Part of the Pacemaker Project; this models the Pacemaker.

Dependencies:   mbed TextLCD mbed-rtos

Revision:
6:d9c0ce333d71
Parent:
4:f04eb7f96f4b
Parent:
5:9eee15818b0e
Child:
7:af6c040f0421
--- a/PacemakerController.cpp	Mon Nov 30 03:31:29 2015 +0000
+++ b/PacemakerController.cpp	Mon Nov 30 03:39:25 2015 +0000
@@ -11,6 +11,7 @@
 Serial pc(USBTX, USBRX);
 TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x4); // rs, e, d4-d7
 
+int keyboard_needs_numeric = 0; // boolean - is in middle of interval input?
 
 int h_clock;
 int pm_clock;
@@ -82,13 +83,20 @@
 }
 
 // hw interrupt callback, deal with the keyboard input from PC
-void MODE_SWITCH() {
+void keyboard_handler() {
     
     // get the char, put it on the PC command line
     char a = pc.getc();
 
-    // if the char is N, update bounds to normal mode
-    if(a == 'N'){
+    if (keyboard_needs_numeric) {
+        if (a >= '0' && a <= '9') {
+            // update observation interval
+            obs_int = (a - '0') * 5;
+        } else {
+            pc.printf("Expected numeric key\n");    
+        }
+    } else if(a == 'N'){
+        // if the char is N, update bounds to normal mode
         curr_mode = NORMAL;
         upper_bound = 100;
         lower_bound = 40;
@@ -123,7 +131,9 @@
         if(curr_mode == MANUAL){
             pc.printf("MODE IS MANUAL GOT VPACE\n");   
         }  
-    }else{
+    }else if (a == 'O'){
+        keyboard_needs_numeric = 1;
+    } else{
         // do nothing for invalid char
     }
     
@@ -176,8 +186,9 @@
 
 
 int main() {
+    https://developer.mbed.org/users/chadnach1/code/PacemakerController/
     // connect the serial device (PC keybd) to the interrupt
-    pc.attach(&MODE_SWITCH);
+    pc.attach(&keyboard_handler);
     
     Thread t3(pm_sense);
     Thread t4(pm_response);