mbed heart

Dependencies:   TextLCD mbed-rtos mbed

Revision:
3:189e64d01258
Parent:
2:4761ca8ba841
Child:
4:6d3ddf74b49a
diff -r 4761ca8ba841 -r 189e64d01258 PMTest.cpp
--- a/PMTest.cpp	Wed Dec 02 01:58:23 2015 +0000
+++ b/PMTest.cpp	Wed Dec 02 02:01:17 2015 +0000
@@ -19,7 +19,7 @@
 
 int needs_num_input = 0;
 
-enum mode{RANDOM,MANUAL,TEST};
+enum mode {RANDOM,MANUAL,TEST};
 mode test_curr_mode = RANDOM;
 Timer t;
 
@@ -27,15 +27,16 @@
 
 
 
-void random_heart(void const *args){
+void random_heart(void const *args)
+{
     t.reset();
     t.start();
 
-    while(test_curr_mode == RANDOM){
+    while(test_curr_mode == RANDOM) {
         int r = rand();
-        if(r%2 == 0){
+        if(r%2 == 0) {
             serial_in.printf("timer was %i",t.read());
-            if(1){
+            if(1) {
                 asense = 1;
                 serial_in.printf("asense ");
                 Thread::wait(10);
@@ -43,8 +44,8 @@
                 t.reset();
 
             }
-        }else{
-            if(1){
+        } else {
+            if(1) {
                 vsense = 1;
                 serial_in.printf("vsense ");
                 Thread::wait(10);
@@ -53,7 +54,7 @@
 
             }
         }
-        
+
         Thread::wait(500);
 
 
@@ -62,99 +63,103 @@
 }
 
 
-void kbd_intrp(){
+void kbd_intrp()
+{
 
     char a = serial_in.getc();
     serial_in.printf("char was " + a);
-    if(needs_num_input){
+    if(needs_num_input) {
         // DO O handling
         needs_num_input = 0;
         return;
     }
 
-    if(a == 'R'){
+    if(a == 'R') {
         test_curr_mode = RANDOM;
-    }else if(a == 'T'){
+    } else if(a == 'T') {
         test_curr_mode = TEST;
-    }else if(a == 'M'){
+    } else if(a == 'M') {
         test_curr_mode = MANUAL;
     }
-    
-    if(a == 'A' && 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){
+
+    if(a == 'V' && test_curr_mode == MANUAL) {
         vsense = 1;
         Thread::wait(10);
         vsense = 0;
     }
-        
+
 }
 
 
 
 // interrupt function
-void interrupt_and_run_test(){
+void interrupt_and_run_test()
+{
     // zero timer, set for 1ms interrupt
-    
+
     // wait for atrial pulse
-    
+
     // check if timer was within event
-    
-    
+
+
     // send vsense
-    
-    
+
+
     // send asense
-    
+
     // check if timer was in event
 
     // wait for vpace
-    
+
     // wait for atrial pulse
-    
+
     // check if timer was within event
-}    
+}
 
-int main(void){
-    
+int main(void)
+{
+
     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;
-    }
+    char a = 'Z';
+
+    while(1) {
+
+        if(serial_in.readable()) {
+            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;
-    }
-    
-        
-    }
+            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