Part of the Pacemaker Project; this models the Pacemaker.

Dependencies:   mbed TextLCD mbed-rtos

Revision:
15:81c5dbdf3ca0
Parent:
9:fd8477284185
--- a/PacemakerController.cpp	Mon Nov 30 20:24:59 2015 +0000
+++ b/PacemakerController.cpp	Mon Nov 30 20:59:48 2015 +0000
@@ -15,7 +15,7 @@
 
 int h_clock;
 int pm_clock;
-int avi_clock; 
+Timer avi_clock; 
 
 int LRI = 1000;
 int AVI = 150;
@@ -36,9 +36,7 @@
 int obs_int = 10;
 mode curr_mode = NORMAL;
 
-
-
-// alarms 
+// LED's 
 DigitalOut Apace(LED1);
 DigitalOut Vpace(LED2);
 DigitalOut Asense(LED3);
@@ -166,25 +164,33 @@
  
     while(1) {
          if (timer_count >= LRI-AVI) {
-             // PM_A!
+             
+             // PM_A! sets the LED high
+             Apace = 1;
+             
              // avi_clk = 0
-             //apace();
+             avi_clk.reset();
+             
+             apace();
          } else if (timer_count < LRI - AVI) {
+             
              // avi_clk = 0
-             // wait for Asense?
+             avi_clk.reset();
+             
+             // wait for Asense? naaah
          } 
          
          // At Atrial Event State
-         
-         //while (avi_clk < AVI);
+         while (avi_clk.read() < AVI);
          
          // Ventricular Event
          timer_count = 0;
-         // PM_V!
+         
+         // PM_V! sets the LED high
+         Vpace = 1;
+         
          timer_count = 0;
-         // VPace!
-         
-        
+         vpace();
     } 
 }
 
@@ -199,10 +205,17 @@
 
 
 int main() {
-    https://developer.mbed.org/users/chadnach1/code/PacemakerController/
+    // https://developer.mbed.org/users/chadnach1/code/PacemakerController/
     // connect the serial device (PC keybd) to the interrupt
     pc.attach(&keyboard_handler);
     
+    // Start LED's Off
+    Apace = 0;
+    Vpace = 0;
+    
+    // Start the avi_clock
+    avi_clk.start();
+    
     Thread t3(pm_sense);
     Thread t4(pm_response);