/*****************************按键处理************************/
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
{
key_state = 0;
}
}
else if (key_state == 5)
{
key_state++;
KeyDo(new_key);
}
else if (key_state == 6)
{
key_temp = KeyScan();
if (key_temp == 0x1f)
{
key_state ++;
}
else if (key_temp == DECREASE || key_temp == INCREASE)
{
if (key_tcc >= 10)
{
key_tcc = 5;
KeyDo(key_temp);
}
else
{
key_tcc++;
}
}
}
else if (key_state < 10)
{
if (KeyScan() == 0x1f)
{
key_state ++;
}
else
{
key_state = 6;
}
}
else if (key_state == 10)
{
key_state = 0;
key_tcc = 0;
}
if(mode_on_off)
{
times++;
timer1++;
if(++timer2>=100)
{
timer_1s_ok=1;
timer2=0;
}
}
// Write your code (inline assembly or C) here
//restore C system
_asm
{
BS 0X4,6
BS 0X4,7
MOV A,0X3C+1 // USE 1 BYTE C TYPE,C SYSTEM RESTORE
MOV 0X10,A
MOV A,0X3B+1
MOV 0X14,A
MOV A,0X3A+1
MOV 0X18,A
MOV A,0X39+1
MOV 0X1B,A
MOV A,0X38+1
MOV 0X1C,A
}
//restore R4
_asm
{
SWAPA 0x1F
MOV 0X04,A
}
}
void main()
{
uchar temp1,temp2;
uchar i,j;
uchar *r;
uchar b;
uchar c;
uchar stst;
uchar *w;
uchar x;
uchar y;
DISI();
tms(10);
sys_init();
//lcd_init(0xf7);
r_buf[0]=0;
r_buf[1]=0;
r=r_buf; //读参数
b=0x00;
c=2;
w=w_buf; //写参数
x=0x00;
y=2;
//w_buf[0]=0x81;
//w_buf[1]=0x19;
// wt24c(w,x,y); //出厂写EEPROM
rd24c(r,b,c); //初始读EEPROM
fan_st=r_buf[0];
set_temper=r_buf[1];
init_1302();
temp1=test_temperature();
for(i=0;i=250)
{
temp1=test_temperature();
times=0;
}
temp2=Bin1toBcd(set_temper);
display(temp1,fan_st,temp2);
PORT6=fan_st&0xe0;
stst=fan_st&0x01;
if(stst==0x01)
{
COOL=1;
HOT=0;
tms(1);
if((temp1>temp2)&&(COL_RST_FLAG==0))
{
j=0;
while((COOL_IF_L)&&(j