📄 main.c
字号:
if(countMin>59)
{
countMin=0;
}
}
void keyscan(void)//382 byte
{
#if 1
bit Flagcheckkeyvalid;//need not initial for key and data port check
char i;
char temp;
temp=0xfe;
for(i=0;i<8;i++)
{
if((temp&0x01)==1)
{
DataPort=1;
}
else
{
DataPort=0;
}
DataPortClk=0;
//nop_instruction();
DataPortClk=1;
nop_instruction();
DataPortPiD=0;//change to input mode
PULL0.3=1;//po_3 pull up
nop_instruction();
nop_instruction();
if(DataPort==0)
{
keytemp1=keylist[i];
Flagcheckkeyvalid=1;
}
if(Key==0)
{
keytemp2=keylist[i+8];
Flagcheckkeyvalid=1;
}
DataPortPiD=1;//change to output mode
nop_instruction();
temp=temp>>1;
}
if(Flagcheckkeyvalid==0)
{
keytemp1=0xff;
keytemp2=0xff;
}
else
{
Flagcheckkeyvalid=0;
}
#endif
}
void KeyProcess(void)//1255 byte
{
#if 1
if(KeyScanCs==1)//enable keyprocess every 12ms check once
{
KeyScanCs=0;
if((keytemp1!=0xff)&(keytemp2==0xff))//legal key
{
KeyValue=keytemp1;
}
else if((keytemp1==0xff)&(keytemp2!=0xff))//legal key
{
KeyValue=keytemp2;
}
else
{
KeyValue=0xff;//valid key
}
TempA=KeyBuf;
TempA=KeyValue;
if(KeyValue!=0xff)//key pressed
{
if(KeyValue==KeyBuf)//debounce
{
if(KeyAnswer==1)//key is running
{
return;//key has been running
}
else
{
//**************************key function*****************************//
//key for start//
if(KeyValue==Key_Switch)
{
buzzer_on_flag=1;//beeper
count_1s=0;//clear counter
count_1min=0;
Flag40s=0;
Flag1Min=0;
if(StatusRun==0)
{
StatusRun=1;
}
if((StatusRun==1)&(FlagFuncEnable==1))//close all func
{
Func.ubyte=0;
FlagFuncEnable=0;
FlagFunc_YuYueDingShi=0;
FlagSetOver_SetupYuYueDingShi=0;
K=0;
FlagErrorDisplayPan=0;//initial error display
InitialErrorDisplayPan=0;//initial error display
CountineCheckPan=0;//initial error display
InitialErrorDisplayIGBT=0;
FlagFun_CheckPan=0;
InitialCheckIGBT=0;//only clear by poweroff
FlagSeriousError=0;//clear serious error
FlagHardwareError=0;//clear hardware error
FlagIGBTError=0;//clear igbt flag
FlagIGBTOverHeat=0;//clear igbt flag
FlagPanelError=0;
FlagPanelOverHeat=0;
FlagPowerVoltHigh=0;
FlagPowerVoltLow=0;
InitialK=0;//initial (k give pluse)
Power.ubyte=0;
//for test
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = CMP01_L_800W; /* Write low-order of compare 01 */
CRAH = CMP01_H_800W; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow *///close pwm
}
KeyAnswer=1;//key has been running
}
//end key for start//
//key for function distribute//
if((StatusRun==1)&(FlagSeriousError==0))
{
switch(KeyValue)
{
case 0:;
break;
case 1:;
break;
case 2:
if(FlagFunc_Zhufan!=1)
{
FuncSerial=0;
Func.ubyte=0x08;
Power.ubyte=0x00;
KeyFuncSetupInitial();
}
KeyAnswer=1;//key has been running
break;
case 3:
if(FlagFunc_ShaoKao!=1)//auto func
{
FuncSerial=1;
Func.ubyte=0x20;
Power.ubyte=0x10;//initial display 180 oc
KeyFuncSetupInitial();
}
KeyAnswer=1;//key has been running
break;
case 4:;
break;
case 5:
if(FlagFunc_ShaoShui!=1)
{
FuncSerial=2;
Func.ubyte=0x01;
Power.ubyte=0x00;
KeyFuncSetupInitial();
}
KeyAnswer=1;//key has been running
break;
case 6:
if(FlagFunc_ZhengDun!=1)
{
FuncSerial=3;
Func.ubyte=0x02;
Power.ubyte=0x00;
KeyFuncSetupInitial();
}
KeyAnswer=1;//key has been running
break;
case 7:
if(FlagFunc_JianChao!=1)//auto func
{
FuncSerial=4;
Func.ubyte=0x40;
Power.ubyte=0x80;//initial display 1800w
KeyFuncSetupInitial();
}
KeyAnswer=1;//key has been running
break;
case 8:;
break;
case 9:
if(FlagFunc_HuoGuo!=1)//autofunc
{
FuncSerial=5;
Func.ubyte=0x10;
Power.ubyte=0x10;//initial display 1200w
KeyFuncSetupInitial();
}
KeyAnswer=1;//key has been running
break;
case 10:;
break;
case 11:
if(FlagFunc_AoZhou!=1)
{
FuncSerial=6;
Func.ubyte=0x04;
Power.ubyte=0x00;
KeyFuncSetupInitial();
}
KeyAnswer=1;//key has been running
break;
case 12:
if(FlagFunc_BaoTang!=1)
{
FuncSerial=7;
Func.ubyte=0x80;
Power.ubyte=0x00;
KeyFuncSetupInitial();
}
KeyAnswer=1;//key has been running
break;
default:break;
}
//insert powerserial calculate
PowerSerialSearch();
//end insert powerserial calculate
}
//end for function distribute//
//Start Yuyue Func//
if(((StatusRun==1)&(FlagFuncEnable==1))&(FlagPan==1)&(FlagSeriousError==0))
{
if(KeyValue==Key_YuYueDingShi)
{
buzzer_on_flag=1;
if(FlagFunc_YuYueDingShi==0)
{
FlagFunc_YuYueDingShi=1;//yuyue start
EnableYuYueCounter=0;
}
else
{//close yuyue
FlagFunc_YuYueDingShi=0;
FlagSetOver_SetupYuYueDingShi=0;
EnableYuYueCounter=1;
FlagYuYueDingShiTimeVaid=0;
InitialK=0;
}
TempDisp0=0xff;
TempDisp1=LEDDisp[0]+DispLed_Dp;
TempDisp2=LEDDisp[0];
TempDisp3=LEDDisp[0];
Temp0=0;
Temp1=0;
Temp2=0;
Temp3=0;
count_500ms=0;
countMin=0;
countHour=0;
Flag500msTwinkle=1;//initial light when go into yuyue
Flag5s=0;//set 5s inital
count_1s=0;//set 5s inital
count_5s=0;//set 5s inital
KeyAnswer=1;//key has been respond
}
}
if(((KeyValue==Key_Decrease)||(KeyValue==Key_Increase))
&(FlagFunc_YuYueDingShi==1)&(FlagSetOver_SetupYuYueDingShi==0)&(FlagSeriousError==0))//setup hour
{
FlagDisableTwinkle_SetupYuYueDingShi=1;
count_1s=0;//set 5s initial
count_5s=0;
if((CountKeyCycle==0))//frist in keyprocess
{
buzzer_on_flag=1;//start beeper
count_500ms=0;
Flag500msTwinkle=1;//initial light when go into decrease
LongKeyCs=0;
KeyDecreaseIncreaseFunc();
}
CountKeyCycle++;
if(CountKeyCycle>=50)//second or above in keyprocess
{
CountKeyCycle=49;//countkeycycle++,so it can enter :if(CountKeyCycle>=50)
//if countkeycycle>=49, it in longkey mode
if(FlagSynchronous==0)
{
FlagSynchronous=1;
CountLongKey=0;
}//synchronous longkeycs,when second or above in
if(LongKeyCs==1)//longkey counter?
{
LongKeyCs=0;
KeyDecreaseIncreaseFunc();
}
}
if((countHour==0)&(countMin==0))//judge if yuyuedingshi time setup=0 or not
{
FlagYuYueDingShiTimeVaid=0;
}
else
{
FlagYuYueDingShiTimeVaid=1;
}
}
if(((KeyValue==Key_Decrease)||(KeyValue==Key_Increase))
&((FlagFunc_ShaoKao)||(FlagFunc_HuoGuo)||(FlagFunc_JianChao))
&((FlagSetOver_SetupYuYueDingShi)||(FlagFunc_YuYueDingShi==0))&(FlagSeriousError==0))//auto func increase and decrease
{
if(KeyValue==Key_Decrease)
{
if(Power.ubyte!=0x01)
{
TempPower=Power.ubyte;//for option so add it
Power.ubyte=TempPower>>1;
}
}
else if(KeyValue==Key_Increase)
{
if(Power.ubyte!=0x80)
{
TempPower=Power.ubyte;
Power.ubyte=TempPower<<1;
}
}
PowerSerialSearch();
buzzer_on_flag=1;
Flag5sTwinkle=1;
count_5s=0;
KeyAnswer=1;//key has been respond
}
//end YuYue Func//
return;
}
}
else//
{
//valid key, then initial
//clear flagkeybuf
KeyBuf=KeyValue;
KeyAnswer=0;//clear key running flag
CountKeyCycle=0;
CountLongKey=0;
FlagDisableTwinkle_SetupYuYueDingShi=0;//clear flag
//count_500ms=0;//clear for release longkey display normally
}
}
else
{
//valid key,then initial
//clear flagkeybuf
KeyBuf=KeyValue;
KeyAnswer=0;//clear key running flag
CountKeyCycle=0;
CountLongKey=0;
FlagDisableTwinkle_SetupYuYueDingShi=0;
//count_500ms=0;//clear for release longkey display normally
}
}
#endif
}
void start(void)
{
if(Initial1s==0)//only run once for initial
{
buzzer_on_flag=1;
count_1s=0;
Initial1s=1;
}
if(Initial1s==1)//only run 1s
{
if(Flag1sStart==0)
{
Disp[0]=0x00;//light all led
Disp[1]=0x00;
Disp[2]=0x00;
Disp[3]=0x00;
Disp[4]=0xff;
Disp[5]=0xff;
}
else
{
Disp[0]=LEDDisp[10];//display "-"
Disp[1]=LEDDisp[10];
Disp[2]=LEDDisp[10];
Disp[3]=LEDDisp[10];
Disp[4]=0x00;//group led off
Disp[5]=0x00;
Initial1s=2;//jump display
}
}
if(FlagFuncEnable==0)
{
if((StatusRun==1))//run but all func are closed
{
FAN=1;//start fun function
if(Flag40s==0)
{
if(Flag500msTwinkle==0)
{
Disp[0]=0xff;//turn off all led
Disp[1]=0xff;
Disp[2]=0xff;
Disp[3]=0xff;
Disp[4]=0x00;//group led off
Disp[5]=LEDDisp[15];//light power led
}
else
{
Disp[0]=LEDDisp[10];//display "-"
Disp[1]=LEDDisp[10];
Disp[2]=LEDDisp[10];
Disp[3]=LEDDisp[10];
Disp[4]=0x00;//group led off
Disp[5]=LEDDisp[15];//light power led
}
}
else
{
Disp[0]=LEDDisp[10];//display "-"
Disp[1]=LEDDisp[10];
Disp[2]=LEDDisp[10];
Disp[3]=LEDDisp[10];
Disp[4]=0x00;//group led off
Disp[5]=0x00;
}
if(Flag1Min==1)
{
//no key
FAN=0;//close fan function
if(KeyValue==0xff)
{
StatusRun=0;//has been closed at 40s
Flag40s=0;
Flag1Min=0;
Disp[0]=LEDDisp[10];//display "-"
Disp[1]=LEDDisp[10];
Disp[2]=LEDDisp[10];
Disp[3]=LEDDisp[10];
Disp[4]=0x00;//group led off
Disp[5]=0x00;
}
}
}
else
{//when press power off delay 1min to poweroff fan
if(Flag1Min==1)
{
FAN=0;
StatusRun=0;
Flag40s=0;
Flag1Min=0;
}
}
}
}
/*************************************************************************
Name : pan check
Parameters : None
Returns : None
Description: pan check function
**************************************************************************/
void CheckPan(void)
{
zpage char i;
zpage int j;
if(FlagFun_CheckPan==1)
{
{
if(InitialCheckPan==0)//check pan
{
CountTiguo=0;//clear for tiguo when evry decet pan 2007.4.6
InitialCheckPan=1;
counterInt_pan_check=0;
CCRP = 0x01; /* Selecte Latch 01 */
CRAL = CMP01_L_800W; /* Write low-order of compare 01 */
CRAH = CMP01_H_800W; /* Write high-order of compare 01 */
CMPR = 0x01; /* Compare latch 00,01 reload at next underflow */
disable_interrupt();
PAN=0;
P0D.0=1;//output
K=1;//9us enable
for(i=0;i<2;i++)//for k
{
nop_instruction();
}
nop_instruction();
nop_instruction();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -