关于DE2上的LCD_16207的文件altera_avalon_lcd_16207.c中的lcd_handle_escape()代码
- UID
- 800354
|
关于DE2上的LCD_16207的文件altera_avalon_lcd_16207.c中的lcd_handle_escape()代码
哪位兄弟帮我解释一下DE2上的液晶LCD_16207的文件altera_avalon_lcd_16207.c中的lcd_handle_escape()函数代码,看了几天实在看不明白,帮忙解释一下,谢谢!
static void lcd_handle_escape(alt_LCD_16207_dev * dev, char c)
{
int parm1 = 0, parm2 = 0; //parm1和parm2两个变量起什么作用 ?
if (dev->escape[0] == '[') //结构体中的escape数组是存放什么的?为什么要将escape[0]元素赋值'[',是用'['的ASCII代码091吗?
{
char * ptr = dev->escape+1; //为什么要将指针ptr指向数组元素escape[1]?
while (isdigit(*ptr))
parm1 = (parm1 * 10) + (*ptr++ - '0'); //parm1开始不是被赋值0了吗?这里 parm1乘10不还是0吗?*ptr++ - '0'又是干什么呢?是变量*ptr减去'0'的ASCII代码048吗?
if (*ptr == ';') //又为什么要变量*ptr等于';'才有下面的操作?
{
ptr++;
while (isdigit(*ptr))
parm2 = (parm2 * 10) + (*ptr++ - '0'); //这几行是在干什么?
}
}
else
parm1 = -1;
switch (c)
{
case 'H': /* ESC '[' <y> ';' <x> 'H' : Move cursor to location */ //如果是情况'H',是干什么?
case 'f': /* Same as above */ //如果是情况'f',下面有是在干什么?
if (parm2 > 0)
dev->x = parm2 - 1;
if (parm1 > 0)
{
dev->y = parm1 - 1;
if (dev->y > ALT_LCD_HEIGHT * 2)
dev->y = ALT_LCD_HEIGHT * 2;
while (dev->y > ALT_LCD_HEIGHT)
lcd_scroll_up(dev);
}
break;
case 'J': //如果是情况'J',下面有是在干什么?
/* ESC J is clear to beginning of line [unimplemented]
* ESC [ 0 J is clear to bottom of screen [unimplemented]
* ESC [ 1 J is clear to beginning of screen [unimplemented]
* ESC [ 2 J is clear screen
*/
if (parm1 == 2)
lcd_clear_screen(dev);
break;
case 'K': //如果是情况'K',下面有是在干什么?
/* ESC K is clear to end of line
* ESC [ 0 K is clear to end of line
* ESC [ 1 K is clear to beginning of line [unimplemented]
* ESC [ 2 K is clear line [unimplemented]
*/
if (parm1 < 1)
{
if (dev->x < ALT_LCD_VIRTUAL_WIDTH)
memset(dev->line[dev->y].data + dev->x, ' ', ALT_LCD_VIRTUAL_WIDTH - dev->x);
}
break;
}
} |
|
|
|
|
|