CIS541 Xueli Jon / Mbed 2 deprecated myStopwatch_threads

Dependencies:   TextLCD mbed-rtos mbed

Revision:
2:91cb258f9745
Parent:
1:38e744366b97
Child:
3:6fad2a5b72e5
diff -r 38e744366b97 -r 91cb258f9745 main.cpp
--- a/main.cpp	Fri Oct 03 19:26:13 2014 +0000
+++ b/main.cpp	Fri Oct 03 19:47:12 2014 +0000
@@ -21,13 +21,38 @@
 int main() {
     
     Thread thread_display(update_display);
-    Thread thread_mm(update_mm);
-    Thread thread_ss(update_ss);
-    Thread thread_MM(update_MM);
-    
-    while (true) {
 
+    char input = 'z';
+    int run_status = 0;
+    while(1) {
+        
+        if ( input == 's') { 
+            if (run_status==0) {
+                Thread thread_mm(update_mm);
+                Thread thread_ss(update_ss);
+                Thread thread_MM(update_MM);
+                run_status = 1;
+            }
+        }
+        if ( input == 'p') {
+            if (run_status==1) {
+                thread_mm.terminate();
+                thread_ss.terminate();
+                thread_MM.terminate();
+                run_status = 0;
+            }
+        }
+        if ( input == 'r') {
+            if (run_status == 0) {
+                mm[0] = mm[1] = 0;
+                ss[0] = ss[1] = 0;
+                MM[0] = MM[1] = 0;
+            }
+        }
+        
+        input = pc.getc();
     }
+
 }
 
 void update_display(void const *args) {