/******************************************************************************************* * UI_DoorProcess *input parameters: * gbDoorTemp *output parameters: * TBD *Function: * key debounce *******************************************************************************************/ #define DOOROPEN_DEBOUNCE_TIMER 30 //door open debounce #define DOORCLOSE_DEBOUNCE_TIMER 250 //door close debounce
void UI_DoorProcess(void) { static bit bdata debounce; //registers used to debounce static Byte idata debounceTimer; static bit bdata doorState; if(_testbit_(gbFlag1ms_1)) { //1> judge key state change ---------------------------------------------------------------- if( doorState != gbDoorTemp ) { //2> begin to bebounce if key state change ------------------------------------------------- doorState = gbDoorTemp; if(gbDoorTemp) { debounceTimer = DOOROPEN_DEBOUNCE_TIMER; } else { debounceTimer = DOORCLOSE_DEBOUNCE_TIMER; } debounce = 1; } //3> finish debounce if door state keep unchanged during the debounce period---------------- if(debounce) { if(!(--debounceTimer)) { gbDoorValue = doorState; //save door value if(gbDoorValue) { ExecuteDoorOpenFunc(); } else { ExecuteDoorCloseFunc(); } debounce = 0; } } } }
/******************************************************************************************* * UI_LEDDisplay * * --------- --------- --------- --------- * | | | | | | | | * |_______| |_______| DP1 |_______| |_______| CLOCK Arrow 1~37 * | | | | | | | | * | | | | DP2 | | | | KG * --------- --------- --------- --------- * 7segDigit1 7segDigit2 7segDigit3 7segDigit4 * *input parameters: * gBDigitSegPart1 -- 7SegDigit1 and DP1 * gBDigitSegPart2 -- 7SegDigit2 and DP2 * gBDigitSegPart3 -- 7SegDigit3 and DP3(CLOCK icon) * gBDigitSegPart4 -- 7SegDigit4 and DP4(KG icon) * gBArrowSegPart1 -- Arrow 1~6 * gBArrowSegPart2 -- Arrow 7~12 * gBArrowSegPart3 -- Arrow 13~18 * gBArrowSegPart4 -- Arrow 19~24 * gWArrowSegPart5 -- Arrow 25~37 *output parameters: * gBKeyTemp[0~3] *Function: * LED display and keyline scan *******************************************************************************************/ void UI_LEDDisplay(void) { static Byte comLoop; if(_testbit_(gbFlag2ms_0)) { COM1_PIN = 1; //display nothing COM2_PIN = 1; COM3_PIN = 1; COM4_PIN = 1; COM5_PIN = 1; switch(comLoop) { //1> scan key and door,then prepare content for display------------------------------------- case 0: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~KeyIn pins input pull high KEYIN_PINS_CFG = Bin(00000000); KEYIN_PINS_PULL = Bin(11111111); KEYIN_PINS = Bin(11111111); KEYOUT1_PIN = 1; KEYOUT2_PIN = 1; KEYOUT3_PIN = 1; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scan key line4 KEYOUT4_PIN = 0; Delay(); gBKeyTemp[0] = ~KEYIN_PINS; gBKeyTemp[0] &= Bin(01111111); Delay(); KEYOUT4_PIN = 1; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scan key line3 KEYOUT3_PIN = 0; Delay(); gBKeyTemp[1] = ~KEYIN_PINS; gBKeyTemp[1] &= Bin(01111111); Delay(); KEYOUT3_PIN = 1; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scan key line2 KEYOUT2_PIN = 0; Delay(); gBKeyTemp[2] = ~KEYIN_PINS; gBKeyTemp[2] &= Bin(01111111); Delay(); KEYOUT2_PIN = 1; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scan key line1 KEYOUT1_PIN = 0; Delay(); gBKeyTemp[3] = ~KEYIN_PINS; gBKeyTemp[3] &= Bin(01111111); Delay(); KEYOUT1_PIN = 1; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scan door if( KEYIN_PINS & Bin(10000000) ) { gbDoorTemp = 1; } else { gbDoorTemp = 0; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~restart next LED display loop SEG_PINS_CFG = Bin(11111111); SEG_PINS_PULL = Bin(00000000); SEG_PINS = Bin(11111111); SetLED(); comLoop++; break; //2> show content of COM1------------------------------------------------------------------- case 1: SEG_PINS = gBDigitSegPart1; Write74164(gBArrowSegPart1); COM1_PIN = 0; comLoop++; break; //3> show content of COM2------------------------------------------------------------------- case 2: SEG_PINS = gBDigitSegPart2; Write74164(gBArrowSegPart2); COM2_PIN = 0; comLoop++; break; //4> show content of COM3------------------------------------------------------------------- case 3: SEG_PINS = gBDigitSegPart3; Write74164(gBArrowSegPart3); COM3_PIN = 0; comLoop++; break; //5> show content of COM4------------------------------------------------------------------- case 4: SEG_PINS = gBDigitSegPart4; Write74164(gBArrowSegPart4); COM4_PIN = 0; comLoop++; break; //6> show content of COM5------------------------------------------------------------------- default: SEG_PINS = LOBYTE(gWArrowSegPart5); Write74164(HIBYTE(gWArrowSegPart5)); COM5_PIN = 0; comLoop=0; break; } } } /********************************************************************************************** * Single Key Press interface * * Function Description: * Input parameter : * Output paramter : * remarks : **********************************************************************************************/
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~00 P2.3 - P1.0 //N/C static bit Key00_PressDown(void) { return 0; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~01 P2.3 - P1.1 //A-05 Corn static bit Key01_PressDown(void) { return ExecuteCookMemuKeyFunc(0,A05_START,A05_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~02 P2.3 - P1.2 //A-09 MeatBone static bit Key02_PressDown(void) { return ExecuteCookMemuKeyFunc(0,A09_START,A09_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~03 P2.3 - P1.3 //A-10 Wings static bit Key03_PressDown(void) { return ExecuteCookMemuKeyFunc(0,A10_START,A10_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~04 P2.3 - P1.4 //A-08 Bread static bit Key04_PressDown(void) { return ExecuteCookMemuKeyFunc(0,A08_START,A08_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~05 P2.3 - P1.5 //A-07 Milk/Coffee static bit Key05_PressDown(void) { return ExecuteCookMemuKeyFunc(0,A07_START,A07_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~06 P2.3 - P1.6 //A-06 DeepFrezee static bit Key06_PressDown(void) { return ExecuteCookMemuKeyFunc(0,A06_START,A06_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~07 P2.2 - P1.0 //A-04 egg static bit Key07_PressDown(void) { return ExecuteCookMemuKeyFunc(0,A04_START,A04_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~08 P2.2 - P1.1 //A-03 shrump static bit Key08_PressDown(void) { return ExecuteCookMemuKeyFunc(0,A03_START,A03_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~09 P2.2 - P1.2 //A-02 Ribs static bit Key09_PressDown(void) { return ExecuteCookMemuKeyFunc(0,A02_START,A02_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~10 P2.2 - P1.3 //A-01 fish static bit Key10_PressDown(void) { return ExecuteCookMemuKeyFunc(0,A01_START,A01_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~11 P2.2 - P1.4 //SC-6 noddle static bit Key11_PressDown(void) { return ExecuteCookMemuKeyFunc(0,SC6_START,SC6_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~12 P2.2 - P1.5 //SC-5 Dumpling static bit Key12_PressDown(void) { return ExecuteCookMemuKeyFunc(0,SC5_START,SC5_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~13 P2.2 - P1.6 //SC-4 beancurd static bit Key13_PressDown(void) { return ExecuteCookMemuKeyFunc(0,SC4_START,SC4_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~14 P2.1 - P1.0 //odor static bit Key14_PressDown(void) { return ExecuteCookMemuKeyFunc(0,ODOR_START,ODOR_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~15 P2.1 - P1.1 //SC-3 Meat static bit Key15_PressDown(void) { return ExecuteCookMemuKeyFunc(0,SC3_START,SC3_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~16 P2.1 - P1.2 //SC-2 Vegetable static bit Key16_PressDown(void) { return ExecuteCookMemuKeyFunc(0,SC2_START,SC2_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~17 P2.1 - P1.3 //SC-1 Rice static bit Key17_PressDown(void) { return ExecuteCookMemuKeyFunc(0,SC1_START,SC1_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~18 P2.1 - P1.4 //10SEC static bit Key18_PressDown(void) { return ExecuteTimeMemuKeyFunc(TENS_DIGIT,10); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~19 P2.1 - P1.5 //1MIN static bit Key19_PressDown(void) { return ExecuteTimeMemuKeyFunc(SINGLE_DIGIT,60); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~20 P2.1 - P1.6 //10MIN static bit Key20_PressDown(void) { return ExecuteTimeMemuKeyFunc(TENS_DIGIT,600); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~21 P2.0 - P1.0 //Pause/Cancel/Saving static bit Key21_PressDown(void) { return ExecuteCancelKeyFunc(); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~22 P2.0 - P1.1 //Start/+30s static bit Key22_PressDown(void) { return ExecuteStartKeyFunc(); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~23 P2.0 - P1.2 //Clock/Preset static bit Key23_PressDown(void) { return ExecuteClockKeyFunc(); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~24 P2.0 - P1.3 //Defrost static bit Key24_PressDown(void) { return ExecuteDefrostMemuKeyFunc(); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~25 P2.0 - P1.4 //Lightwave static bit Key25_PressDown(void) { return ExecuteCookMemuKeyFunc(1,GRILL_START,GRILL_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~26 P2.0 - P1.5 //Baby static bit Key26_PressDown(void) { return ExecuteCookMemuKeyFunc(0,BABY_START,BABY_END); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~27 P2.0 - P1.6 //Microwave static bit Key27_PressDown(void) { gbPowerCheckReq = 1; return ExecuteCookMemuKeyFunc(1,MICRO_START,MICRO_END); }
KeyCommand code KeyCommandUnit[28] = { { &Key00_PressDown}, { &Key01_PressDown}, { &Key02_PressDown}, { &Key03_PressDown}, { &Key04_PressDown}, { &Key05_PressDown}, { &Key06_PressDown}, { &Key07_PressDown}, { &Key08_PressDown}, { &Key09_PressDown}, { &Key10_PressDown}, { &Key11_PressDown}, { &Key12_PressDown}, { &Key13_PressDown}, { &Key14_PressDown}, { &Key15_PressDown}, { &Key16_PressDown}, { &Key17_PressDown}, { &Key18_PressDown}, { &Key19_PressDown}, { &Key20_PressDown}, { &Key21_PressDown}, { &Key22_PressDown}, { &Key23_PressDown}, { &Key24_PressDown}, { &Key25_PressDown}, { &Key26_PressDown}, { &Key27_PressDown}, }; /******************************************************************************************* * UI_KeyProcess *input parameters: * gBKeyTemp[0~3] *output parameters: * TBD *Function: * key debounce *******************************************************************************************/ #define KEY_DEBOUNCE_TIMER 32 //key debounce 32ms void UI_KeyProcess(void) { Byte data i,j; Byte data keyBuf; //registers used to judge how many key pressed Byte data keyCount; Byte data keyIndex;
bit bdata FgNeedToBuzz; //flag will mark if key take effect
static bit bdata debounce; //registers used to debounce static Byte idata debounceTimer; static Byte idata keyState[4]; if(_testbit_(gbFlag1ms_2)) { //1> judge key state change ---------------------------------------------------------------- for(i=0;i<4;i++) { if(keyState != gBKeyTemp) { //2> begin to bebounce if key state change ------------------------------------------------- keyState = gBKeyTemp; debounceTimer = KEY_DEBOUNCE_TIMER; debounce = 1; } } //3> finish debounce if key state keep unchanged during the debounce period----------------- if(debounce) { if(!(--debounceTimer)) { debounce = 0; //4> judge how many key press and save the key value of the pressed key -------------------- for(i=0,keyIndex=0,keyCount=0;i<4;i++) { keyBuf = keyState; for(j=0;j<7;j++) //note:the key matrix is 4 by 7 { keyBuf>>=1; if(CY) { if(keyCount<3) //at most save 3 pressed key to prevent ghost key { gBKeyValue[keyCount] = keyIndex; } keyCount++; } keyIndex++; } } //5> process of all key release ------------------------------------------------------------ if(keyCount == 0) { if(_testbit_(gbCancelKeyEntry)) //cancle key: enter energy saver mode { gBOSMode = OS_ENERGY_SAVER; FgNeedToBuzz = 1; } gBKeyPressFlag = NO_KEY_PRESS; } //6> process of multi-key press ------------------------------------------------------------ else if(keyCount >1) { if(_testbit_(gbCancelKeyEntry)) //cancel+demo key: enter demo mode { if(keyCount ==2) { if(gBKeyValue[0]==KEY_PAUSE_CANCEL_SAVE) { if(gBKeyValue[1]==KEY_DEFROST) { if(ExecuteCancelPulsDefrostKeyFunc()) { gbBuzzToneReq = 1; gBBuzzToneType = BUZZ_DEMO; } } else if(gBKeyValue[1] == KEY_MICRO) { FgNeedToBuzz = ExecuteCancelPulsMicroKeyFunc(); } } } } gBKeyPressFlag = MULTI_KEY_PRESS; } //7> process of single-key press ------------------------------------------------------------ else { gbCancelKeyEntry = 0; if(gBKeyPressFlag == NO_KEY_PRESS ) { //execute single key press function FgNeedToBuzz=(*KeyCommandUnit[gBKeyValue][0]].KeyCommandProPtr)(); gBKeyPressFlag = VALID_KEY_PRESS; } else { gBKeyPressFlag = INVALID_KEY_PRESS; } } //8> buzz if key take effect ---------------------------------------------------------------- if(_testbit_(FgNeedToBuzz)) { gbCfgModifyReq = 1; gbBuzzToneReq = 1; gBBuzzToneType = BUZZ_KEYPRESS; } //9> reset door open 10min if any key press-------------------------------------------------- gbDoorOpen10minResetReq = 1; } } } } |