Pacemaker code Implementation for SFWRENG 3K04

Dependencies:   FXOS8700Q Queue mbed-rtos mbed

Fork of Pacemaker by Eric dollar

Revision:
19:d58e1e1a9a24
Parent:
16:08d5e5a3ee74
Child:
20:bfd23a6845bb
Child:
21:fc6c33206152
diff -r 27134bc42ecb -r d58e1e1a9a24 interface.cpp
--- a/interface.cpp	Thu Nov 17 04:10:59 2016 +0000
+++ b/interface.cpp	Thu Nov 24 01:10:08 2016 +0000
@@ -34,15 +34,24 @@
 //USER INTERFACE SCREENS**************************   
 
 void interface::startScreen(){
-    (*pc).printf("\nWelcome to the PACEMAKER DCM.\n");
-    (*pc).printf("Options:\n");
-    (*pc).printf("1. Start VOOR Pulse\n"); // temporary test to get VOOR working
-    (*pc).printf("2. View/Change data\n");
-    (*pc).printf("Please enter a command:");
+    
+    pc->printf("\n ____   _    ____ _____ __  __    _    _  _______ ____  ");
+    pc->printf("\n|  _ \\ / \\  / ___| ____|  \\/  |  / \\  | |/ / ____|  _ \\");
+    pc->printf("\n| |_) / _ \\| |   |  _| | |\\/| | / _ \\ | ' /|  _| | |_) |");
+    pc->printf("\n|  __/ ___ \\ |___| |___| |  | |/ ___ \\| . \\| |___|  _ <");
+    pc->printf("\n|_| /_/   \\_\\____|_____|_|  |_/_/   \\_\\_|\\_\\_____|_| \\_\\");
+    
+    
+    pc->printf("\nWelcome to the PACEMAKER DCM.\n");
+    pc->printf("Options:\n");
+    pc->printf("1. Start VOOR Pulse\n"); // temporary test to get VOOR working
+    pc->printf("2. View/Change data\n");
+    pc->printf("Please enter a command:");
     char command = getChar();
     switch (command) {
         case '1':{
-            voor v(interfacePulse); //creates new instance of voor
+            
+            voor v(interfacePulse, ventData); //creates new instance of voor
             v.startPace(); //starts pacing voor the same way as it used to pace in the user interface
             //interfacePulse->startPulse(); //problems with this method: you create the pc output twice, once in UI and once in pulse.
             startScreen();                             //realistically we'll never need to call the serial output in pulse, it should all be done in UI
@@ -52,7 +61,7 @@
             interface::dataScreen();
             break;
         default:
-            pc->printf("\nThat is not an option.");
+            pc->printf("\nThat is not an option.\n");
             interface::startScreen();
             break;
     }   
@@ -65,43 +74,73 @@
     char command = getChar();
     switch (command) {
         case '1':
-            pc->printf("\nAtrium Data");
-            pc->printf("\n1. Pace Amplitude: %f", atrData->getPaceAmp()*7);
-            pc->printf("\n2. Pace Width: %f", atrData->getPaceWidth());
-            pc->printf("\n3. Refractory Period: %f", atrData->getRP());
-            pc->printf("\n4. Sensitivity: %f", atrData->getSensitivity());
-            pc->printf("\nChoose variable to be changed or 5 To return to Data Sets");
-            interface::getData(atrData);
-            break;
+            interface::chamberDataScreen(atrData);
         case '2':
-            pc->printf("\nVentricle Data");
-            pc->printf("\n1. Pace Amplitude: %f", ventData->getPaceAmp()*7);
-            pc->printf("\n2. Pace Width: %f", ventData->getPaceWidth());
-            pc->printf("\n3. Refractory Period: %f", ventData->getRP());
-            pc->printf("\n4. Sensitivity: %f", ventData->getSensitivity());
-            pc->printf("\nChoose variable to be changed or 5 To return to Data Sets");
-            interface::getData(ventData);
-            break;
+            interface::chamberDataScreen(ventData);
         case '3':
-            pc->printf("\nGeneral Data");
-            pc->printf("\n1. Hysteresis: %s", generalData->getHyst() ? "true" : "false");
-            pc->printf("\n2. Hysteresis Interval: %f", generalData->getHystInterval());
-            pc->printf("\n3. Lower Rate Limit: %f", generalData->getLRL());
-            pc->printf("\n4. Upper Rate Limit: %f", generalData->getURL());
-            pc->printf("\n5. Atrial-Ventricular Delay: %f", generalData->getAVdelay());
-            pc->printf("\n6. Atrial-Ventricular Delay Offset: %f" , generalData->getAVdelayOffset());
-            pc->printf("\n7. Rate Smoothing: %f", generalData->getRSmooth());
+            interface::genDataScreen();
         case '4':
             pc->printf("\nNot setup yet");
             break;
         case '5':
             interface::startScreen();  
         default:
-            pc->printf("\nThat is not an option.");
+            pc->printf("\nThat is not an option.\n");
             interface::dataScreen();
     }  
 }
 
+void interface::chamberDataScreen(chamberData* chamber){
+            if (chamber == atrData)
+            pc->printf("\nAtrium Data");
+            
+            if (chamber == ventData)   
+            pc->printf("\nVentricle Data");
+            
+            pc->printf("\n1. Pace Amplitude: %f", chamber->getPaceAmp()*7);
+            pc->printf("\n2. Pace Width: %f", chamber->getPaceWidth());
+            pc->printf("\n3. Refractory Period: %f", chamber->getRP());
+            pc->printf("\n4. Sensitivity: %f", chamber->getSensitivity());
+            pc->printf("\nChoose variable to be changed or 5 To return to Data Sets");
+            interface::getData(chamber);
+}
+
+void interface::genDataScreen(){ //moved option 3 from dataScreen() into its own method
+    pc->printf("\nGeneral Data");
+    pc->printf("\n1. Hysteresis: %s", generalData->getHyst() ? "true" : "false");
+    pc->printf("\n2. Hysteresis Interval: %f", generalData->getHystInterval());
+    pc->printf("\n3. Lower Rate Limit: %f", generalData->getLRL());
+    pc->printf("\n4. Upper Rate Limit: %f", generalData->getURL());
+    pc->printf("\n5. Atrial-Ventricular Delay: %f", generalData->getAVdelay());
+    pc->printf("\n6. Atrial-Ventricular Delay Offset: %f" , generalData->getAVdelayOffset());
+    pc->printf("\n7. Rate Smoothing: %f", generalData->getRSmooth());
+    pc->printf("\nChoose variable to be changed or 5 To return to Data Sets");      
+    char command = getChar();
+    switch (command) {
+        case '1':
+            pc->printf("\nNot setup yet\n");
+            interface::genDataScreen();
+            break;
+        case '2':
+            pc->printf("\nNot setup yet\n");
+            interface::genDataScreen();
+            break;
+        case '3':
+            pc->printf("\nNot setup yet\n");
+            interface::genDataScreen();
+        case '4':
+            pc->printf("\nNot setup yet\n");
+            interface::genDataScreen();
+            break;
+        case '5':
+            interface::dataScreen(); 
+        default:
+            pc->printf("\nThat is not an option.\n");
+            interface::genDataScreen();
+    }  
+}
+
+
 void interface::getData(chamberData* chamber){
     char command = getChar();
     switch (command){