homework 7

Dependencies:   mbed-rtos mbed C12832_lcd LM75B

Files at this revision

API Documentation at this revision

Comitter:
gatedClock
Date:
Wed Sep 11 23:06:09 2013 +0000
Parent:
71:4a5f256ecf7c
Child:
73:44739860198b
Commit message:
rewrite tickCookRemainingTime.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Sep 11 23:00:14 2013 +0000
+++ b/main.cpp	Wed Sep 11 23:06:09 2013 +0000
@@ -606,30 +606,40 @@
       
       switch (giRemainingTime.cControl)
       {
-        case RT_PRELOAD   : 
+        case RT_PRELOAD   :                     // preload with total time.
         {
-        
+          dRemainingTime = giRemainingTime.dTotalTime;
+          if (dRemainingTime > 180) dRemainingTime = 180;
+          if (dRemainingTime <   0) dRemainingTime =   0;
           break;
         }
-        case RT_DECREMENT :
+        case RT_DECREMENT :                     // count-down.
         {
-        
+          dRemainingTime--;
+          if (dRemainingTime > 180) dRemainingTime = 180;
+          if (dRemainingTime <   0) dRemainingTime =   0;
           break;
         }
       
-        case RT_PAUSE    :
+        case RT_PAUSE    :                      // suspend countdown.
         {
-        
+          dRemainingTime = dRemainingTime;
+          if (dRemainingTime > 180) dRemainingTime = 180;
+          if (dRemainingTime <   0) dRemainingTime =   0;
           break;
         }
         
-        case RT_CLEAR    :
+        case RT_CLEAR    :                      // clear countdown.
         {
-        
+          dRemainingTime = 0;               
           break;
         }
       
-        default          : break;
+        default          :                      // saturate, just in case.
+        {
+          if (dRemainingTime > 180) dRemainingTime = 180;
+          if (dRemainingTime <   0) dRemainingTime =   0;        
+        }
       }