程序一:
int main(void)
{
lcd_clean(0);
/*line-one*/
lcd_display_character(&ch_1,0,2*16,0,1);
lcd_display_character(&ch_2,0,3*16,0,1);
lcd_display_character(&ch_3,0,0*16,1,0);
lcd_display_character(&ch_4,0,1*16,1,0);
/*line-four*/
lcd_display_character(&ch_9,6,1*16,0,1);
lcd_display_character(&ch_10,6,2*16,0,1);
lcd_display_character(&ch_11,6,3*16,0,1);
lcd_display_character(&ch_12,6,0*16,1,0);
lcd_display_character(&ch_13,6,1*16,1,0);
lcd_display_character(&ch_14,6,2*16,1,0);
lcd_close();
lcd_open();
return 0;
}
程序二:
int main(void)
{
int buttons,buttonsLast=0x000F; //按键变量
lcd_clean(0);
while(1)
{
buttons=IORD(BUTTONS_BASE,0); //读取按键数据输入码
if(buttons!=buttonsLast && buttonsLast==0x000F) //判断是否有按键按下
{
switch(buttons & 0x000F)
{
case 0x000E: //按键1按下,只显示第一行
lcd_display_character(&ch_1,0,2*16,0,1);
lcd_display_character(&ch_2,0,3*16,0,1);
lcd_display_character(&ch_3,0,0*16,1,0);
lcd_display_character(&ch_4,0,1*16,1,0);
lcd_close();
lcd_open();
break;
case 0x000D: //按键2按下,只显示第四行
lcd_display_character(&ch_9,6,1*16,0,1);
lcd_display_character(&ch_10,6,2*16,0,1);
lcd_display_character(&ch_11,6,3*16,0,1);
lcd_display_character(&ch_12,6,0*16,1,0);
lcd_display_character(&ch_13,6,1*16,1,0);
lcd_display_character(&ch_14,6,2*16,1,0);
lcd_close();
lcd_open();
break;
case 0x000F: //没有按键按下
buttons=buttonsLast=0x000F;
break;
default:
break;
}
}
buttonsLast=buttons; //保存当前按键值到buttonsLast变量
}
return 0;
}
|