#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
int main()
{
int fd = open("/dev/fb0",O_RDWR);
if(-1 == fd)
{
printf("open lcd error\n");
return 0;
}
//映射内存
int * plcd = mmap(NULL,800*480*4, PROT_WRITE | PROT_READ,MAP_SHARED,fd,0);
if(plcd == MAP_FAILED)
{
printf("map error\n");
return 0;
}
int cinx,ciny;//确认开始的横纵坐标
cinx=151;
ciny=200;
int julen,juwid; //矩形的长与宽
julen=100;
juwid=80;
int color; //矩形的颜色
color=0x00ff0000;
int x,y;
for(y=ciny;y<=cinx+juwid;y++)
{
for(x=cinx;x<=cinx+julen;x++)
{
*(plcd+800*y+x) = 0x00ff0000;
}
}
munmap(plcd,800*480*4);
sleep(3);
return 0;
}