mbed heart

Dependencies:   TextLCD mbed-rtos mbed

Revision:
2:4761ca8ba841
Parent:
0:54ec65701097
Child:
3:189e64d01258
diff -r 54ec65701097 -r 4761ca8ba841 PMTest.cpp
--- a/PMTest.cpp	Wed Dec 02 00:50:28 2015 +0000
+++ b/PMTest.cpp	Wed Dec 02 01:58:23 2015 +0000
@@ -14,8 +14,8 @@
 
 int test_time_count;
 int curr_test;
-int minwaitV;
-int minwaitA;
+int minwaitV = 100000;
+int minwaitA = 200000;
 
 int needs_num_input = 0;
 
@@ -27,37 +27,45 @@
 
 
 
-void random_heart(){
+void random_heart(void const *args){
     t.reset();
     t.start();
 
     while(test_curr_mode == RANDOM){
         int r = rand();
-
         if(r%2 == 0){
-            if(t.read() > minwaitA){
+            serial_in.printf("timer was %i",t.read());
+            if(1){
                 asense = 1;
+                serial_in.printf("asense ");
                 Thread::wait(10);
                 asense = 0;
+                t.reset();
+
             }
         }else{
-            if(t.read() > minwaitV){
+            if(1){
                 vsense = 1;
+                serial_in.printf("vsense ");
                 Thread::wait(10);
                 vsense = 0;
+                t.reset();
+
             }
         }
+        
+        Thread::wait(500);
 
 
-        t.reset();
 
     }
 }
 
 
 void kbd_intrp(){
+
     char a = serial_in.getc();
-
+    serial_in.printf("char was " + a);
     if(needs_num_input){
         // DO O handling
         needs_num_input = 0;
@@ -84,9 +92,6 @@
         vsense = 0;
     }
         
-
-
-
 }
 
 
@@ -115,7 +120,41 @@
 }    
 
 int main(void){
-    while(1){
-        random_heart();
+    
+    Thread t3(random_heart, (void *)"");
+
+    
+    while(1){  
+    
+    if(serial_in.readable()){      
+    char a = serial_in.getc();
+    serial_in.printf("char was " + a);
+    if(needs_num_input){
+        // DO O handling
+        needs_num_input = 0;
+    }
+
+    if(a == 'R'){
+        test_curr_mode = RANDOM;
+    }else if(a == 'T'){
+        test_curr_mode = TEST;
+    }else if(a == 'M'){
+        test_curr_mode = MANUAL;
+    }
+    
+    if(a == 'A' && test_curr_mode == MANUAL){
+        asense = 1;
+        Thread::wait(10);
+        asense = 0;
+    }
+    
+    if(a == 'V' && test_curr_mode == MANUAL){
+        vsense = 1;
+        Thread::wait(10);
+        vsense = 0;
+    }
+    
+        
+    }
     }
 }
\ No newline at end of file