mbed heart

Dependencies:   TextLCD mbed-rtos mbed

Revision:
4:6d3ddf74b49a
Parent:
3:189e64d01258
Child:
5:8d9bcf25accb
diff -r 189e64d01258 -r 6d3ddf74b49a PMTest.cpp
--- a/PMTest.cpp	Wed Dec 02 02:01:17 2015 +0000
+++ b/PMTest.cpp	Wed Dec 02 03:50:45 2015 +0000
@@ -9,6 +9,11 @@
 DigitalIn apace(p22);
 DigitalIn vpace(p21);
 
+DigitalOut led_apace(LED1);
+DigitalOut led_vpace(LED2);
+DigitalOut led_asense(LED3);
+DigitalOut led_vsense(LED4);
+
 Serial serial_in(USBTX, USBRX);
 
 
@@ -31,25 +36,29 @@
 {
     t.reset();
     t.start();
-
+    while(1){
     while(test_curr_mode == RANDOM) {
         int r = rand();
         if(r%2 == 0) {
             serial_in.printf("timer was %i",t.read());
             if(1) {
+                led_asense = 1;
                 asense = 1;
                 serial_in.printf("asense ");
                 Thread::wait(10);
                 asense = 0;
+                led_asense = 0;
                 t.reset();
 
             }
         } else {
             if(1) {
+                led_vsense = 1;
                 vsense = 1;
                 serial_in.printf("vsense ");
                 Thread::wait(10);
                 vsense = 0;
+                led_vsense = 0;
                 t.reset();
 
             }
@@ -60,6 +69,7 @@
 
 
     }
+    }
 }
 
 
@@ -96,7 +106,32 @@
 
 }
 
+void rec_apace(){
+    led_apace = 1;
+    serial_in.printf("vssense fired\n");
+    Thread::wait(10);
+    led_apace = 0;   
+}
 
+void rec_vpace(){
+    led_vpace = 1;
+    serial_in.printf("vssense fired\n");
+    Thread::wait(10);
+    led_vpace = 0;   
+}
+
+void heart_response(void const *args){
+    while(1){
+        if(apace == 1){
+            rec_apace();
+        }
+        
+        if(vpace == 1){
+            rec_vpace();
+        }
+    }
+    
+}
 
 // interrupt function
 void interrupt_and_run_test()
@@ -126,6 +161,7 @@
 {
 
     Thread t3(random_heart, (void *)"");
+    Thread t2(heart_response, (void *)"");
 
     char a = 'Z';