E-BOOK-TINY6410-LCD的使用
电子书需要通过屏幕显示出来,首先写了LCD模块。代码上传到了 github https://github.com/qq2216691777/E-book
本次完善了lcd模块的程序。可以适用在其他地方。
代码:fb.c fb.h
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <stdlib.h> #include "fb.h"
#include "main.h" static int Device_FB_Init(void);
static void lcd_put_pixel(int x, int y, unsigned int color );
static void lcd_clean( unsigned int color );
static void Device_FB_Destory(void); fb_t g_fb={
0,
0,
0,
0,
0,
0,
NULL,
&Device_FB_Init,
&lcd_put_pixel,
&lcd_clean,
&Device_FB_Destory,
}; static void lcd_put_pixel(int x, int y, unsigned int color )
{
unsigned char *pen_8 = g_fb.fbmem + y*g_fb.xres*g_fb.pixel_chars+x*g_fb.pixel_chars;
unsigned short *pen_16 = (unsigned short *)pen_8;
unsigned short *pen_32 = (unsigned short *)pen_8;
unsigned char red,blue,green;
switch(g_fb.pixel_bits)
{
case 8:
*pen_8 = color;
break;
case 16:
/* 565 */
red = (color>>16) & 0xff;
green = (color>>8) & 0xff;
blue = (color>>0) & 0xff;
color = ((red>>3)<<11) | ((green>>2)<<5) |((blue>>3));
*pen_16 = color;
break;
case 32:
*pen_32 = color;
break;
default:
DEBUG_PRINT("ERROR: can't support %ddpp\n",g_fb.pixel_bits);
break;
}
} static void lcd_clean( unsigned int color )
{
unsigned char *pen_8 = g_fb.fbmem;
unsigned short *pen_16 = (unsigned short *)pen_8;
unsigned short *pen_32 = (unsigned short *)pen_8;
unsigned char red,blue,green;
int i = g_fb.screen_size;
switch(g_fb.pixel_bits)
{
case 8:
break;
case 16:
/* 565 */
red = (color>>16) & 0xff;
green = (color>>8) & 0xff;
blue = (color>>0) & 0xff;
color = ((red>>3)<<11) | ((green>>2)<<5) |((blue>>3));
break;
case 32:
break;
default:
DEBUG_PRINT("ERROR: can't support %ddpp\n",g_fb.pixel_bits);
return;
}
while(i)
{
switch(g_fb.pixel_bits)
{
case 8:
*pen_8 = color;
pen_8++;
i--;
break;
case 16:
*pen_16 = color;
pen_16++;
i-=2;
break;
case 32:
*pen_32 = color;
pen_32++;
i-=4;
break; } } } static int Device_FB_Init(void)
{
int fb_fd;
struct fb_fix_screeninfo fix;
struct fb_var_screeninfo var; fb_fd = open(DEVICE_NAME, O_RDWR);
if (fb_fd<0)
{
DEBUG_PRINT("open device fb failed\n");
return -1;
}
if( ioctl( fb_fd, FBIOGET_VSCREENINFO, &var ) )
{
DEBUG_PRINT("can't get var\n");
return -1;
} if( ioctl( fb_fd, FBIOGET_FSCREENINFO, &fix ) )
{
DEBUG_PRINT("can't get fix\n");
return -1;
} g_fb.fd = fb_fd;
g_fb.xres = var.xres;
g_fb.yres = var.yres;
g_fb.pixel_bits = var.bits_per_pixel;
g_fb.pixel_chars = var.bits_per_pixel/8;
g_fb.screen_size = var.xres*var.yres*var.bits_per_pixel/8;
g_fb.fbmem = (unsigned char *)mmap( NULL, g_fb.screen_size, PROT_READ | PROT_WRITE, MAP_SHARED,fb_fd,0 ); printf("xres:%d\n", g_fb.xres);
printf("yres:%d\n", g_fb.yres);
printf("pixel bit:%d\n", g_fb.pixel_bits);
printf("pixel char:%d\n", g_fb.pixel_chars);
return 0; } static void Device_FB_Destory(void)
{
free(g_fb.fbmem);
}
#ifndef _FB_H__
#define _FB_H__ #define DEVICE_NAME "/dev/fb0" typedef struct
{
int fd;
int xres;
int yres;
int pixel_bits;
int pixel_chars;
int screen_size;
unsigned char *fbmem;
void (*Devie_Init)(void);
void (*put_pixel)(int x, int y, unsigned int color );
void (*cleanscreen)( unsigned int color );
void (*Devie_Destory)(void); }fb_t; extern fb_t g_fb; #endif
E-BOOK-TINY6410-LCD的使用的更多相关文章
- Tiny6410 LCD设置
1.注意LCD的硬件连接 2.LCD初始化 2.1 初始化步骤 LCD时序设置 LCD芯片 2.2 引脚初始化 2.3 配置 MIFPCON 寄存器及SPCON 寄存器 2.4 配置VIDCONx 2 ...
- 向tiny6410中移植中移植linux-4.5.1内核(最新)
下载linux-4.5.1.tar.gz 解压在任意目录下.我解压在/home/tiny6410/ # tar xvzf linux-4.5.1.tar.gz # cd linux-4.5.1/ 修改 ...
- Tiny6410之重定位代码到SDRAM
在上一章中,将代码重定位到了SRAM中,但是这样的做法作用不大.正确的做法的是将代码重定位到更大的主存中,即DRAM.Tiny6410的DRAM控制寄存器最多只能支持两个同一类型的芯片.每个芯片最多可 ...
- tiny6410 启动参数
baudrate=115200 bootargs=noinitrd root=/dev/nfs nfsroot=192.168.1.116:/home/suxuandong/Documents/com ...
- tiny6410 uboot启动参数的问题
使用uboot来启动tiny6410,需要在启动参数中加入lcd=S70,才能在lcd上显示正确的画面
- 自己写Tiny6410的Bootloader总结!
1.由于Tiny6410 2G版的Nand flash(K9GAG08U0E)的页大小是8K的,但是s3c6410芯片设置为nand flash启动时先从nand flash复制8K代码到片内内存中去 ...
- Tiny6410烧入uboot,linux内核,文件系统
好久没有玩tiny6410了,今天拿出来试试.之前学习一直是跟着视频学习的.今天自己动手来做一下. 首先我将光盘linux目录下的linux-2.6.38-20150708.tgz rootfs_r ...
- STM32F429 LCD程序移植
STM32F429自带LCD驱动器,这一具有功能给我等纠结于屏幕驱动的程序员带来了很大的福音.有经验的读者一定有过这样的经历,用FSMC驱动带由控制器的屏幕时候,一旦驱动芯片更换,则需要重新针对此驱动 ...
- 分页型Memory LCD显存管理与emWin移植
上一篇随笔整理了一下逐行扫描型Memory LCD的显存管理与emWin移植,这篇就整理一下分页型Memory LCD显存管理与emWin移植. //此处以SSD1306作为实例 //OLED的显存/ ...
- 逐行扫描型Memory LCD显存管理与emWin移植
因为Memory LCD 的特性,不能设置像素坐标,只能用缓存整体刷新. 所以对于Memory LCD来说,emWin移植仅与打点函数有关,这里用Sharp Memory LCD(ls013b7dh0 ...
随机推荐
- Spring Boot 集成 MQTT
本文代码有些许问题,处理方案见:解决 spring-integration-mqtt 频繁报 Lost connection 错误 一.添加配置 spring: mqtt: client: usern ...
- spring框架使用c3po链接数据库
编辑工具:idea 1.配置pom.xml文件(创建模板时软件自动创建) 导入spring的核心架包 全部架包官网:https://mvnrepository.com/ 1 <dependenc ...
- 第15.19节 PyQt(Python+Qt)入门学习:自定义信号与槽连接
老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 一.引言 本文利用中介绍了PyQt中的信号和槽机制,除了使用PyQt组件的已有信号外,PyQt和Qt ...
- Kubernetes的Local Persistent Volumes使用小记
欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...
- 手把手教你写DI_2_小白徒手撸构造函数注入
小白徒手撸构造函数注入 在上一节:手把手教你写DI_1_DI框架有什么? 我们已经知道我们要撸哪些东西了 那么我们开始动工吧,这里呢,我们找小白同学来表演下 小白同学 :我们先定义一下我们的广告招聘纸 ...
- 惊天秘密!如何在 Flutter 项目中实现操作引导
不要冒然评价我,你只知道我的名字,却不知道我的故事,你只是听闻我做了什么,却不知我经历过什么. 俗话说得好,产品有三宝,弹窗浮层加引导. 上图截图自我司 App 晓黑板中的口算模块,相信每个 App ...
- 圆周率PI
import math import time scale=30 s,m,=1,2 total,s,n,t=0.0,1,1.0,1.0 print("执行开始".center(sc ...
- oracle 11g调优常用语句
1.查询表的基数及选择性 select a.column_name, b.num_rows, a.num_distinct cardinality, round( ...
- ORA-29701: unable to connect to Cluster Synchronization Service
修改主机名后,has无法启动,将has启动之后,尝试ASMCA,出现如图提示: 再尝试登陆asm实例,出现日下提示: [oracle@edgzrip2-+ASM ~]$ sqlplus / as sy ...
- gnuplot取消曲线标题
plot 'File.dat' using 1:2 notitle或者 plot 'File.dat' using 1:2 title ""