- 论坛徽章:
- 0
|
09计应一班 孟明明 LCD控制实验
#include <stdio.h> #include <string.h> #include <stdlib.h>
#include <fcntl.h> // open() close() #include <unistd.h> // read() write()
#define DEVICE_NAME "/dev/fb0"
#define VERSION "PXA270RP-LCD-V1.00-090101"
void showversion(void) { printf("*********************************************\n"); printf("\t %s \t\n", VERSION); printf("*********************************************\n\n");
}
//------------------------------------- main ---------------------------------------------------------------- int main(void) { int fd; int ret; int i; int j; int f=0; int k=0; unsigned short buf[480][800];
showversion();
printf("\nstart test_lcd test\n\n");
fd = open(DEVICE_NAME, O_RDWR); printf("fd = %d\n",fd);
if (fd == -1) { printf("open device %s error\n",DEVICE_NAME); } else { for(i=0;i<480;i++){ for(j=0;j<800;j++){ buf[i][j]=0x0001; } } ret=write(fd,buf,sizeof(buf));
usleep(500000); close(fd); //---------------------------------------------- while(1){ //设置一个方块中嵌套方块的图片并向四周同时扩散 //也可将循环过程封装成一个函数,进行函数回调,效果会更好!
fd = open(DEVICE_NAME, O_RDWR); for(i=0;i<480;i++){ for(j=0;j<f;j++){ buf[i][j]=0x0001; } } ret=write(fd,buf,sizeof(buf));
//usleep(500000); close(fd); fd = open(DEVICE_NAME, O_RDWR); for(i=200-f;i<280+f;i++){ for(j=340-k;j<460+k;j++){ buf[i][j]=0xf800; } } for(i=220-f;i<260+f;i++){ for(j=370-k;j<430+k;j++){ buf[i][j]=0x0001; } } for(i=240-f;i<240+f;i++){ for(j=400-k;j<400+k;j++){ buf[i][j]=0xf81f; } }
f=f+8; k=k+12; ret=write(fd,buf,sizeof(buf)); usleep(100000); close(fd); if(f>=200||k>=340){ for(i=0;i<480;i++){ for(j=0;j<800;j++){ buf[i][j]=0x0001; } } f=0; k=0; } } if(getchar()>0){ system("cat fb >/dev/fb0"); system("cat apl_test/fb >/dev/fb0"); } }
return 0; }// end main
|
|