homework 7

Dependencies:   mbed-rtos mbed C12832_lcd LM75B

Committer:
gatedClock
Date:
Wed Sep 11 23:00:14 2013 +0000
Revision:
71:4a5f256ecf7c
Parent:
70:7c0743c28b11
Child:
72:b4d0c0aa3c26
rewrite tickCookRemainingTime.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gatedClock 0:fcca4db7b32a 1 /*----------------------------------------------//------------------------------
gatedClock 0:fcca4db7b32a 2 student : m-moore
gatedClock 0:fcca4db7b32a 3 class : rtos
gatedClock 10:2b0a9fc39109 4 directory : RTOS_HW_07
gatedClock 0:fcca4db7b32a 5 file : main.cpp
gatedClock 0:fcca4db7b32a 6 ----description---------------------------------//------------------------------
gatedClock 70:7c0743c28b11 7 gotchyas
gatedClock 70:7c0743c28b11 8 1. using pc.printf inside a ticker routine will freeze the routine.
gatedClock 71:4a5f256ecf7c 9 2. using queues (get, put) will not work within a ticker routine.
gatedClock 0:fcca4db7b32a 10 -----includes-----------------------------------//----------------------------*/
gatedClock 0:fcca4db7b32a 11 #include "mbed.h" // mbed class.
gatedClock 10:2b0a9fc39109 12 #include "rtos.h" // rtos class.
gatedClock 39:4e7e4d935a87 13 #include "LM75B.h" // thermometer class.
gatedClock 10:2b0a9fc39109 14 #include "C12832_lcd.h" // LCD class.
gatedClock 0:fcca4db7b32a 15 //---defines------------------------------------//------------------------------
gatedClock 9:cfdb9aa5857c 16 #define LCD1 lcd.locate(0, 0); // LCD line 1.
gatedClock 9:cfdb9aa5857c 17 #define LCD2 lcd.locate(0,11); // LCD line 2.
gatedClock 9:cfdb9aa5857c 18 #define LCD3 lcd.locate(0,22); // LCD line 3.
gatedClock 9:cfdb9aa5857c 19
gatedClock 10:2b0a9fc39109 20
gatedClock 66:4a0006fa5cc1 21 #define DEBOUNCEmS 16 // debounce wait in mS.
gatedClock 19:92b11e30aaaf 22 #define uS_TIMEOUT 100 // Timer uS timeout.
gatedClock 19:92b11e30aaaf 23 #define LBSIG 1 // left button signal code.
gatedClock 33:34c1bef3c4ff 24 #define PIPEuS 1000 // pipeline clock period.
gatedClock 19:92b11e30aaaf 25 #define SLOWCLOCKuS 500000 // slow-clock period.
gatedClock 39:4e7e4d935a87 26 #define TEMPCLOCKS 1 // temperature-measuring period in S.
gatedClock 26:bff592483cb1 27 #define PIPEDATASIZE 8 // dimension of tPipeData.
gatedClock 44:d16e813e61ef 28 #define THREAD_1_WAITmS 400 // thread 1 wait in mS.
gatedClock 67:1d9c85a4c3c1 29 #define THREAD_2_WAITmS 20 // LCD thread wait.
gatedClock 67:1d9c85a4c3c1 30 #define THREAD_3_WAITmS 80 // thread 3 wait in mS.
gatedClock 66:4a0006fa5cc1 31 #define THREAD_4_WAITmS 1 // thread 4 wait in mS.
gatedClock 57:0432c68ad232 32 #define THREAD_5_WAITmS 400 // thread 5 wait in mS.
gatedClock 44:d16e813e61ef 33 #define HB_MODULO 1024 // heartbeat modulo divisor.
gatedClock 50:2928c3cbdcc3 34
gatedClock 54:b0e7352d2516 35 #define MSG_INC_TIME 0x01
gatedClock 54:b0e7352d2516 36 #define MSG_DEC_TIME 0x02
gatedClock 58:ec630b6dd9b1 37 #define MSG_START 0x04
gatedClock 58:ec630b6dd9b1 38 #define MSG_STOP 0x08
gatedClock 58:ec630b6dd9b1 39 #define MSG_OPEN 0x10
gatedClock 58:ec630b6dd9b1 40 #define MSG_CLOSED 0x20
gatedClock 57:0432c68ad232 41
gatedClock 57:0432c68ad232 42 #define FSM_IDLE 0x00 // cook-state state-machine.
gatedClock 57:0432c68ad232 43 #define FSM_COOK 0x01 // cook-state state-machine.
gatedClock 57:0432c68ad232 44 #define FSM_PAUSE 0x02 // cook-state state-machine.
gatedClock 57:0432c68ad232 45 #define FSM_DONE 0x04 // cook-state state-machine.
gatedClock 65:e39360da5929 46
gatedClock 71:4a5f256ecf7c 47 #define RT_PRELOAD 0x01 // remaining-time preload.
gatedClock 71:4a5f256ecf7c 48 #define RT_DECREMENT 0x02 // remaining-time decrement.
gatedClock 71:4a5f256ecf7c 49 #define RT_PAUSE 0x03 // remaining-time don't change.
gatedClock 71:4a5f256ecf7c 50 #define RT_CLEAR 0x04 // remaining-time set to zero.
gatedClock 71:4a5f256ecf7c 51
gatedClock 65:e39360da5929 52 #define DEBUG1 // debug preprocessor control.
gatedClock 0:fcca4db7b32a 53 //--global_definitions--------------------------//------------------------------
gatedClock 26:bff592483cb1 54 struct tButtons // button ISR updates.
gatedClock 26:bff592483cb1 55 {
gatedClock 26:bff592483cb1 56 char cLeftButton; // cooktime +60S.
gatedClock 26:bff592483cb1 57 char cRightButton; // cooktime -60S.
gatedClock 26:bff592483cb1 58 char cTopButton; // start cook.
gatedClock 26:bff592483cb1 59 char cBottomButton; // stop cook.
gatedClock 58:ec630b6dd9b1 60 char cCenterButton; // center button pressed.
gatedClock 53:8c2baf5623c8 61 char cDoorOpen; // door open.
gatedClock 26:bff592483cb1 62 };
gatedClock 34:b449d2a7c786 63
gatedClock 71:4a5f256ecf7c 64 struct tRemainingTime // remaining time related.
gatedClock 71:4a5f256ecf7c 65 {
gatedClock 71:4a5f256ecf7c 66 char cControl; // countdown control.
gatedClock 71:4a5f256ecf7c 67 int dTotalTime; // initialize to this.
gatedClock 71:4a5f256ecf7c 68 int dRemainingTime; // the countdown value.
gatedClock 71:4a5f256ecf7c 69 };
gatedClock 71:4a5f256ecf7c 70
gatedClock 61:8026a9fc0cf1 71 Queue<int, 1> queueModTotalTime; // message to modify total time.
gatedClock 61:8026a9fc0cf1 72 Queue<int, 1> queueUpdateFSM; // message to inform FSM.
gatedClock 61:8026a9fc0cf1 73 Queue<int, 1> queueUpdateRemainingTime; // message to update remaining time.
gatedClock 71:4a5f256ecf7c 74 Queue<int, 1> queueSetRemainingTime; // tell countdown it's start time.
gatedClock 69:55b836e8ced7 75 Queue<int, 1> queueFSMnewState; // latest FSM state.
gatedClock 0:fcca4db7b32a 76 //--global_variables----------------------------//------------------------------
gatedClock 26:bff592483cb1 77 char gcSignalWaitEnable; // 1 to wait on a signal.
gatedClock 26:bff592483cb1 78 char gcSlowClock; // slow-clock signal.
gatedClock 33:34c1bef3c4ff 79 char gcInitializePipeline; // 1 to initialize pipeline state.
gatedClock 39:4e7e4d935a87 80 float gfCelsius; // from thermometer.
gatedClock 42:266d5bbbfd19 81 float gfLCDcelsius; // feed into LCD.
gatedClock 42:266d5bbbfd19 82 int gdLCDtotalCookTimeSec; // feed into LCD.
gatedClock 42:266d5bbbfd19 83 int gdCookTimeRemainingSec; // feed into LCD.
gatedClock 26:bff592483cb1 84 tButtons gtButtons; // ISR button updates.
gatedClock 70:7c0743c28b11 85
gatedClock 71:4a5f256ecf7c 86 tRemainingTime giRemainingTime; // structure instance.
gatedClock 71:4a5f256ecf7c 87
gatedClock 70:7c0743c28b11 88 int gdDiagTotalTime;
gatedClock 0:fcca4db7b32a 89 //--global_instances----------------------------//------------------------------
gatedClock 55:17f3354da63a 90 Serial pc(USBTX, USBRX); // PuTTY terminal communication.
gatedClock 39:4e7e4d935a87 91 LM75B temperature(p28,p27); // on-board thermometer.
gatedClock 9:cfdb9aa5857c 92 C12832_LCD lcd; // LCD object.
gatedClock 53:8c2baf5623c8 93 DigitalOut led0(LED4); // magnetron.
gatedClock 39:4e7e4d935a87 94 DigitalOut led1(LED3);
gatedClock 39:4e7e4d935a87 95 DigitalOut led2(LED2);
gatedClock 39:4e7e4d935a87 96 DigitalOut led3(LED1);
gatedClock 0:fcca4db7b32a 97
gatedClock 0:fcca4db7b32a 98 InterruptIn iJoyStickUp (p15); // joystick up rising edge.
gatedClock 0:fcca4db7b32a 99 InterruptIn iJoyStickDown (p12); // joystick down rising edge.
gatedClock 0:fcca4db7b32a 100 InterruptIn iJoyStickLeft (p13); // joystick left rising edge.
gatedClock 0:fcca4db7b32a 101 InterruptIn iJoyStickRight (p16); // joystick right rising edge.
gatedClock 0:fcca4db7b32a 102 InterruptIn iJoyStickCenter(p14); // 1 if joystick middle pressed.
gatedClock 66:4a0006fa5cc1 103
gatedClock 66:4a0006fa5cc1 104 Timer debounceTimer; // button debounce timer.
gatedClock 0:fcca4db7b32a 105
gatedClock 50:2928c3cbdcc3 106 Ticker tickerButtonStateManager; // manage the button states.
gatedClock 19:92b11e30aaaf 107 Ticker tickerSlowClock; // generate a ~1Hz clock.
gatedClock 64:255295f1d782 108 Ticker tickerCookCountdown; // remaining cook time.
gatedClock 63:63f362bcc2ac 109
gatedClock 63:63f362bcc2ac 110 // Timer timerFSMdone; // duration of FSM 'done' state.
gatedClock 40:7afff79f0d8b 111
gatedClock 0:fcca4db7b32a 112 //-------prototypes-----------------------------//------------------------------
gatedClock 49:56f790977983 113
gatedClock 19:92b11e30aaaf 114 void slowClock(); // 1Hz or thereabouts.
gatedClock 49:56f790977983 115
gatedClock 9:cfdb9aa5857c 116 void initialization(); // initialize settings.
gatedClock 13:21f27ba467c2 117
gatedClock 13:21f27ba467c2 118 void ISRleftButtonRising(); // cook-time increase.
gatedClock 13:21f27ba467c2 119 void ISRleftButtonFalling(); // button-release debounce.
gatedClock 13:21f27ba467c2 120 void ISRrightButtonRising(); // cook-time decrease.
gatedClock 13:21f27ba467c2 121 void ISRrightButtonFalling(); // button-release debounce.
gatedClock 13:21f27ba467c2 122 void ISRtopButtonRising(); // cook start.
gatedClock 13:21f27ba467c2 123 void ISRtopButtonFalling(); // button-release debounce.
gatedClock 13:21f27ba467c2 124 void ISRbottomButtonRising(); // cook stop.
gatedClock 13:21f27ba467c2 125 void ISRbottomButtonFalling(); // button-release debounce.
gatedClock 13:21f27ba467c2 126 void ISRcenterButtonRising(); // door state toggle.
gatedClock 13:21f27ba467c2 127 void ISRcenterButtonFalling(); // button-release debounce.
gatedClock 16:db7f0b3b2605 128 void disableSignalWaiting(); // break from signal waiting.
gatedClock 39:4e7e4d935a87 129
gatedClock 54:b0e7352d2516 130 void threadButtonStateManager(void const *args);
gatedClock 50:2928c3cbdcc3 131 void threadTotalTimeControl(void const *args);
gatedClock 57:0432c68ad232 132 void threadCookStateFSM(void const *args);
gatedClock 71:4a5f256ecf7c 133 void tickCookRemainingTime(); // remaining time countdown.
gatedClock 50:2928c3cbdcc3 134
gatedClock 40:7afff79f0d8b 135 void temperatureThread(void const *args); // temperature measurement.
gatedClock 42:266d5bbbfd19 136 void LCDthread (void const *args); // LCD display thread.
gatedClock 0:fcca4db7b32a 137 //==============================================//==============================
gatedClock 0:fcca4db7b32a 138 int main(void)
gatedClock 0:fcca4db7b32a 139 {
gatedClock 16:db7f0b3b2605 140 char cLeftButtonState; // 1 means button was pressed.
gatedClock 16:db7f0b3b2605 141
gatedClock 16:db7f0b3b2605 142
gatedClock 16:db7f0b3b2605 143
gatedClock 14:d3bb343cd5b2 144 iJoyStickLeft.rise (&ISRleftButtonRising);
gatedClock 14:d3bb343cd5b2 145 iJoyStickLeft.fall (&ISRleftButtonFalling);
gatedClock 9:cfdb9aa5857c 146
gatedClock 14:d3bb343cd5b2 147 iJoyStickRight.rise(&ISRrightButtonRising);
gatedClock 14:d3bb343cd5b2 148 iJoyStickRight.fall(&ISRrightButtonFalling);
gatedClock 14:d3bb343cd5b2 149
gatedClock 14:d3bb343cd5b2 150 iJoyStickUp.rise (&ISRtopButtonRising);
gatedClock 14:d3bb343cd5b2 151 iJoyStickUp.fall (&ISRtopButtonFalling);
gatedClock 9:cfdb9aa5857c 152
gatedClock 14:d3bb343cd5b2 153 iJoyStickDown.rise (&ISRbottomButtonRising);
gatedClock 14:d3bb343cd5b2 154 iJoyStickDown.fall (&ISRbottomButtonFalling);
gatedClock 7:9fbd1d540863 155
gatedClock 14:d3bb343cd5b2 156 iJoyStickCenter.rise(&ISRcenterButtonRising);
gatedClock 14:d3bb343cd5b2 157 iJoyStickCenter.fall(&ISRcenterButtonFalling);
gatedClock 9:cfdb9aa5857c 158
gatedClock 66:4a0006fa5cc1 159 debounceTimer.start(); // kick-off debounce timer.
gatedClock 66:4a0006fa5cc1 160
gatedClock 33:34c1bef3c4ff 161 gcInitializePipeline = 1; // tell pipeline to initialize.
gatedClock 16:db7f0b3b2605 162
gatedClock 9:cfdb9aa5857c 163 initialization(); // initialize variables.
gatedClock 21:b794d189c36b 164 gcSlowClock = 0;
gatedClock 44:d16e813e61ef 165 led1 = 0;
gatedClock 53:8c2baf5623c8 166 gtButtons.cDoorOpen = 0; // initialize with door closed.
gatedClock 63:63f362bcc2ac 167
gatedClock 63:63f362bcc2ac 168 // timerFSMdone.start(); // start 'done' timer.
gatedClock 49:56f790977983 169
gatedClock 70:7c0743c28b11 170 tickerSlowClock.attach_us(&slowClock ,SLOWCLOCKuS);
gatedClock 64:255295f1d782 171
gatedClock 64:255295f1d782 172 // count-down by one second.
gatedClock 69:55b836e8ced7 173 pc.printf("\n\r starting cookRemainingTime");
gatedClock 71:4a5f256ecf7c 174 tickerCookCountdown.attach(&tickCookRemainingTime,1);
gatedClock 54:b0e7352d2516 175
gatedClock 40:7afff79f0d8b 176
gatedClock 70:7c0743c28b11 177 Thread thread_1(temperatureThread ,NULL,osPriorityIdle,DEFAULT_STACK_SIZE,NULL);
gatedClock 70:7c0743c28b11 178 Thread thread_2(LCDthread ,NULL,osPriorityIdle,DEFAULT_STACK_SIZE,NULL);
gatedClock 70:7c0743c28b11 179 Thread thread_3(threadTotalTimeControl ,NULL,osPriorityIdle,DEFAULT_STACK_SIZE,NULL);
gatedClock 70:7c0743c28b11 180 Thread thread_4(threadButtonStateManager,NULL,osPriorityIdle,DEFAULT_STACK_SIZE,NULL); // was osPriorityIdle
gatedClock 70:7c0743c28b11 181 Thread thread_5(threadCookStateFSM ,NULL,osPriorityIdle,DEFAULT_STACK_SIZE,NULL);
gatedClock 70:7c0743c28b11 182
gatedClock 66:4a0006fa5cc1 183 //Thread thread_4(threadButtonStateManager);
gatedClock 52:8ba6a0c91a89 184
gatedClock 40:7afff79f0d8b 185
gatedClock 59:5e45b5e4a874 186 // the message-receiving threads need 'else' for message-receive-timeout.
gatedClock 9:cfdb9aa5857c 187
gatedClock 14:d3bb343cd5b2 188 while(1)
gatedClock 0:fcca4db7b32a 189 {
gatedClock 70:7c0743c28b11 190 pc.printf("\n\r gdDiagTotalTime %d",gdDiagTotalTime);
gatedClock 70:7c0743c28b11 191
gatedClock 70:7c0743c28b11 192 Thread::wait(1000);
gatedClock 16:db7f0b3b2605 193
gatedClock 16:db7f0b3b2605 194
gatedClock 16:db7f0b3b2605 195
gatedClock 14:d3bb343cd5b2 196
gatedClock 0:fcca4db7b32a 197 }
gatedClock 19:92b11e30aaaf 198 }
gatedClock 19:92b11e30aaaf 199 /*----------------------------------------------//----------------------------*/
gatedClock 59:5e45b5e4a874 200
gatedClock 59:5e45b5e4a874 201 // this serves as the bottom-half for all of the button-press IRSs.
gatedClock 59:5e45b5e4a874 202 // it sends button-status messages to other threads, and it also
gatedClock 59:5e45b5e4a874 203 // clears the button-state globals to prepare them for the next
gatedClock 59:5e45b5e4a874 204 // button press.
gatedClock 59:5e45b5e4a874 205
gatedClock 59:5e45b5e4a874 206
gatedClock 54:b0e7352d2516 207 void threadButtonStateManager(void const *args)
gatedClock 50:2928c3cbdcc3 208 {
gatedClock 56:18cff6eb91db 209 int dMessage; // message.
gatedClock 50:2928c3cbdcc3 210
gatedClock 54:b0e7352d2516 211 while(1) // thread loop.
gatedClock 67:1d9c85a4c3c1 212 {
gatedClock 54:b0e7352d2516 213 //--- // TOTAL TIME CONTROL.
gatedClock 56:18cff6eb91db 214
gatedClock 56:18cff6eb91db 215 // encoded integers will be sent,
gatedClock 56:18cff6eb91db 216 // not pointers.
gatedClock 50:2928c3cbdcc3 217
gatedClock 50:2928c3cbdcc3 218 if (gtButtons.cLeftButton) // total time increment button.
gatedClock 50:2928c3cbdcc3 219 {
gatedClock 54:b0e7352d2516 220 dMessage = MSG_INC_TIME; // set message.
gatedClock 69:55b836e8ced7 221 queueModTotalTime.put((int *) dMessage,1);// pretend it's a pointer.
gatedClock 50:2928c3cbdcc3 222 gtButtons.cLeftButton = 0; // clear the button state.
gatedClock 67:1d9c85a4c3c1 223 // pc.printf("\n\r time increment button.");
gatedClock 50:2928c3cbdcc3 224 }
gatedClock 67:1d9c85a4c3c1 225
gatedClock 59:5e45b5e4a874 226 if (gtButtons.cRightButton) // total time decrement button.
gatedClock 50:2928c3cbdcc3 227 {
gatedClock 54:b0e7352d2516 228 dMessage = MSG_DEC_TIME; // set message.
gatedClock 69:55b836e8ced7 229 queueModTotalTime.put((int *) dMessage,1);// pretend it's a pointer.
gatedClock 50:2928c3cbdcc3 230 gtButtons.cRightButton = 0; // clear the button state.
gatedClock 67:1d9c85a4c3c1 231 // pc.printf("\n\r time decrement button.");
gatedClock 50:2928c3cbdcc3 232 }
gatedClock 67:1d9c85a4c3c1 233
gatedClock 59:5e45b5e4a874 234 //--- // COOK-STATE FSM.
gatedClock 59:5e45b5e4a874 235
gatedClock 59:5e45b5e4a874 236 if (gtButtons.cTopButton) // start-cook button.
gatedClock 58:ec630b6dd9b1 237 {
gatedClock 59:5e45b5e4a874 238 dMessage = MSG_START; // set message.
gatedClock 69:55b836e8ced7 239 queueUpdateFSM.put((int *) dMessage,1); // pretend it's a pointer.
gatedClock 59:5e45b5e4a874 240 gtButtons.cTopButton = 0; // clear the button state.
gatedClock 58:ec630b6dd9b1 241 }
gatedClock 67:1d9c85a4c3c1 242
gatedClock 59:5e45b5e4a874 243 if (gtButtons.cBottomButton) // stop-cook button.
gatedClock 58:ec630b6dd9b1 244 {
gatedClock 59:5e45b5e4a874 245 dMessage = MSG_STOP; // set message.
gatedClock 69:55b836e8ced7 246 queueUpdateFSM.put((int *) dMessage,1); // pretend it's a pointer.
gatedClock 59:5e45b5e4a874 247 gtButtons.cBottomButton = 0; // clear the button state.
gatedClock 58:ec630b6dd9b1 248 }
gatedClock 67:1d9c85a4c3c1 249
gatedClock 59:5e45b5e4a874 250 if (gtButtons.cCenterButton) // door-state-toggle.
gatedClock 58:ec630b6dd9b1 251 {
gatedClock 59:5e45b5e4a874 252 dMessage = gtButtons.cDoorOpen; // determined in ISR.
gatedClock 69:55b836e8ced7 253 queueUpdateFSM.put((int *) dMessage,1); // pretend it's a pointer.
gatedClock 59:5e45b5e4a874 254 gtButtons.cCenterButton = 0; // clear the button state.
gatedClock 58:ec630b6dd9b1 255 }
gatedClock 59:5e45b5e4a874 256 //---
gatedClock 58:ec630b6dd9b1 257
gatedClock 54:b0e7352d2516 258 Thread::wait(THREAD_4_WAITmS); // multitasking.
gatedClock 54:b0e7352d2516 259 } // thread loop.
gatedClock 54:b0e7352d2516 260 } // threadButtonStateManager.
gatedClock 50:2928c3cbdcc3 261 /*----------------------------------------------//----------------------------*/
gatedClock 51:e5ec74c49b01 262 // the incoming messages are mutually-exclusive.
gatedClock 51:e5ec74c49b01 263 // total time controller.
gatedClock 51:e5ec74c49b01 264 void threadTotalTimeControl(void const *args)
gatedClock 50:2928c3cbdcc3 265 {
gatedClock 51:e5ec74c49b01 266 static int dTotalTime = 0; // total time variable.
gatedClock 60:e10bf95bbc96 267 int dMessage; // message.
gatedClock 51:e5ec74c49b01 268 osEvent queueEvent; // queue event.
gatedClock 70:7c0743c28b11 269 int dRC;
gatedClock 50:2928c3cbdcc3 270
gatedClock 50:2928c3cbdcc3 271 while(1) // thread loop.
gatedClock 50:2928c3cbdcc3 272 {
gatedClock 50:2928c3cbdcc3 273
gatedClock 55:17f3354da63a 274 queueEvent = queueModTotalTime.get(1); // get message.
gatedClock 51:e5ec74c49b01 275 if (queueEvent.status == osEventMessage)
gatedClock 51:e5ec74c49b01 276 {
gatedClock 56:18cff6eb91db 277 dMessage = (int) queueEvent.value.p; // interpret as integer, not pointer.
gatedClock 54:b0e7352d2516 278
gatedClock 54:b0e7352d2516 279 // increment total time.
gatedClock 56:18cff6eb91db 280 if (dMessage == MSG_INC_TIME) dTotalTime += 60;
gatedClock 54:b0e7352d2516 281
gatedClock 54:b0e7352d2516 282 // decrement total time.
gatedClock 56:18cff6eb91db 283 if (dMessage == MSG_DEC_TIME) dTotalTime -= 60;
gatedClock 65:e39360da5929 284
gatedClock 65:e39360da5929 285 // saturations.
gatedClock 65:e39360da5929 286 if (dTotalTime > 180) dTotalTime = 180;
gatedClock 65:e39360da5929 287 if (dTotalTime < 0) dTotalTime = 0;
gatedClock 65:e39360da5929 288
gatedClock 70:7c0743c28b11 289 dRC = queueSetRemainingTime.put((int *) dTotalTime,1);
gatedClock 70:7c0743c28b11 290 pc.printf("\n\r just queueSetRemainingTime.put %d, dRC = %d",dTotalTime,dRC);
gatedClock 65:e39360da5929 291
gatedClock 65:e39360da5929 292
gatedClock 51:e5ec74c49b01 293 }
gatedClock 54:b0e7352d2516 294
gatedClock 65:e39360da5929 295
gatedClock 51:e5ec74c49b01 296
gatedClock 51:e5ec74c49b01 297 gdLCDtotalCookTimeSec = dTotalTime; // transmit to LCD.
gatedClock 61:8026a9fc0cf1 298
gatedClock 61:8026a9fc0cf1 299 // pretend it's a pointer.
gatedClock 61:8026a9fc0cf1 300 // queueUpdateTotalTime.put((int *) dTotalTime);
gatedClock 61:8026a9fc0cf1 301
gatedClock 61:8026a9fc0cf1 302
gatedClock 50:2928c3cbdcc3 303
gatedClock 50:2928c3cbdcc3 304 Thread::wait(THREAD_3_WAITmS); // multitasking.
gatedClock 50:2928c3cbdcc3 305 } // thread loop.
gatedClock 50:2928c3cbdcc3 306 } // threadTotalTimeControl.
gatedClock 33:34c1bef3c4ff 307 /*----------------------------------------------//----------------------------*/
gatedClock 60:e10bf95bbc96 308 /*
gatedClock 60:e10bf95bbc96 309 #define FSM_IDLE 0x00 // cook-state state-machine.
gatedClock 60:e10bf95bbc96 310 #define FSM_COOK 0x01 // cook-state state-machine.
gatedClock 60:e10bf95bbc96 311 #define FSM_PAUSE 0x02 // cook-state state-machine.
gatedClock 60:e10bf95bbc96 312 #define FSM_DONE 0x04 // cook-state state-machine.
gatedClock 62:48e7c196e2a5 313
gatedClock 62:48e7c196e2a5 314 #define MSG_START 0x04
gatedClock 62:48e7c196e2a5 315 #define MSG_STOP 0x08
gatedClock 62:48e7c196e2a5 316 #define MSG_OPEN 0x10
gatedClock 62:48e7c196e2a5 317 #define MSG_CLOSED 0x20
gatedClock 60:e10bf95bbc96 318 */
gatedClock 57:0432c68ad232 319 void threadCookStateFSM(void const *args) // cook-cycle FSM.
gatedClock 57:0432c68ad232 320 {
gatedClock 69:55b836e8ced7 321 static int dFSMstate = FSM_IDLE; // state of this FSM.
gatedClock 69:55b836e8ced7 322 static int dFSMstateLast = FSM_IDLE; // previous FSM state.
gatedClock 61:8026a9fc0cf1 323 static int dButtonState; // received button state.
gatedClock 61:8026a9fc0cf1 324 static int dRemainingTime; // received remaining time.
gatedClock 62:48e7c196e2a5 325
gatedClock 62:48e7c196e2a5 326 static int dButtonStart = 0;
gatedClock 62:48e7c196e2a5 327 static int dButtonStop = 0;
gatedClock 62:48e7c196e2a5 328 static int dDoorOpen = 0;
gatedClock 62:48e7c196e2a5 329 static int dTimeRemaining = 0;
gatedClock 62:48e7c196e2a5 330
gatedClock 63:63f362bcc2ac 331 osEvent queueEvent; // queue event.
gatedClock 63:63f362bcc2ac 332
gatedClock 57:0432c68ad232 333 while(1) // thread loop.
gatedClock 57:0432c68ad232 334 {
gatedClock 62:48e7c196e2a5 335
gatedClock 63:63f362bcc2ac 336 if (dFSMstate == FSM_IDLE) // idle state.
gatedClock 62:48e7c196e2a5 337 {
gatedClock 69:55b836e8ced7 338 // pc.printf("\n\r FSM_IDLE");
gatedClock 62:48e7c196e2a5 339 if (dButtonStart & !dDoorOpen & dTimeRemaining) dFSMstate = FSM_COOK;
gatedClock 62:48e7c196e2a5 340 }
gatedClock 62:48e7c196e2a5 341 else
gatedClock 63:63f362bcc2ac 342 if (dFSMstate == FSM_COOK) // cook state.
gatedClock 62:48e7c196e2a5 343 {
gatedClock 68:cbebcfc948aa 344 pc.printf("\n\r FSM_COOK");
gatedClock 68:cbebcfc948aa 345 if (dDoorOpen & dTimeRemaining) dFSMstate = FSM_PAUSE;
gatedClock 62:48e7c196e2a5 346 }
gatedClock 62:48e7c196e2a5 347 else
gatedClock 63:63f362bcc2ac 348 if (dFSMstate == FSM_PAUSE) // pause state.
gatedClock 62:48e7c196e2a5 349 {
gatedClock 68:cbebcfc948aa 350 pc.printf("\n\r FSM_PAUSE");
gatedClock 62:48e7c196e2a5 351 if (dButtonStart & !dDoorOpen & dTimeRemaining) dFSMstate = FSM_DONE;
gatedClock 62:48e7c196e2a5 352 if (dButtonStop) dFSMstate = FSM_COOK;
gatedClock 62:48e7c196e2a5 353 }
gatedClock 62:48e7c196e2a5 354 else
gatedClock 62:48e7c196e2a5 355 if (dFSMstate == FSM_DONE) // incomplete.
gatedClock 62:48e7c196e2a5 356 {
gatedClock 68:cbebcfc948aa 357 pc.printf("\n\r FSM_DONE");
gatedClock 63:63f362bcc2ac 358 // timerFSMdone.reset(); // reset the timer.
gatedClock 63:63f362bcc2ac 359 dFSMstate = FSM_IDLE; // end of beep.
gatedClock 62:48e7c196e2a5 360 }
gatedClock 62:48e7c196e2a5 361
gatedClock 69:55b836e8ced7 362
gatedClock 69:55b836e8ced7 363 if (dFSMstate != dFSMstateLast) // if just changed state.
gatedClock 69:55b836e8ced7 364 {
gatedClock 69:55b836e8ced7 365 // tell cookRemainingTime the new state.
gatedClock 69:55b836e8ced7 366 queueFSMnewState.put((int* )dFSMstate,1);
gatedClock 69:55b836e8ced7 367
gatedClock 69:55b836e8ced7 368
gatedClock 69:55b836e8ced7 369 }
gatedClock 62:48e7c196e2a5 370
gatedClock 63:63f362bcc2ac 371
gatedClock 60:e10bf95bbc96 372 queueEvent = queueUpdateFSM.get(1); // get message.
gatedClock 60:e10bf95bbc96 373 if (queueEvent.status == osEventMessage)// update state variable.
gatedClock 60:e10bf95bbc96 374 {
gatedClock 61:8026a9fc0cf1 375 // interpret as integer, not pointer.
gatedClock 61:8026a9fc0cf1 376 dButtonState = (int) queueEvent.value.p;
gatedClock 63:63f362bcc2ac 377
gatedClock 69:55b836e8ced7 378 pc.printf("\n dButtonState = %d",dButtonState);
gatedClock 69:55b836e8ced7 379
gatedClock 63:63f362bcc2ac 380 if (dButtonState == MSG_START)
gatedClock 63:63f362bcc2ac 381 {
gatedClock 69:55b836e8ced7 382 pc.printf("\n\r message start.");
gatedClock 63:63f362bcc2ac 383 dButtonStart = 1;
gatedClock 63:63f362bcc2ac 384 dButtonStop = 0;
gatedClock 63:63f362bcc2ac 385 }
gatedClock 63:63f362bcc2ac 386 if (dButtonState == MSG_STOP)
gatedClock 63:63f362bcc2ac 387 {
gatedClock 69:55b836e8ced7 388 pc.printf("\n\r message stop.");
gatedClock 63:63f362bcc2ac 389 dButtonStart = 0;
gatedClock 63:63f362bcc2ac 390 dButtonStop = 1;
gatedClock 63:63f362bcc2ac 391 }
gatedClock 63:63f362bcc2ac 392
gatedClock 63:63f362bcc2ac 393 if (dButtonState == MSG_OPEN)
gatedClock 63:63f362bcc2ac 394 {
gatedClock 69:55b836e8ced7 395 pc.printf("\n\r message open.");
gatedClock 63:63f362bcc2ac 396 dDoorOpen = 1;
gatedClock 63:63f362bcc2ac 397 }
gatedClock 63:63f362bcc2ac 398
gatedClock 63:63f362bcc2ac 399 if (dButtonState == MSG_CLOSED)
gatedClock 63:63f362bcc2ac 400 {
gatedClock 69:55b836e8ced7 401 pc.printf("\n\r message closed.");
gatedClock 63:63f362bcc2ac 402 dDoorOpen = 0;
gatedClock 63:63f362bcc2ac 403 }
gatedClock 63:63f362bcc2ac 404
gatedClock 61:8026a9fc0cf1 405 }
gatedClock 61:8026a9fc0cf1 406 // get message.
gatedClock 61:8026a9fc0cf1 407 queueEvent = queueUpdateRemainingTime.get(1);
gatedClock 61:8026a9fc0cf1 408 if (queueEvent.status == osEventMessage)// update state variable.
gatedClock 61:8026a9fc0cf1 409 {
gatedClock 70:7c0743c28b11 410 led3 = !led3;
gatedClock 61:8026a9fc0cf1 411 // interpret as integer, not pointer.
gatedClock 61:8026a9fc0cf1 412 dRemainingTime = (int) queueEvent.value.p;
gatedClock 69:55b836e8ced7 413
gatedClock 61:8026a9fc0cf1 414 }
gatedClock 60:e10bf95bbc96 415
gatedClock 60:e10bf95bbc96 416
gatedClock 61:8026a9fc0cf1 417
gatedClock 57:0432c68ad232 418
gatedClock 57:0432c68ad232 419
gatedClock 57:0432c68ad232 420
gatedClock 57:0432c68ad232 421
gatedClock 69:55b836e8ced7 422 dFSMstateLast = dFSMstate; // pipeline variable.
gatedClock 57:0432c68ad232 423 Thread::wait(THREAD_5_WAITmS); // multitasking.
gatedClock 57:0432c68ad232 424 } // thread loop.
gatedClock 57:0432c68ad232 425 } // threadCookStateFSM.
gatedClock 57:0432c68ad232 426 /*----------------------------------------------//----------------------------*/
gatedClock 19:92b11e30aaaf 427 void slowClock(void) // 1Hz or thereabouts.
gatedClock 19:92b11e30aaaf 428 {
gatedClock 24:d39516e077ea 429 gcSlowClock = !gcSlowClock; // toggle clock.
gatedClock 19:92b11e30aaaf 430 }
gatedClock 19:92b11e30aaaf 431 /*----------------------------------------------//----------------------------*/
gatedClock 0:fcca4db7b32a 432 void initialization(void) // program initializations.
gatedClock 0:fcca4db7b32a 433 {
gatedClock 16:db7f0b3b2605 434 gcSignalWaitEnable = 1;
gatedClock 0:fcca4db7b32a 435 }
gatedClock 0:fcca4db7b32a 436 /*----------------------------------------------//----------------------------*/
gatedClock 26:bff592483cb1 437 void ISRleftButtonRising(void) // cooktime plus 60s.
gatedClock 1:9188d4668a88 438 {
gatedClock 66:4a0006fa5cc1 439 if (debounceTimer.read_ms() > DEBOUNCEmS)
gatedClock 26:bff592483cb1 440 gtButtons.cLeftButton = 1; // detect left button.
gatedClock 9:cfdb9aa5857c 441
gatedClock 66:4a0006fa5cc1 442 debounceTimer.reset(); // begin debounce period.
gatedClock 11:9cae003da12b 443 }
gatedClock 1:9188d4668a88 444 /*----------------------------------------------//----------------------------*/
gatedClock 15:5eaa2ab1d00d 445 void ISRleftButtonFalling(void) // button-release debounce.
gatedClock 1:9188d4668a88 446 {
gatedClock 66:4a0006fa5cc1 447 debounceTimer.reset(); // begin debounce period.
gatedClock 11:9cae003da12b 448 }
gatedClock 2:665ffa57031f 449 /*----------------------------------------------//----------------------------*/
gatedClock 26:bff592483cb1 450 void ISRrightButtonRising(void) // cooktime -60s.
gatedClock 12:e40272e1fd8f 451 {
gatedClock 66:4a0006fa5cc1 452 if (debounceTimer.read_ms() > DEBOUNCEmS)
gatedClock 26:bff592483cb1 453 gtButtons.cRightButton = 1; // detect right button.
gatedClock 12:e40272e1fd8f 454
gatedClock 66:4a0006fa5cc1 455 debounceTimer.reset(); // begin debounce period.
gatedClock 12:e40272e1fd8f 456 }
gatedClock 12:e40272e1fd8f 457 /*----------------------------------------------//----------------------------*/
gatedClock 15:5eaa2ab1d00d 458 void ISRrightButtonFalling(void) // button-release debounce.
gatedClock 12:e40272e1fd8f 459 {
gatedClock 66:4a0006fa5cc1 460 debounceTimer.reset(); // begin debounce period.
gatedClock 12:e40272e1fd8f 461 }
gatedClock 12:e40272e1fd8f 462 /*----------------------------------------------//----------------------------*/
gatedClock 26:bff592483cb1 463 void ISRtopButtonRising(void) // cook start.
gatedClock 12:e40272e1fd8f 464 {
gatedClock 66:4a0006fa5cc1 465 if (debounceTimer.read_ms() > DEBOUNCEmS)
gatedClock 26:bff592483cb1 466 gtButtons.cTopButton = 1; // detect top button.
gatedClock 12:e40272e1fd8f 467
gatedClock 66:4a0006fa5cc1 468 debounceTimer.reset(); // begin debounce period.
gatedClock 12:e40272e1fd8f 469 }
gatedClock 12:e40272e1fd8f 470 /*----------------------------------------------//----------------------------*/
gatedClock 15:5eaa2ab1d00d 471 void ISRtopButtonFalling(void) // button-release debounce.
gatedClock 12:e40272e1fd8f 472 {
gatedClock 66:4a0006fa5cc1 473 debounceTimer.reset(); // begin debounce period.
gatedClock 12:e40272e1fd8f 474 }
gatedClock 12:e40272e1fd8f 475 /*----------------------------------------------//----------------------------*/
gatedClock 53:8c2baf5623c8 476 // front-end control of magnetron off.
gatedClock 53:8c2baf5623c8 477 // due to physical danger, the magnetron is turned off immediately
gatedClock 53:8c2baf5623c8 478 // upon off-button press, in the interrupt that it generates.
gatedClock 53:8c2baf5623c8 479
gatedClock 26:bff592483cb1 480 void ISRbottomButtonRising(void) // cook stop.
gatedClock 12:e40272e1fd8f 481 {
gatedClock 66:4a0006fa5cc1 482 if (debounceTimer.read_ms() > DEBOUNCEmS)
gatedClock 66:4a0006fa5cc1 483 {
gatedClock 66:4a0006fa5cc1 484 led0 = 0; // magnetron off.
gatedClock 66:4a0006fa5cc1 485 gtButtons.cBottomButton = 1; // detect bottom button.
gatedClock 66:4a0006fa5cc1 486 }
gatedClock 66:4a0006fa5cc1 487 debounceTimer.reset(); // begin debounce period.
gatedClock 66:4a0006fa5cc1 488 }
gatedClock 12:e40272e1fd8f 489 /*----------------------------------------------//----------------------------*/
gatedClock 15:5eaa2ab1d00d 490 void ISRbottomButtonFalling(void) // button-release debounce.
gatedClock 12:e40272e1fd8f 491 {
gatedClock 66:4a0006fa5cc1 492 debounceTimer.reset(); // begin debounce period.
gatedClock 12:e40272e1fd8f 493 }
gatedClock 12:e40272e1fd8f 494 /*----------------------------------------------//----------------------------*/
gatedClock 53:8c2baf5623c8 495 // front-end control of magnetron off.
gatedClock 53:8c2baf5623c8 496 // due to physical danger, the magnetron is turned off immediately
gatedClock 53:8c2baf5623c8 497 // upon detection of an open door.
gatedClock 53:8c2baf5623c8 498
gatedClock 26:bff592483cb1 499 void ISRcenterButtonRising(void) // toggle door state.
gatedClock 12:e40272e1fd8f 500 {
gatedClock 66:4a0006fa5cc1 501 if (debounceTimer.read_ms() > DEBOUNCEmS)
gatedClock 66:4a0006fa5cc1 502 {
gatedClock 66:4a0006fa5cc1 503 if (gtButtons.cDoorOpen == MSG_OPEN) // calculate door state.
gatedClock 66:4a0006fa5cc1 504 gtButtons.cDoorOpen = MSG_CLOSED;
gatedClock 66:4a0006fa5cc1 505 else
gatedClock 66:4a0006fa5cc1 506 gtButtons.cDoorOpen = MSG_OPEN;
gatedClock 53:8c2baf5623c8 507
gatedClock 59:5e45b5e4a874 508 // magnetron off.
gatedClock 66:4a0006fa5cc1 509 if (gtButtons.cDoorOpen == MSG_OPEN) led0 = 0;
gatedClock 58:ec630b6dd9b1 510
gatedClock 66:4a0006fa5cc1 511 gtButtons.cCenterButton = 1;
gatedClock 66:4a0006fa5cc1 512 }
gatedClock 66:4a0006fa5cc1 513 debounceTimer.reset(); // begin debounce period.
gatedClock 12:e40272e1fd8f 514 }
gatedClock 12:e40272e1fd8f 515 /*----------------------------------------------//----------------------------*/
gatedClock 15:5eaa2ab1d00d 516 void ISRcenterButtonFalling(void) // button-release debounce.
gatedClock 12:e40272e1fd8f 517 {
gatedClock 66:4a0006fa5cc1 518 debounceTimer.reset(); // begin debounce period.
gatedClock 12:e40272e1fd8f 519 }
gatedClock 12:e40272e1fd8f 520 /*----------------------------------------------//----------------------------*/
gatedClock 40:7afff79f0d8b 521 void temperatureThread(void const *args) // temperature measurement.
gatedClock 39:4e7e4d935a87 522 {
gatedClock 45:e3207684e841 523 while(1) // thread loop.
gatedClock 45:e3207684e841 524 {
gatedClock 45:e3207684e841 525 gfCelsius = temperature.read(); // physical measurement.
gatedClock 40:7afff79f0d8b 526
gatedClock 45:e3207684e841 527 Thread::wait(THREAD_1_WAITmS); // multitasking.
gatedClock 45:e3207684e841 528 } // thread loop.
gatedClock 45:e3207684e841 529 } // temperatureThread.
gatedClock 42:266d5bbbfd19 530 /*----------------------------------------------//----------------------------*/
gatedClock 42:266d5bbbfd19 531 void LCDthread(void const *args) // LCD display thread.
gatedClock 42:266d5bbbfd19 532 {
gatedClock 67:1d9c85a4c3c1 533
gatedClock 67:1d9c85a4c3c1 534 static int dLCDtotalCookTimeSec = 0; // sample current values.
gatedClock 67:1d9c85a4c3c1 535 static int dCookTimeRemainingSec = 0;
gatedClock 67:1d9c85a4c3c1 536 static float fLCDcelsius = 0.0;
gatedClock 67:1d9c85a4c3c1 537
gatedClock 67:1d9c85a4c3c1 538 // remember previous values.
gatedClock 67:1d9c85a4c3c1 539 static int dLCDtotalCookTimeSecLast = 0;
gatedClock 67:1d9c85a4c3c1 540 static int dCookTimeRemainingSecLast = 0;
gatedClock 67:1d9c85a4c3c1 541 static float fLCDcelsiusLast = 0.0;
gatedClock 67:1d9c85a4c3c1 542
gatedClock 44:d16e813e61ef 543 while(1) // thread loop.
gatedClock 44:d16e813e61ef 544 {
gatedClock 67:1d9c85a4c3c1 545 // don't allow the values to
gatedClock 67:1d9c85a4c3c1 546 // change in the middle of the
gatedClock 67:1d9c85a4c3c1 547 // below else the anti-blink
gatedClock 67:1d9c85a4c3c1 548 // code won't work.
gatedClock 67:1d9c85a4c3c1 549 dLCDtotalCookTimeSec = gdLCDtotalCookTimeSec;
gatedClock 67:1d9c85a4c3c1 550 dCookTimeRemainingSec = gdCookTimeRemainingSec;
gatedClock 67:1d9c85a4c3c1 551 fLCDcelsius = gfLCDcelsius;
gatedClock 67:1d9c85a4c3c1 552
gatedClock 67:1d9c85a4c3c1 553
gatedClock 67:1d9c85a4c3c1 554 // clear display only when
gatedClock 67:1d9c85a4c3c1 555 // necessary, in order to avoid
gatedClock 67:1d9c85a4c3c1 556 // 'blinkieness'.
gatedClock 67:1d9c85a4c3c1 557 if (dLCDtotalCookTimeSec != dLCDtotalCookTimeSecLast ||
gatedClock 67:1d9c85a4c3c1 558 dCookTimeRemainingSec != dCookTimeRemainingSecLast ||
gatedClock 67:1d9c85a4c3c1 559 fLCDcelsius != fLCDcelsiusLast)
gatedClock 67:1d9c85a4c3c1 560 lcd.cls();
gatedClock 42:266d5bbbfd19 561
gatedClock 44:d16e813e61ef 562 LCD1; // line 1.
gatedClock 67:1d9c85a4c3c1 563 lcd.printf(" total cook time: %d",dLCDtotalCookTimeSec);
gatedClock 42:266d5bbbfd19 564
gatedClock 44:d16e813e61ef 565 LCD2; // line 2.
gatedClock 67:1d9c85a4c3c1 566 lcd.printf(" remaing cook time: %d",dCookTimeRemainingSec);
gatedClock 42:266d5bbbfd19 567
gatedClock 44:d16e813e61ef 568 LCD3; // line 3.
gatedClock 67:1d9c85a4c3c1 569 lcd.printf(" temperature : %5.3f",fLCDcelsius);
gatedClock 67:1d9c85a4c3c1 570
gatedClock 67:1d9c85a4c3c1 571 // pipeline variables.
gatedClock 67:1d9c85a4c3c1 572 dLCDtotalCookTimeSecLast = dLCDtotalCookTimeSec;
gatedClock 67:1d9c85a4c3c1 573 dCookTimeRemainingSecLast = dCookTimeRemainingSec;
gatedClock 67:1d9c85a4c3c1 574 fLCDcelsiusLast = fLCDcelsius;
gatedClock 42:266d5bbbfd19 575
gatedClock 44:d16e813e61ef 576 Thread::wait(THREAD_2_WAITmS); // multitasking.
gatedClock 44:d16e813e61ef 577 } // thread loop.
gatedClock 44:d16e813e61ef 578 } // LCDthread.
gatedClock 42:266d5bbbfd19 579 /*----------------------------------------------//----------------------------*/
gatedClock 71:4a5f256ecf7c 580
gatedClock 71:4a5f256ecf7c 581 /*
gatedClock 71:4a5f256ecf7c 582 struct tRemainingTime // remaining time related.
gatedClock 64:255295f1d782 583 {
gatedClock 71:4a5f256ecf7c 584 char cControl; // countdown control.
gatedClock 71:4a5f256ecf7c 585 int dTotalTime; // initialize to this.
gatedClock 71:4a5f256ecf7c 586 int dRemainingTime; // the countdown value.
gatedClock 71:4a5f256ecf7c 587 }
gatedClock 71:4a5f256ecf7c 588
gatedClock 71:4a5f256ecf7c 589 giRemainingTime.
gatedClock 66:4a0006fa5cc1 590
gatedClock 71:4a5f256ecf7c 591 #define RT_PRELOAD 0x01 // remaining-time preload.
gatedClock 71:4a5f256ecf7c 592 #define RT_DECREMENT 0x02 // remaining-time decrement.
gatedClock 71:4a5f256ecf7c 593 #define RT_PAUSE 0x03 // remaining-time don't change.
gatedClock 71:4a5f256ecf7c 594 #define RT_CLEAR 0x04 // remaining-time set to zero.
gatedClock 71:4a5f256ecf7c 595
gatedClock 71:4a5f256ecf7c 596 */
gatedClock 71:4a5f256ecf7c 597
gatedClock 71:4a5f256ecf7c 598
gatedClock 71:4a5f256ecf7c 599
gatedClock 71:4a5f256ecf7c 600
gatedClock 71:4a5f256ecf7c 601
gatedClock 71:4a5f256ecf7c 602
gatedClock 71:4a5f256ecf7c 603 void tickCookRemainingTime(void) // cook-cycle countdown.
gatedClock 71:4a5f256ecf7c 604 {
gatedClock 71:4a5f256ecf7c 605 static int dRemainingTime = 0; // remaining time in seconds.
gatedClock 70:7c0743c28b11 606
gatedClock 71:4a5f256ecf7c 607 switch (giRemainingTime.cControl)
gatedClock 71:4a5f256ecf7c 608 {
gatedClock 71:4a5f256ecf7c 609 case RT_PRELOAD :
gatedClock 71:4a5f256ecf7c 610 {
gatedClock 71:4a5f256ecf7c 611
gatedClock 71:4a5f256ecf7c 612 break;
gatedClock 71:4a5f256ecf7c 613 }
gatedClock 71:4a5f256ecf7c 614 case RT_DECREMENT :
gatedClock 71:4a5f256ecf7c 615 {
gatedClock 71:4a5f256ecf7c 616
gatedClock 71:4a5f256ecf7c 617 break;
gatedClock 71:4a5f256ecf7c 618 }
gatedClock 71:4a5f256ecf7c 619
gatedClock 71:4a5f256ecf7c 620 case RT_PAUSE :
gatedClock 69:55b836e8ced7 621 {
gatedClock 71:4a5f256ecf7c 622
gatedClock 71:4a5f256ecf7c 623 break;
gatedClock 71:4a5f256ecf7c 624 }
gatedClock 71:4a5f256ecf7c 625
gatedClock 71:4a5f256ecf7c 626 case RT_CLEAR :
gatedClock 71:4a5f256ecf7c 627 {
gatedClock 71:4a5f256ecf7c 628
gatedClock 71:4a5f256ecf7c 629 break;
gatedClock 71:4a5f256ecf7c 630 }
gatedClock 69:55b836e8ced7 631
gatedClock 71:4a5f256ecf7c 632 default : break;
gatedClock 71:4a5f256ecf7c 633 }
gatedClock 71:4a5f256ecf7c 634
gatedClock 71:4a5f256ecf7c 635
gatedClock 70:7c0743c28b11 636
gatedClock 70:7c0743c28b11 637 } // cookRemainingTime.
gatedClock 69:55b836e8ced7 638 /*----------------------------------------------//----------------------------*/
gatedClock 69:55b836e8ced7 639
gatedClock 69:55b836e8ced7 640
gatedClock 69:55b836e8ced7 641
gatedClock 69:55b836e8ced7 642
gatedClock 69:55b836e8ced7 643
gatedClock 69:55b836e8ced7 644
gatedClock 69:55b836e8ced7 645
gatedClock 69:55b836e8ced7 646
gatedClock 69:55b836e8ced7 647
gatedClock 69:55b836e8ced7 648
gatedClock 69:55b836e8ced7 649