有时由于用串口调试信息存在一定的局限性,希望在lcd打印一些debug信息,所以需要一个lcd上的打印函数
如下:
#include
#include
#include
#include
void disable_blankinterval(void)
{
int f;
f = open("/dev/tty0", O_RDWR);
if(f < 0)
{
printf("Can not write /dev/tty0\n");
printf("(mknod /dev/tty0 c 4 0)\n");
}
write(f, "\033[9;0]", 8);
close(f);
}
int printfonlcd(const char *fmt, ...)
{
char sys_printf_buf[128];
char printf_buf[128];
va_list args;
int printed;
va_start(args, fmt);
printed = vsprintf(printf_buf, fmt, args);
va_end(args);
sprintf(sys_printf_buf,"echo %s > /dev/tty0", printf_buf);
system(sys_printf_buf);
//puts(printf_buf);
return printed;
}
int main(int argc, char *argv[])
{
int cnt = 0;
int time;
if(argc != 2)
{
printf("arguments error! Please enter a argument\n");
return 1;
}
disable_blankinterval();
//system("echo -e "\033[9;0]" > /dev/tty0");
time = atoi(argv[1]);
while(1)
{
cnt++;
printfonlcd("Test On LCD Screen, %d", cnt);
usleep(time);
if(cnt >= 9)
cnt = 0;
}
return 0;
}
阅读(837) | 评论(0) | 转发(0) |