CIS441 Controller

Dependencies:   TextLCD mbed-rtos mbed

Fork of PacemakerController by Chad Nachiappan

Revision:
30:97db5a684eaa
Parent:
29:5cec671cb80d
Child:
31:7f0e865e3d4b
--- a/PacemakerController.cpp	Wed Dec 02 00:47:31 2015 +0000
+++ b/PacemakerController.cpp	Wed Dec 02 01:26:27 2015 +0000
@@ -52,6 +52,7 @@
 void asense()
 {
     a_sense = 1;
+    lcd.printf("asense fired\n");
     Thread::wait(10);
     a_sense = 0;
 }
@@ -59,6 +60,7 @@
 void vsense()
 {
     v_sense = 1;
+    lcd.printf("vssense fired\n");
     Thread::wait(10);
     v_sense = 0;
 }
@@ -66,6 +68,7 @@
 void apace()
 {
 
+    lcd.printf("apace fired\n");
     apaceSignal = 1;
     led_apace = 1;
     Thread::wait(10);
@@ -75,7 +78,7 @@
 
 void vpace()
 {
-
+    lcd.printf("vpace fired\n");
     vpaceSignal = 1;
     led_vpace = 1;
     Thread::wait(10);
@@ -109,14 +112,16 @@
     while (1) {
         // min hr alarm
         if( beats < MIN_PM_RT) {
+            lcd.cls();
             lcd.locate(0,1);
-            lcd.printf("!<");
+            lcd.printf("!<\n");
         }
     
         // max hr alarm
         if(beats > MAX_PM_RT) {
+            lcd.cls();
             lcd.locate(0,1);
-            lcd.printf("!>");
+            lcd.printf("!>\n");
         }
     }
 
@@ -184,6 +189,8 @@
 {
 
     while(1) {
+        //lcd.locate(0,1);
+        //lcd.printf("in pmsense\n");
 
         if (timer_count >= VRP && vgetSignal == 1) {
             // Valid_V state
@@ -210,8 +217,12 @@
 void pm_response(void const *args)
 {
     while(1) {
+        //lcd.cls();
+        //lcd.printf("in response\n");
         bool goInitalState = 1;
         if (timer_count >= LRI-AVI) {
+            //lcd.cls();
+            //lcd.printf("timer_count >= LRI-AVI\n");
             goInitalState = 0;
             // PM_A! sets the LED high
             led_apace = 1;
@@ -222,6 +233,8 @@
             apace();
             // At Atrial Event State
             while (avi_clk.read() < AVI) {
+                //lcd.cls();
+                //lcd.printf("avi_clk.read() < AVI\n");
                 if (v_sense == 1) {
                     goInitalState = 1;
                     break;
@@ -238,6 +251,8 @@
                 vpace();
             }
         } else if (timer_count < LRI - AVI) {
+             //lcd.cls();
+             //lcd.printf("timer_count < LRI - AVI\n");
             // if Asense, move on to atrial event
             if (a_sense == 1) {
                 goInitalState = 0;
@@ -271,6 +286,7 @@
     // https://developer.mbed.org/users/chadnach1/code/PacemakerController/
     // connect the serial device (PC keybd) to the interrupt
     pc.attach(&keyboard_handler);
+    lcd.printf("in main\n");
 
     // Start LED's Off
     led_apace = 0;
@@ -279,7 +295,8 @@
     // Start the avi_clock
     avi_clk.start();
 
-    Thread t2(PM_ALARM);
-    Thread t3(pm_sense);
-    Thread t4(pm_response);
+    Thread t1(pm_sense, (void *)"");
+    Thread t2(pm_response, (void *)"");
+    
+    PM_ALARM((void *)"");
 }
\ No newline at end of file