Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6557082
  • 博文数量: 1159
  • 博客积分: 12444
  • 博客等级: 上将
  • 技术积分: 12570
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-13 21:34
文章分类

全部博文(1159)

文章存档

2016年(126)

2015年(350)

2014年(56)

2013年(91)

2012年(182)

2011年(193)

2010年(138)

2009年(23)

分类: 嵌入式

2011-10-21 14:48:42

09计应一班 孟明明 LCD控制实验

#include
#include
#include

#include      // open() close()
#include     // 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

阅读(1496) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~