MCU:PIC24H128***
LCD Driver:st7567
void LcdSetContrast(U8 count)
{
#if 1
LcdWriteCmd(0x81);
LcdWriteDat(20+count); //EV(00~3F)
#endif
}
//按键响应
void CmdConfigSetup(U8 id)
{
U8 config_min_max[][2]={{1,5},{0,1},{0,4},{1,5},{1,15},{0,1}};
switch(id)
{
case KeyUpdate:
GuiConfigSetup(1);
break;
case KeyInc:
if(lcd_value_flag)
{
if(config_data[lcd_item_sel]==config_min_max[lcd_item_sel][1])
{
is_boundary_flag=1;
if(!is_mask_key_flag)
{
config_data[lcd_item_sel]=config_min_max[lcd_item_sel][0];
is_boundary_flag=0;
}
}
else
config_data[lcd_item_sel]++;
if(lcd_item_sel==4)
{
LcdSetContrast(LCD_CONTRAST);
}
}
else
{
lcd_row_last=lcd_row_sel;
if(lcd_row_sel>1)
lcd_row_sel--;
lcd_item_sel=lcd_row_sel-1;
}
GuiConfigSetup(0);
break;
case KeyDec:
if(lcd_value_flag)
{
if(config_data[lcd_item_sel]==config_min_max[lcd_item_sel][0])
{
is_boundary_flag=1;
if(!is_mask_key_flag)
{
config_data[lcd_item_sel]=config_min_max[lcd_item_sel][1];
is_boundary_flag=0;
}
}
else
config_data[lcd_item_sel]--;
if(lcd_item_sel==4)
LcdSetContrast(LCD_CONTRAST);
}
else
{
lcd_row_last=lcd_row_sel;
if(lcd_row_sel<6)
lcd_row_sel++;
lcd_item_sel=lcd_row_sel-1;
}
GuiConfigSetup(0);
break;
case KeyEsc:
if(lcd_value_flag)
{
lcd_value_flag=0;
GuiConfigSetup(0);
}
else
{
lcd_state_main=Lcd_Main;
SendImMsg(KeyUpdate);
}
break;
case KeyOk:
lcd_value_flag=!lcd_value_flag;
GuiConfigSetup(0);
break;
default:
break;
}
}
我在主程序LCD 初始化时,设置LCD对比度,都是正确的,但我按按键不放时,对比度只没有变化,或是错误的,请问大家,这个是什么原因。
一周热门 更多>