LCD控制实验—孟明明
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
阅读(575) | 评论(0) | 转发(0) |
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
#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
相关热门文章
给主人留下些什么吧!~~
评论热议