资源简介
基于嵌入式linux系统下的画板小程序,可以实现画板的显示以及画笔的切换,单线程操作,可以清空画板。
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
void show_color_q(int locat1int locat2int sizexint sizeyint colorchar *p);
void show_inite(char *p);
void double_dot(int xint ychar *p);//显示点的函数
void show_line(int x1int y1int x2int y2char *p);
int main(void)
{
int lcd = open(“/dev/fb0“O_RDWR);
int fd = open(“/dev/input/event0“O_RDONLY);
struct input_event buf;
if(lcd == -1)
{
perror(“开启LCD失败“);
exit(0);
}
char *p = mmap(NULL800*480*4PROT_READ | PROT_WRITEMAP_SHAREDlcd0);
int32_t c0 = 0x00ed1c24;
int32_t c1 = 0x00fff300;
int32_t c2 = 0x0022b14c;
int32_t c3 = 0x00b97a56;
int32_t c4 = 0x0099d9eb;
int32_t c5 = 0x00000000;
int32_t c6 = 0x003e48cd;
int32_t c7 = 0x00a348a5;
int32_t colors[]={c0c1c2c3c4c5c6c7};
show_inite(p);
bool xdone = false;
bool ydone = true;
bool x1done = false;
bool y1done = true;
bool charge = false;
int a=1000b=1000a1=1000b1=1000;
while(1)
{
bzero(&bufsizeof(buf));
read(fd&bufsizeof(buf));
if(buf.type == EV_ABS)
{
if(buf.code == ABS_X&&ydone==true&&charge==false)
{
a=buf.value;
xdone = true;
ydone = false;
}
else if(buf.code == ABS_Y&&xdone ==true&&charge==false)
{
b=buf.value;
ydone = true;
xdone = false;
charge = true;
if(a<=20&&b<=20)
show_inite(p);
if(a1<798&&b1<478)
show_line(a1b1abp);
}
else if(buf.code == ABS_X&&y1done==true&&charge == true)
{
a1=buf.value;
x1done = true;
y1done = false;
评论
共有 条评论