//绘制单个字符
void Draw_8X16(int x, int y, const unsigned char ch[])
{
int i = 0, j = 0;
unsigned char mask, buffer;
long location_tt;
location_tt = x * vinfo.bits_per_pixel / 8 + y *finfo.line_length;
//判断是否换行 x坐标
int Is_next_line(int x)
{
if (x >= End_x)
return 1;
return 0;
}
//跳到下一行
int Next_line(int y)
{
//sleep(1);
y = y + 16;
s_y = y;
s_x = Start_x;
return y;
}
//判断是否换屏 y坐标
int Is_next_screen(int y)
{
if (y >= End_y -
return 1;
return 0;
}
//清屏,跳到下一屏
void Next_screen()
{
int ret;
int i;
while (1)
{
ret = read(fk, button_status, 6);
if (ret < 0)
{
printf("read button status err\n"
}
//按键控制翻到下一页
if (button_status[0] == '1')
{
//清屏
clear_screen();
//s_x = Start_x;
s_y = Start_y;
break;
}
if (button_status[1] == '1'){
for(i=0;i<255;i++) ;
if (button_status[1] == '1'){
clear_screen();
printf("%d\n",id);
id=id-532;
s_y = Start_y;
break;}
}
}
// sleep(2);
}
//清屏,跳到上一屏
void UP_screen(unsigned int zf_index)
{
int ret;
//int i=0;
// unsigned char *buffer;
//unsigned char buf[16];
while (1)
{
ret = read(fk, button_status, 6);
if (ret < 0)
{
printf("read button status err\n"
}
//按键控制翻到上一页
if (button_status[1] == '1')
{
//清屏
clear_screen();
//s_x = Start_x;
//zf_index = buffer[i] * 16;
// memcpy(buf, (const void *)&Assic[zf_index], 16);
s_y=zf_index;
break;
}
}
// sleep(2);
}
//绘制一行字符
void Put_text_ch(int x, int y, int size, const unsigned char ch[])
{
int i = 0, j = 0;
unsigned char buffer[16];
for (i = 0; i < size; i++)
{
for (j = 0; j < 16; j++)
{
buffer[j] = ch[i * 16 + j];
}
if (i != 0)
x += 8;
if(Is_next_line(x))
{
y = Next_line(y);
x = s_x;
if (Is_next_screen(y))
{
Next_screen();
y = s_y;
}
}
Draw_8X16(x, y, buffer);
}
}
//绘制一行汉字
void Put_text_hz(int x, int y, int size, const unsigned char ch[])
{
int i = 0, j = 0;
unsigned char buffer[32];
for (i = 0; i < size; i++)
{
for (j = 0; j < 32; j++)
{
buffer[j] = ch[i * 32 + j];
}
if (i != 0)
x += 16;
if(Is_next_line(x))
{
y = Next_line(y);
x = s_x;
if (Is_next_screen(y))
{
Next_screen();
y = s_y;
}
}
Draw_16X16(x, y, buffer);
}
}
//打开LCD设备
void open_lcd()
{
//以可读可写的方式打开LCD设备
fp = open ("/dev/fb0",O_RDWR);
//错误冗余
if (fp < 0){
printf("Error : Can not open framebuffer device\n"
exit(1);
}
//在超级终端打印下面两句话
puts("hello, world.\n"
printf("open framebuffer device\n"
//获取屏幕相关参数
if (ioctl(fp,FBIOGET_FSCREENINFO,&finfo)){
printf("Error reading fixed information\n"
exit(2);
}
if (ioctl(fp,FBIOGET_VSCREENINFO,&vinfo)){
printf("Error reading variable information\n"
exit(3);
}