eric's fork test
Fork of Pacemaker by
Embed:
(wiki syntax)
Show/hide line numbers
interface.cpp
00001 #pragma once 00002 #include "mbed.h" 00003 #include "interface.h" 00004 #include "hardware.h" 00005 #include "chamberData.h" 00006 #include "genData.h" 00007 #include "pulse.h" 00008 #include "voor.h" 00009 #include "rtos.h" 00010 #include <stdlib.h> 00011 #include <stdio.h> 00012 #include <string> 00013 00014 //CONSTRUCTORS***************************** 00015 interface::interface(){ 00016 } 00017 00018 interface::~interface(){}; 00019 00020 interface::interface(Serial* inputPC){ 00021 pc = inputPC; 00022 } 00023 00024 interface::interface(Serial* inputPC , pulse* p ,genData* genData, chamberData* atrium , chamberData* ventricle){ 00025 generalData = genData; 00026 pc = inputPC; 00027 interfacePulse = p; 00028 atrData = atrium; 00029 ventData = ventricle; 00030 } 00031 //******************************************** 00032 00033 00034 //USER INTERFACE SCREENS************************** 00035 00036 void interface::startScreen(){ 00037 (*pc).printf("\nWelcome to the PACEMAKER DCM.\n"); 00038 (*pc).printf("Options:\n"); 00039 (*pc).printf("1. Start VOOR Pulse\n"); // temporary test to get VOOR working 00040 (*pc).printf("2. View/Change data\n"); 00041 (*pc).printf("Please enter a command:"); 00042 char command = getChar(); 00043 switch (command) { 00044 case '1':{ 00045 voor v(interfacePulse); //creates new instance of voor 00046 v.startPace(); //starts pacing voor the same way as it used to pace in the user interface 00047 //interfacePulse->startPulse(); //problems with this method: you create the pc output twice, once in UI and once in pulse. 00048 startScreen(); //realistically we'll never need to call the serial output in pulse, it should all be done in UI 00049 break; 00050 } 00051 case '2': 00052 interface::dataScreen(); 00053 break; 00054 default: 00055 pc->printf("\nThat is not an option."); 00056 interface::startScreen(); 00057 break; 00058 } 00059 } 00060 00061 void interface::dataScreen(){ 00062 (*pc).printf("\nDCM Data sets:\n"); 00063 (*pc).printf("1. Atrium Data\n2. Ventricle Data\n3. General Data\n4. Egram Data\n5. Back to start page\n"); 00064 (*pc).printf("Choose a data set:"); 00065 char command = getChar(); 00066 switch (command) { 00067 case '1': 00068 pc->printf("\nAtrium Data"); 00069 pc->printf("\n1. Pace Amplitude: %f", atrData->getPaceAmp()*7); 00070 pc->printf("\n2. Pace Width: %f", atrData->getPaceWidth()); 00071 pc->printf("\n3. Refractory Period: %f", atrData->getRP()); 00072 pc->printf("\n4. Sensitivity: %f", atrData->getSensitivity()); 00073 pc->printf("\nChoose variable to be changed or 5 To return to Data Sets"); 00074 interface::getData(atrData); 00075 break; 00076 case '2': 00077 pc->printf("\nVentricle Data"); 00078 pc->printf("\n1. Pace Amplitude: %f", ventData->getPaceAmp()*7); 00079 pc->printf("\n2. Pace Width: %f", ventData->getPaceWidth()); 00080 pc->printf("\n3. Refractory Period: %f", ventData->getRP()); 00081 pc->printf("\n4. Sensitivity: %f", ventData->getSensitivity()); 00082 pc->printf("\nChoose variable to be changed or 5 To return to Data Sets"); 00083 interface::getData(ventData); 00084 break; 00085 case '3': 00086 pc->printf("\nGeneral Data"); 00087 pc->printf("\n1. Hysteresis: %s", generalData->getHyst() ? "true" : "false"); 00088 pc->printf("\n2. Hysteresis Interval: %f", generalData->getHystInterval()); 00089 pc->printf("\n3. Lower Rate Limit: %f", generalData->getLRL()); 00090 pc->printf("\n4. Upper Rate Limit: %f", generalData->getURL()); 00091 pc->printf("\n5. Atrial-Ventricular Delay: %f", generalData->getAVdelay()); 00092 pc->printf("\n6. Atrial-Ventricular Delay Offset: %f" , generalData->getAVdelayOffset()); 00093 pc->printf("\n7. Rate Smoothing: %f", generalData->getRSmooth()); 00094 case '4': 00095 pc->printf("\nNot setup yet"); 00096 break; 00097 case '5': 00098 interface::startScreen(); 00099 default: 00100 pc->printf("\nThat is not an option."); 00101 interface::dataScreen(); 00102 } 00103 } 00104 00105 void interface::getData(chamberData* chamber){ 00106 char command = getChar(); 00107 switch (command){ 00108 case '1': 00109 pc->printf("\nChoose New Value:"); 00110 char* value = getInput(); 00111 chamber->chngPaceAmp(atof(value)); 00112 pc->printf("\t%f",chamber->getPaceAmp()*7); 00113 interface::dataScreen(); 00114 break; 00115 case '2': 00116 pc->printf("\nChoose New Value:"); 00117 value = getInput(); 00118 chamber->chngPaceWidth(atof(value)); 00119 pc->printf("\t%f",chamber->getPaceWidth()); 00120 interface::dataScreen(); 00121 break; 00122 case '3': 00123 pc->printf("\nChoose New Value:"); 00124 value = getInput(); 00125 chamber->chngRP(atof(value)); 00126 pc->printf("\t%f",chamber->getRP()); 00127 interface::dataScreen(); 00128 break; 00129 case '4': 00130 pc->printf("\nChoose New Value:"); 00131 value = getInput(); 00132 chamber->chngSensitivity(atof(value)); 00133 pc->printf("\t%f",chamber->getSensitivity()); 00134 interface::dataScreen(); 00135 break; 00136 case '5': 00137 interface::dataScreen(); 00138 break; 00139 default: 00140 pc->printf("\nThat is not an option."); 00141 interface::getData(chamber); 00142 } 00143 } 00144 00145 00146 00147 char* interface::getInput(){ 00148 char buffer[5]; 00149 fgets (buffer,5,stdin); 00150 return buffer; 00151 } 00152 00153 char interface::getChar(){ 00154 while(true){ 00155 if(pc->readable()){ 00156 char command = pc->getc(); 00157 return command; 00158 } 00159 } 00160 } 00161 //**************************** 00162 00163 //void interface::getAPulse(){ //TODO get this to work, the wait command has issues, see pulse.cpp . wait takes in seconds as argument 00164 // pulse myPulse(*atr); 00165 // myPulse.setWidth(1); 00166 // myPulse.startPulse(); 00167 // } 00168 00169 //void interface::LEDon(AnalogOut* out){ 00170 // (*out) = 0; 00171 //// (*pc).printf(led); 00172 //} 00173 // 00174 //void interface::LEDoff(AnalogOut* out){ 00175 // (*out) = 1; 00176 //}
Generated on Thu Jul 14 2022 00:42:53 by
1.7.2
Eric Tran
