tq210操作屏幕显示
来源:互联网 发布:mac jmeter下载安装 编辑:程序博客网 时间:2024/05/01 12:20
简单例子操作tq210,/dev/fb0,显示颜色。内核中结构体fb_var_screeninfo,用来描述有关屏幕信息。
arm-linux-gcc 编译后,串口rz下载或者tftp下载到板子上运行。
#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <stdlib.h>#include <sys/mman.h>#include <unistd.h>#include <signal.h>#include <linux/fb.h>#include <stdbool.h>/**struct fb_var_screeninfo {__u32 xres;// visible resolution__u32 yres;__u32 xres_virtual;// virtual resolution__u32 yres_virtual;__u32 xoffset;// offset from virtual to visible __u32 yoffset;// resolution__u32 bits_per_pixel;//guess what__u32 grayscale;/ 0 = color, 1 = grayscale,/>1 = FOURCCstruct fb_bitfield red;/ bitfield in fb mem if true color, struct fb_bitfield green;/else only length is significant struct fb_bitfield blue;struct fb_bitfield transp; transparency__u32 nonstd; != 0 Non standard pixel format __u32 activate;/see FB_ACTIVATE___u32 height;/ height of picture in mm __u32 width;/ width of picture in mm __u32 accel_flags;/ (OBSOLETE) see fb_info.flags /* Timing: All values in pixclocks, except pixclock (of course) __u32 pixclock;/* pixel clock in ps (pico seconds) __u32 left_margin;/* time from sync to picture__u32 right_margin;/* time from picture to sync__u32 upper_margin;/* time from sync to picture__u32 lower_margin;__u32 hsync_len;/* length of horizontal sync__u32 vsync_len;/* length of vertical sync__u32 sync;/* see FB_SYNC_*__u32 vmode;/* see FB_VMODE_*__u32 rotate;/* angle we rotate counter clockwise__u32 colorspace;/* colorspace for FOURCC-based modes __u32 reserved[4];/* Reserved for future compatibility };*/char* plcd = NULL;bool terminated = false;//typedef void (*sighandler_t)(int);void sighandler(int sig){switch(sig){case SIGINT:terminated = true;break;}}void LCD_DrawPoint(unsigned long x , unsigned long y, int color){int *p =(int *) plcd;*(p + y * 800 + x) = color;}//draw screen with colorvoid LCD_ClearScr(int color){unsigned long x, y;for (y = 0; y < 480; y++){for (x = 0; x < 800; x++){LCD_DrawPoint(x, y, color) ;}}}int main(int argc,char** argv){printf("hello tq210\n");signal(SIGINT,sighandler);//sighandler_t signal(int signum, sighandler_t handler);int fd = open("/dev/fb0",O_RDWR);if(fd == -1){perror("open device error");exit(-1);}printf("open device %d\n",fd);/*2. get screen infomations*/structfb_var_screeninfo fbinfo;int r = ioctl(fd,FBIOGET_VSCREENINFO , &fbinfo);if (r == -1){perror("ioctl error:");return -1;}printf("resuation: %d x %d\n", fbinfo.xres, fbinfo.yres);printf("bits_per_pixel: %d bits\n", fbinfo.bits_per_pixel);printf("A: offset %d length %d msb_rigth: %d\n ", fbinfo.transp.offset, fbinfo.transp.length, fbinfo.transp.msb_right);printf("R: offset %d length %d msb_rigth: %d\n ", fbinfo.red.offset, fbinfo.red.length, fbinfo.red.msb_right);printf("G: offset %d length %d msb_rigth: %d\n ", fbinfo.green.offset, fbinfo.green.length, fbinfo.green.msb_right);printf("B: offset %d length %d msb_rigth: %d\n ", fbinfo.blue.offset, fbinfo.blue.length, fbinfo.blue.msb_right);/*3. mmap*/plcd = mmap(NULL, fbinfo.xres * fbinfo.yres * (fbinfo.bits_per_pixel / 8),PROT_WRITE,MAP_SHARED,fd,0);while(!terminated){LCD_ClearScr(0xff);//bluesleep(2);LCD_ClearScr(0xff00);//greensleep(2);LCD_ClearScr(0xff0000);//redsleep(2);}munmap(plcd,fbinfo.xres * fbinfo.yres * (fbinfo.bits_per_pixel / 8));close(fd);return 0;}
串口中显示的信息:
[root@klein /]# ./a.out
hello tq210
open device 3
resuation: 800 x 480
bits_per_pixel: 32 bits
A: offset 24 length 8 msb_rigth: 0
R: offset 16 length 8 msb_rigth: 0
G: offset 8 length 8 msb_rigth: 0
B: offset 0 length 8 msb_rigth: 0
0 0
- tq210操作屏幕显示
- wince6 TQ210电源管理对屏幕保护的影响
- Android 几种常用关于屏幕操作的方法(获取屏幕大小,全屏,显示方向)
- 屏幕操作
- tq210基本参数
- 更改屏幕显示区
- android屏幕显示设置
- BIOS 屏幕显示中断
- 字幕显示屏幕保护
- 获取屏幕显示
- VC多屏幕显示
- 摄像头屏幕三分之二显示
- div屏幕居中显示
- win7 屏幕显示
- 在屏幕显示信息
- 屏幕显示技巧
- ubuntu外接屏幕显示
- 多屏幕显示
- STL源码笔记(9)—序列式容器之vector(二)
- Android init源代码分析(1)概要分析
- FBI树
- 【补充】offset()和position()的区别。
- S3C2451_GPIO初始化、置位、读取源码
- tq210操作屏幕显示
- 常用函数
- 4.Reverse Words in a String-Leetcode
- 基于OpenCV的人脸识别门禁系统
- fastDFS+nginx配置
- 探究printf
- 三栏布局的实现
- 关于Node.js你必须要知道的原理性知识
- Flume:本地文件到HDFS