/*void lcd_on_off(void)
{
uchar i;
for(i=0;i<32;i++)
{
LCD_ADDR=i;
LCD_DB=0xff;
}
for(dly=0x00ff;dly;dly--)
{
WDTC();
}
for(i=32;i;i--)
{
LCD_ADDR=i;
LCD_DB=0;
}
for(dly=0x1fff;dly;dly--)
{
WDTC();
}
}*/
/******************************按键扫描************************/
/*****************************按键处理************************/
void KeyDo(uchar key)
{
uchar fan_temp;
if (key == ON_OFF){
if(mode_on_off==0)
{
key_flag=1;
mode_on_off=1;
}
else
{
mode_on_off=0;
}
}
else if (key == FAN)
{
timer1=0;
key_flag=1;
if(mode_on_off==1)
{
fan_temp=fan_st&0xe0;
if(fan_temp==0x80)
{
fan_st|=0x40;
fan_st&=0x7f;
}
else if(fan_temp==0x40)
{
fan_st|=0x20;
fan_st&=0xbf;
}
else if(fan_temp==0x20)
{
fan_st|=0x80;
fan_st&=0xdf;
}
}
}
else if (key == MODE)
{
timer1=0;
key_flag=1;
if(mode_on_off==1)
{
fan_temp=fan_st&0x03;
if(fan_temp==0x01)
fan_st++;
else
{
fan_st|=0x01;
fan_st&=0xfd;
}
}
}
else if (key == DECREASE)
{
timer1=0;
key_flag=1;
if (set_temper == 10)
{
set_temper = 10;
}
else
{
set_temper--;
}
}
else if (key == INCREASE)
{ timer1=0;
key_flag=1;
set_temper++;
if (set_temper > 30)
{
set_temper = 30;
}
}
}
uchar KeyScan(void)
{
uchar temp = 0;
temp = PORT8;
temp&=0x1f;
if(temp!=0x1f)
return temp;
return 0x1f;
}
void _intcall counter1_l(void) @ 0x0C:low_int 3
{
}
void _intcall counter1(void) @ int 3
{
//backup R4
_asm
{
SWAPA 0x04
MOV 0x1F,A
}
//backup C system
_asm
{
BS 0X4,6
BS 0X4,7
MOV A,0X10 // USE 1 BYTE C TYPE,C SYSTEM BACKUP
MOV 0X3C+1,A
MOV A,0X14
MOV 0X3B+1,A
MOV A,0X18
MOV 0X3A+1,A
MOV A,0X1B
MOV 0X39+1,A
MOV A,0X1C
MOV 0X38+1,A
}
ISR=0;
timer_2ms_ok=1;
if (key_state == 0)
{
new_key = KeyScan();
if (new_key != 0x1f)
{
key_state++;
}
}
else if (key_state < 5)
{
if (KeyScan() == new_key)
{
key_state++;
}
else
上一篇:EMC单片机指令应用的误区与技巧