homework 7

Dependencies:   mbed-rtos mbed C12832_lcd LM75B

Revision:
79:4286319e48b4
Parent:
78:7df160e0db7b
Child:
80:e3e1a2161435
--- a/main.cpp	Thu Sep 12 04:12:13 2013 +0000
+++ b/main.cpp	Thu Sep 12 04:24:40 2013 +0000
@@ -406,7 +406,7 @@
           }
           
           
-          case  FSM_CONTINUE :                  // continue
+          case  FSM_CONTINUE :                  // CONTINUE.
           {
               
             if (dFSMstate != dFSMstateLast)     // if just entered state.
@@ -418,6 +418,8 @@
             if (dRemainingTime <= 0) dFSMstate = FSM_DONE;
             else
             if (dButtonStop) dFSMstate = FSM_IDLE; 
+            else
+            if ((dDoorOpen == 1) && (dRemainingTime > 0)) dFSMstate = FSM_PAUSE;
             break;
           }          
           
@@ -452,26 +454,28 @@
           
           if (dButtonState == MSG_START)
           {
-//            pc.printf("\n\r message start.");
             dButtonStart = 1;
             dButtonStop  = 0;
+            
+                                                // if the door is open, ignore
+                                                // and cancel 'start' state.
+            if (dDoorOpen) dButtonStart = 0;
           }
           if (dButtonState == MSG_STOP)
           {
- //           pc.printf("\n\r message stop.");
             dButtonStart = 0;
             dButtonStop  = 1;
           }    
           
           if (dButtonState == MSG_OPEN)
           {
-//            pc.printf("\n\r message open.");
-            dDoorOpen = 1;
+                                                // if the door opens, clear current 'start' state.
+            dDoorOpen    = 1;
+            dButtonStart = 0;
           }       
           
           if (dButtonState == MSG_CLOSED)
           {
-//            pc.printf("\n\r message closed.");
             dDoorOpen = 0;
           }