本帖最后由 jiuzhi1990 于 2011-5-24 11:48 编辑
用按键控制12864的显示,但是总是出现前面显示的汉字覆盖后面计划显示的汉字,这是什么原因呢?但是波形能正常显示。
/*******************************
函数功能:键盘扫描
*******************************/
unsigned char keyscan()
{
uchar key;
if(keyport!=0xff)
{
delay_50us(200);
if(keyport!=0xff)
{
key=keyport;
while(keyport!=0xff);
switch(key)
{
case 0xfe: return 1;break;
case 0xfd: return 2;break;
case 0xfb: return 3;break;
case 0xf7: return 4;break;
case 0xef: return 5;break;
case 0xdf: return 6;break;
default: return 0;break;
}
}
}
}
/*******************************
函数功能:按键处理
*******************************/
void key_deal(unsigned char key)
{
switch(key)
{
case 0:
lcd_string(0,1,"质量检测");
lcd_string(0,2,"成员:张三");
lcd_string(3,3,"李四");
lcd_string(3,4,"王五");
break;
case 1:
lcd_clear();
clr_gdram();
drawsin();
break;
case 2:
lcd_clear();
lcd_string(0,1,"电压有效值:");
lcd_string(7,1,"5.68");
lcd_string(0,2,"电流有效值:");
lcd_string(7,2,"3.24");
lcd_string(0,3,"电压频率:");
lcd_string(6,3,"50Hz");
break;
case 3:
lcd_clear();
lcd_string(0,1,"有功功率:");
lcd_string(6,1,"23.123");
lcd_string(0,2,"无功功率:");
lcd_string(6,2,"12.234");
lcd_string(0,3,"视在功率:");
lcd_string(6,3,"22.678");
lcd_string(0,4,"功率因数:");
lcd_string(6,4,"0.989");
break;
}
}
main( )
{
lcd_init();
lcd_clear();
while(1)
{
key_deal(keyscan());
}
case0中的数据显示后一直不能改变,但是case1和case2中的数据在没有case0覆盖的区域可以互相改变
} |