mbed heart

Dependencies:   TextLCD mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
lucastai
Date:
Wed Dec 02 21:34:10 2015 +0000
Parent:
8:0f92ac2b9d0e
Commit message:
PM Test Final

Changed in this revision

PMTest.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/PMTest.cpp	Wed Dec 02 20:41:31 2015 +0000
+++ b/PMTest.cpp	Wed Dec 02 21:34:10 2015 +0000
@@ -66,7 +66,7 @@
     
     test_timer.start();
     
-    while(vpace != 1 || vsense != 1){}
+    while(vpace != 1 && vsense != 1){}
     serial_in.printf("VRP: The separation between Ventricle events was %i ", test_timer.read_ms());
     
     
@@ -106,11 +106,9 @@
     while(test_curr_mode == RANDOM) {
         int r = rand();
         if(r%2 == 0) {
-            serial_in.printf("timer was %i",t.read_ms());
-            if(1) {
+            if(t.read_ms() > minwaitA) {
                 led_asense = 1;
                 asense = 1;
-                serial_in.printf("| ASENSE FIRED |");
                 Thread::wait(10);
                 asense = 0;
                 led_asense = 0;
@@ -120,10 +118,9 @@
                 Thread::wait(100);
             }
         } else {
-            if(1) {
+            if(t.read_ms() > minwaitV) {
                 led_vsense = 1;
                 vsense = 1;
-                serial_in.printf("| VSENSE FIRED | ");
                 Thread::wait(10);
                 vsense = 0;
                 beats++;
@@ -186,14 +183,12 @@
 
 void rec_apace(){
     led_apace = 1;
-    serial_in.printf("| A FIRED |");
     Thread::wait(10);
     led_apace = 0;   
 }
 
 void rec_vpace(){
     led_vpace = 1;
-    serial_in.printf("| V FIRED |");
     Thread::wait(10);
     led_vpace = 0;   
 }
@@ -221,25 +216,22 @@
 // interrupt function
 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
+    test_curr_mode = TEST;
+    serial_in.printf("--BEGIN TEST--");
+    while(vpace != 1){}
+    while(vpace == 1){}
+    test_LRI();
+    while(vpace != 1){}
+    while(vpace == 1){}
+    test_PVARP();
+    while(vpace != 1){}
+    while(vpace == 1){}
+    test_VRP();
+    while(apace != 1){}
+    while(apace == 1){}
+    test_AVI();
+    serial_in.printf("--END TEST--");
+    test_curr_mode = RANDOM;
 }
 
 void update_display() {
@@ -287,6 +279,7 @@
             } else if(a == 'T') {
                  serial_in.printf("GOT T!!");
                 test_curr_mode = TEST;
+                interrupt_and_run_test();
             
             } else if(a == 'M') {
                  serial_in.printf("GOT M!!");
@@ -299,13 +292,17 @@
 
             if(a == 'A' && test_curr_mode == MANUAL) {
                 asense = 1;
+                led_asense = 1;
                 Thread::wait(10);
+                led_asense = 0;
                 asense = 0;
             }
 
             if(a == 'V' && test_curr_mode == MANUAL) {
                 vsense = 1;
+                led_vsense = 1;
                 Thread::wait(10);
+                led_vsense = 0;
                 vsense = 0;
             }