Pacemaker code Implementation for SFWRENG 3K04
Dependencies: mbed Queue mbed-rtos FXOS8700Q
Fork of Pacemaker by
SWFRENG 3K04 Project to design, develop, and document a functional pacemaker.
The project uses the Freescale K64F Microcontroller and C++ mbed library.
interface.cpp@22:19b187e345c9, 2016-11-24 (annotated)
- Committer:
- trane3
- Date:
- Thu Nov 24 03:42:12 2016 +0000
- Revision:
- 22:19b187e345c9
- Parent:
- 20:bfd23a6845bb
- Parent:
- 21:fc6c33206152
- Child:
- 23:719584670460
combined changes, eric and gareth
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
FiveDollar | 20:bfd23a6845bb | 1 | #pragma once |
FiveDollar | 0:b2b3955cd77b | 2 | #include "mbed.h" |
FiveDollar | 0:b2b3955cd77b | 3 | #include "interface.h" |
FiveDollar | 0:b2b3955cd77b | 4 | #include "hardware.h" |
FiveDollar | 0:b2b3955cd77b | 5 | #include "chamberData.h" |
FiveDollar | 0:b2b3955cd77b | 6 | #include "genData.h" |
FiveDollar | 0:b2b3955cd77b | 7 | #include "pulse.h" |
trane3 | 8:75c1dd8b0d61 | 8 | #include "voor.h" |
noahzwiep | 16:08d5e5a3ee74 | 9 | #include "rtos.h" |
FiveDollar | 0:b2b3955cd77b | 10 | #include <stdlib.h> |
FiveDollar | 0:b2b3955cd77b | 11 | #include <stdio.h> |
FiveDollar | 0:b2b3955cd77b | 12 | #include <string> |
FiveDollar | 0:b2b3955cd77b | 13 | |
FiveDollar | 0:b2b3955cd77b | 14 | //CONSTRUCTORS***************************** |
FiveDollar | 0:b2b3955cd77b | 15 | interface::interface(){ |
FiveDollar | 0:b2b3955cd77b | 16 | } |
FiveDollar | 0:b2b3955cd77b | 17 | |
trane3 | 7:4eb590c7e064 | 18 | interface::~interface(){}; |
trane3 | 7:4eb590c7e064 | 19 | |
FiveDollar | 0:b2b3955cd77b | 20 | interface::interface(Serial* inputPC){ |
FiveDollar | 0:b2b3955cd77b | 21 | pc = inputPC; |
FiveDollar | 0:b2b3955cd77b | 22 | } |
FiveDollar | 0:b2b3955cd77b | 23 | |
FiveDollar | 9:b48423a135d8 | 24 | interface::interface(Serial* inputPC , pulse* p ,genData* genData, chamberData* atrium , chamberData* ventricle){ |
FiveDollar | 9:b48423a135d8 | 25 | generalData = genData; |
FiveDollar | 0:b2b3955cd77b | 26 | pc = inputPC; |
FiveDollar | 0:b2b3955cd77b | 27 | interfacePulse = p; |
FiveDollar | 0:b2b3955cd77b | 28 | atrData = atrium; |
FiveDollar | 0:b2b3955cd77b | 29 | ventData = ventricle; |
FiveDollar | 0:b2b3955cd77b | 30 | } |
FiveDollar | 0:b2b3955cd77b | 31 | //******************************************** |
FiveDollar | 0:b2b3955cd77b | 32 | |
FiveDollar | 0:b2b3955cd77b | 33 | |
FiveDollar | 0:b2b3955cd77b | 34 | //USER INTERFACE SCREENS************************** |
FiveDollar | 0:b2b3955cd77b | 35 | |
FiveDollar | 0:b2b3955cd77b | 36 | void interface::startScreen(){ |
trane3 | 19:d58e1e1a9a24 | 37 | |
trane3 | 19:d58e1e1a9a24 | 38 | pc->printf("\n ____ _ ____ _____ __ __ _ _ _______ ____ "); |
trane3 | 19:d58e1e1a9a24 | 39 | pc->printf("\n| _ \\ / \\ / ___| ____| \\/ | / \\ | |/ / ____| _ \\"); |
trane3 | 19:d58e1e1a9a24 | 40 | pc->printf("\n| |_) / _ \\| | | _| | |\\/| | / _ \\ | ' /| _| | |_) |"); |
trane3 | 19:d58e1e1a9a24 | 41 | pc->printf("\n| __/ ___ \\ |___| |___| | | |/ ___ \\| . \\| |___| _ <"); |
trane3 | 19:d58e1e1a9a24 | 42 | pc->printf("\n|_| /_/ \\_\\____|_____|_| |_/_/ \\_\\_|\\_\\_____|_| \\_\\"); |
trane3 | 19:d58e1e1a9a24 | 43 | |
trane3 | 19:d58e1e1a9a24 | 44 | |
trane3 | 19:d58e1e1a9a24 | 45 | pc->printf("\nWelcome to the PACEMAKER DCM.\n"); |
trane3 | 19:d58e1e1a9a24 | 46 | pc->printf("Options:\n"); |
trane3 | 19:d58e1e1a9a24 | 47 | pc->printf("1. Start VOOR Pulse\n"); // temporary test to get VOOR working |
trane3 | 19:d58e1e1a9a24 | 48 | pc->printf("2. View/Change data\n"); |
trane3 | 19:d58e1e1a9a24 | 49 | pc->printf("Please enter a command:"); |
FiveDollar | 0:b2b3955cd77b | 50 | char command = getChar(); |
FiveDollar | 0:b2b3955cd77b | 51 | switch (command) { |
trane3 | 8:75c1dd8b0d61 | 52 | case '1':{ |
trane3 | 19:d58e1e1a9a24 | 53 | |
trane3 | 19:d58e1e1a9a24 | 54 | voor v(interfacePulse, ventData); //creates new instance of voor |
trane3 | 8:75c1dd8b0d61 | 55 | v.startPace(); //starts pacing voor the same way as it used to pace in the user interface |
trane3 | 8:75c1dd8b0d61 | 56 | //interfacePulse->startPulse(); //problems with this method: you create the pc output twice, once in UI and once in pulse. |
FiveDollar | 0:b2b3955cd77b | 57 | startScreen(); //realistically we'll never need to call the serial output in pulse, it should all be done in UI |
FiveDollar | 0:b2b3955cd77b | 58 | break; |
trane3 | 8:75c1dd8b0d61 | 59 | } |
FiveDollar | 0:b2b3955cd77b | 60 | case '2': |
FiveDollar | 0:b2b3955cd77b | 61 | interface::dataScreen(); |
FiveDollar | 0:b2b3955cd77b | 62 | break; |
FiveDollar | 2:fbba2687ddfe | 63 | default: |
trane3 | 19:d58e1e1a9a24 | 64 | pc->printf("\nThat is not an option.\n"); |
FiveDollar | 2:fbba2687ddfe | 65 | interface::startScreen(); |
FiveDollar | 2:fbba2687ddfe | 66 | break; |
FiveDollar | 2:fbba2687ddfe | 67 | } |
FiveDollar | 0:b2b3955cd77b | 68 | } |
FiveDollar | 0:b2b3955cd77b | 69 | |
FiveDollar | 0:b2b3955cd77b | 70 | void interface::dataScreen(){ |
FiveDollar | 0:b2b3955cd77b | 71 | (*pc).printf("\nDCM Data sets:\n"); |
FiveDollar | 2:fbba2687ddfe | 72 | (*pc).printf("1. Atrium Data\n2. Ventricle Data\n3. General Data\n4. Egram Data\n5. Back to start page\n"); |
FiveDollar | 0:b2b3955cd77b | 73 | (*pc).printf("Choose a data set:"); |
FiveDollar | 0:b2b3955cd77b | 74 | char command = getChar(); |
FiveDollar | 0:b2b3955cd77b | 75 | switch (command) { |
FiveDollar | 0:b2b3955cd77b | 76 | case '1': |
trane3 | 19:d58e1e1a9a24 | 77 | interface::chamberDataScreen(atrData); |
FiveDollar | 0:b2b3955cd77b | 78 | case '2': |
trane3 | 19:d58e1e1a9a24 | 79 | interface::chamberDataScreen(ventData); |
FiveDollar | 0:b2b3955cd77b | 80 | case '3': |
trane3 | 19:d58e1e1a9a24 | 81 | interface::genDataScreen(); |
FiveDollar | 2:fbba2687ddfe | 82 | case '4': |
FiveDollar | 2:fbba2687ddfe | 83 | pc->printf("\nNot setup yet"); |
FiveDollar | 0:b2b3955cd77b | 84 | break; |
FiveDollar | 2:fbba2687ddfe | 85 | case '5': |
FiveDollar | 0:b2b3955cd77b | 86 | interface::startScreen(); |
FiveDollar | 0:b2b3955cd77b | 87 | default: |
trane3 | 19:d58e1e1a9a24 | 88 | pc->printf("\nThat is not an option.\n"); |
FiveDollar | 0:b2b3955cd77b | 89 | interface::dataScreen(); |
FiveDollar | 0:b2b3955cd77b | 90 | } |
FiveDollar | 0:b2b3955cd77b | 91 | } |
FiveDollar | 0:b2b3955cd77b | 92 | |
trane3 | 19:d58e1e1a9a24 | 93 | void interface::chamberDataScreen(chamberData* chamber){ |
FiveDollar | 20:bfd23a6845bb | 94 | if (chamber == atrData) |
FiveDollar | 20:bfd23a6845bb | 95 | pc->printf("\nAtrium Data"); |
FiveDollar | 20:bfd23a6845bb | 96 | |
FiveDollar | 20:bfd23a6845bb | 97 | if (chamber == ventData) |
FiveDollar | 20:bfd23a6845bb | 98 | pc->printf("\nVentricle Data"); |
FiveDollar | 20:bfd23a6845bb | 99 | |
FiveDollar | 20:bfd23a6845bb | 100 | pc->printf("\n1. Pace Amplitude: %f", chamber->getPaceAmp()*7); |
FiveDollar | 20:bfd23a6845bb | 101 | pc->printf("\n2. Pace Width: %f", chamber->getPaceWidth()); |
FiveDollar | 20:bfd23a6845bb | 102 | pc->printf("\n3. Refractory Period: %f", chamber->getRP()); |
FiveDollar | 20:bfd23a6845bb | 103 | pc->printf("\n4. Sensitivity: %f", chamber->getSensitivity()); |
FiveDollar | 20:bfd23a6845bb | 104 | pc->printf("\nChoose variable to be changed or 5 To return to Data Sets"); |
FiveDollar | 20:bfd23a6845bb | 105 | |
FiveDollar | 20:bfd23a6845bb | 106 | char command = getChar(); |
FiveDollar | 20:bfd23a6845bb | 107 | switch (command){ |
FiveDollar | 20:bfd23a6845bb | 108 | case '1': |
FiveDollar | 20:bfd23a6845bb | 109 | pc->printf("\nChoose New Value for the Pace Amplitude:"); |
FiveDollar | 20:bfd23a6845bb | 110 | char* value = getInput(); |
FiveDollar | 20:bfd23a6845bb | 111 | int valInRange = chamber->chngPaceAmp(atof(value)); |
FiveDollar | 20:bfd23a6845bb | 112 | if(valInRange == 1){ |
FiveDollar | 20:bfd23a6845bb | 113 | pc->printf("\t%f",chamber->getPaceAmp()*7); |
FiveDollar | 20:bfd23a6845bb | 114 | }else{ |
FiveDollar | 20:bfd23a6845bb | 115 | pc->printf("\nThat value is not within range."); |
FiveDollar | 20:bfd23a6845bb | 116 | } |
FiveDollar | 20:bfd23a6845bb | 117 | interface::dataScreen(); |
FiveDollar | 20:bfd23a6845bb | 118 | break; |
FiveDollar | 20:bfd23a6845bb | 119 | case '2': |
FiveDollar | 20:bfd23a6845bb | 120 | pc->printf("\nChoose New Value for the Pace Width:"); |
FiveDollar | 20:bfd23a6845bb | 121 | value = getInput(); |
FiveDollar | 20:bfd23a6845bb | 122 | valInRange = chamber->chngPaceWidth(atof(value)); |
FiveDollar | 20:bfd23a6845bb | 123 | if(valInRange == 1){ |
FiveDollar | 20:bfd23a6845bb | 124 | pc->printf("\t%f",chamber->getPaceWidth()); |
FiveDollar | 20:bfd23a6845bb | 125 | }else{ |
FiveDollar | 20:bfd23a6845bb | 126 | pc->printf("\nThat value is not within range."); |
FiveDollar | 20:bfd23a6845bb | 127 | } |
FiveDollar | 20:bfd23a6845bb | 128 | interface::dataScreen(); |
FiveDollar | 20:bfd23a6845bb | 129 | break; |
FiveDollar | 20:bfd23a6845bb | 130 | case '3': |
FiveDollar | 20:bfd23a6845bb | 131 | pc->printf("\nChoose New Value for the Refractory Period:"); |
FiveDollar | 20:bfd23a6845bb | 132 | value = getInput(); |
FiveDollar | 20:bfd23a6845bb | 133 | valInRange = chamber->chngRP(atof(value)); |
FiveDollar | 20:bfd23a6845bb | 134 | if(valInRange == 1){ |
FiveDollar | 20:bfd23a6845bb | 135 | pc->printf("\t%f",chamber->getRP()); |
FiveDollar | 20:bfd23a6845bb | 136 | }else{ |
FiveDollar | 20:bfd23a6845bb | 137 | pc->printf("\nThat value is not within range."); |
FiveDollar | 20:bfd23a6845bb | 138 | } |
FiveDollar | 20:bfd23a6845bb | 139 | interface::dataScreen(); |
FiveDollar | 20:bfd23a6845bb | 140 | break; |
FiveDollar | 20:bfd23a6845bb | 141 | case '4': |
FiveDollar | 20:bfd23a6845bb | 142 | pc->printf("\nChoose New Value for the Sensitivity:"); |
FiveDollar | 20:bfd23a6845bb | 143 | value = getInput(); |
FiveDollar | 20:bfd23a6845bb | 144 | valInRange = chamber->chngSensitivity(atof(value)); |
FiveDollar | 20:bfd23a6845bb | 145 | if(valInRange == 1){ |
FiveDollar | 20:bfd23a6845bb | 146 | pc->printf("\t%f",chamber->getSensitivity()); |
FiveDollar | 20:bfd23a6845bb | 147 | }else{ |
FiveDollar | 20:bfd23a6845bb | 148 | pc->printf("\nThat value is not within range."); |
FiveDollar | 20:bfd23a6845bb | 149 | } |
FiveDollar | 20:bfd23a6845bb | 150 | interface::dataScreen(); |
FiveDollar | 20:bfd23a6845bb | 151 | break; |
FiveDollar | 20:bfd23a6845bb | 152 | case '5': |
FiveDollar | 20:bfd23a6845bb | 153 | interface::dataScreen(); |
FiveDollar | 20:bfd23a6845bb | 154 | break; |
FiveDollar | 20:bfd23a6845bb | 155 | default: |
FiveDollar | 20:bfd23a6845bb | 156 | pc->printf("\nThat is not an option."); |
FiveDollar | 20:bfd23a6845bb | 157 | interface::chamberDataScreen(chamber); |
FiveDollar | 20:bfd23a6845bb | 158 | break; |
FiveDollar | 20:bfd23a6845bb | 159 | } |
trane3 | 19:d58e1e1a9a24 | 160 | } |
trane3 | 19:d58e1e1a9a24 | 161 | |
trane3 | 19:d58e1e1a9a24 | 162 | void interface::genDataScreen(){ //moved option 3 from dataScreen() into its own method |
trane3 | 19:d58e1e1a9a24 | 163 | pc->printf("\nGeneral Data"); |
trane3 | 19:d58e1e1a9a24 | 164 | pc->printf("\n1. Hysteresis: %s", generalData->getHyst() ? "true" : "false"); |
FiveDollar | 20:bfd23a6845bb | 165 | pc->printf("\n2. Hysteresis Rate Limit: %f", generalData->getHystRL()); |
trane3 | 19:d58e1e1a9a24 | 166 | pc->printf("\n3. Lower Rate Limit: %f", generalData->getLRL()); |
trane3 | 19:d58e1e1a9a24 | 167 | pc->printf("\n4. Upper Rate Limit: %f", generalData->getURL()); |
trane3 | 19:d58e1e1a9a24 | 168 | pc->printf("\n5. Atrial-Ventricular Delay: %f", generalData->getAVdelay()); |
trane3 | 19:d58e1e1a9a24 | 169 | pc->printf("\n6. Atrial-Ventricular Delay Offset: %f" , generalData->getAVdelayOffset()); |
trane3 | 19:d58e1e1a9a24 | 170 | pc->printf("\n7. Rate Smoothing: %f", generalData->getRSmooth()); |
trane3 | 19:d58e1e1a9a24 | 171 | pc->printf("\nChoose variable to be changed or 5 To return to Data Sets"); |
trane3 | 19:d58e1e1a9a24 | 172 | char command = getChar(); |
trane3 | 19:d58e1e1a9a24 | 173 | switch (command) { |
trane3 | 19:d58e1e1a9a24 | 174 | case '1': |
FiveDollar | 20:bfd23a6845bb | 175 | pc->printf("\nSet Hysteresis (t for true, f for false):"); |
FiveDollar | 20:bfd23a6845bb | 176 | char* value = getInput(); |
FiveDollar | 20:bfd23a6845bb | 177 | if(*value == 't'){ |
FiveDollar | 20:bfd23a6845bb | 178 | generalData->chngHyst(true); |
FiveDollar | 20:bfd23a6845bb | 179 | }else if(*value == 'f'){ |
FiveDollar | 20:bfd23a6845bb | 180 | generalData->chngHyst(false); |
FiveDollar | 20:bfd23a6845bb | 181 | }else{ |
FiveDollar | 20:bfd23a6845bb | 182 | pc->printf("You may only enter 't' or 'f'."); |
FiveDollar | 20:bfd23a6845bb | 183 | } |
FiveDollar | 20:bfd23a6845bb | 184 | pc->printf("%s", generalData->getHyst() ? "true" : "false"); |
trane3 | 19:d58e1e1a9a24 | 185 | interface::genDataScreen(); |
trane3 | 19:d58e1e1a9a24 | 186 | break; |
trane3 | 19:d58e1e1a9a24 | 187 | case '2': |
FiveDollar | 20:bfd23a6845bb | 188 | pc->printf("\nChoose New Value for Hysteresis Rate Limit:"); |
FiveDollar | 20:bfd23a6845bb | 189 | value = getInput(); |
FiveDollar | 20:bfd23a6845bb | 190 | int valInRange = generalData->chngHystRL(atof(value)); |
FiveDollar | 20:bfd23a6845bb | 191 | if(valInRange == 1){ |
FiveDollar | 20:bfd23a6845bb | 192 | pc->printf("\t%f",generalData->getHystRL()); |
FiveDollar | 20:bfd23a6845bb | 193 | }else{ |
FiveDollar | 20:bfd23a6845bb | 194 | pc->printf("\nThat value is not within range."); |
FiveDollar | 20:bfd23a6845bb | 195 | } |
trane3 | 19:d58e1e1a9a24 | 196 | interface::genDataScreen(); |
trane3 | 19:d58e1e1a9a24 | 197 | break; |
trane3 | 19:d58e1e1a9a24 | 198 | case '3': |
FiveDollar | 20:bfd23a6845bb | 199 | pc->printf("\nChoose New Value for the Lower Rate Limit:"); |
FiveDollar | 20:bfd23a6845bb | 200 | value = getInput(); |
FiveDollar | 20:bfd23a6845bb | 201 | valInRange = generalData->chngLRL(atof(value)); |
FiveDollar | 20:bfd23a6845bb | 202 | if(valInRange == 1){ |
FiveDollar | 20:bfd23a6845bb | 203 | pc->printf("\t%f",generalData->getLRL()); |
FiveDollar | 20:bfd23a6845bb | 204 | }else{ |
FiveDollar | 20:bfd23a6845bb | 205 | pc->printf("\nThat value is not within range."); |
FiveDollar | 20:bfd23a6845bb | 206 | } |
trane3 | 19:d58e1e1a9a24 | 207 | interface::genDataScreen(); |
FiveDollar | 20:bfd23a6845bb | 208 | break; |
trane3 | 19:d58e1e1a9a24 | 209 | case '4': |
FiveDollar | 20:bfd23a6845bb | 210 | pc->printf("\nChoose New Value for the Upper Rate Limit:"); |
FiveDollar | 20:bfd23a6845bb | 211 | value = getInput(); |
FiveDollar | 20:bfd23a6845bb | 212 | valInRange = generalData->chngURL(atof(value)); |
FiveDollar | 20:bfd23a6845bb | 213 | if(valInRange == 1){ |
FiveDollar | 20:bfd23a6845bb | 214 | pc->printf("\t%f",generalData->getURL()); |
FiveDollar | 20:bfd23a6845bb | 215 | }else{ |
FiveDollar | 20:bfd23a6845bb | 216 | pc->printf("\nThat value is not within range."); |
FiveDollar | 20:bfd23a6845bb | 217 | } |
trane3 | 19:d58e1e1a9a24 | 218 | interface::genDataScreen(); |
trane3 | 19:d58e1e1a9a24 | 219 | break; |
trane3 | 19:d58e1e1a9a24 | 220 | case '5': |
FiveDollar | 20:bfd23a6845bb | 221 | pc->printf("\nChoose New Value for the Atrial-Ventricular Delay:"); |
FiveDollar | 20:bfd23a6845bb | 222 | value = getInput(); |
FiveDollar | 20:bfd23a6845bb | 223 | valInRange = generalData->chngAVdelay(atof(value)); |
FiveDollar | 20:bfd23a6845bb | 224 | if(valInRange == 1){ |
FiveDollar | 20:bfd23a6845bb | 225 | pc->printf("\t%f",generalData->getAVdelay()); |
FiveDollar | 20:bfd23a6845bb | 226 | }else{ |
FiveDollar | 20:bfd23a6845bb | 227 | pc->printf("\nThat value is not within range."); |
FiveDollar | 20:bfd23a6845bb | 228 | } |
FiveDollar | 20:bfd23a6845bb | 229 | interface::genDataScreen(); |
FiveDollar | 20:bfd23a6845bb | 230 | break; |
FiveDollar | 20:bfd23a6845bb | 231 | case '6': |
FiveDollar | 20:bfd23a6845bb | 232 | pc->printf("\nChoose New Value for the Atrial-Ventricular Delay Offset:"); |
FiveDollar | 20:bfd23a6845bb | 233 | value = getInput(); |
FiveDollar | 20:bfd23a6845bb | 234 | valInRange = generalData->chngAVdelayOffset(atof(value)); |
FiveDollar | 20:bfd23a6845bb | 235 | if(valInRange == 1){ |
FiveDollar | 20:bfd23a6845bb | 236 | pc->printf("\t%f",generalData->getAVdelayOffset()); |
FiveDollar | 20:bfd23a6845bb | 237 | }else{ |
FiveDollar | 20:bfd23a6845bb | 238 | pc->printf("\nThat value is not within range."); |
FiveDollar | 20:bfd23a6845bb | 239 | } |
FiveDollar | 20:bfd23a6845bb | 240 | interface::genDataScreen(); |
FiveDollar | 20:bfd23a6845bb | 241 | break; |
FiveDollar | 20:bfd23a6845bb | 242 | case '7': |
FiveDollar | 20:bfd23a6845bb | 243 | pc->printf("\nChoose New Value for the Rate Smoothing:"); |
FiveDollar | 20:bfd23a6845bb | 244 | value = getInput(); |
FiveDollar | 20:bfd23a6845bb | 245 | valInRange = generalData->chngRSmooth(atof(value)); |
FiveDollar | 20:bfd23a6845bb | 246 | if(valInRange == 1){ |
FiveDollar | 20:bfd23a6845bb | 247 | pc->printf("\t%f",generalData->getRSmooth()); |
FiveDollar | 20:bfd23a6845bb | 248 | }else{ |
FiveDollar | 20:bfd23a6845bb | 249 | pc->printf("\nThat value is not within range."); |
FiveDollar | 20:bfd23a6845bb | 250 | } |
FiveDollar | 20:bfd23a6845bb | 251 | interface::genDataScreen(); |
FiveDollar | 20:bfd23a6845bb | 252 | break; |
trane3 | 19:d58e1e1a9a24 | 253 | default: |
trane3 | 19:d58e1e1a9a24 | 254 | pc->printf("\nThat is not an option.\n"); |
trane3 | 19:d58e1e1a9a24 | 255 | interface::genDataScreen(); |
FiveDollar | 20:bfd23a6845bb | 256 | break; |
trane3 | 19:d58e1e1a9a24 | 257 | } |
trane3 | 19:d58e1e1a9a24 | 258 | } |
trane3 | 19:d58e1e1a9a24 | 259 | |
FiveDollar | 0:b2b3955cd77b | 260 | void interface::getData(chamberData* chamber){ |
FiveDollar | 0:b2b3955cd77b | 261 | char command = getChar(); |
FiveDollar | 0:b2b3955cd77b | 262 | switch (command){ |
FiveDollar | 0:b2b3955cd77b | 263 | case '1': |
FiveDollar | 2:fbba2687ddfe | 264 | pc->printf("\nChoose New Value:"); |
FiveDollar | 0:b2b3955cd77b | 265 | char* value = getInput(); |
FiveDollar | 0:b2b3955cd77b | 266 | chamber->chngPaceAmp(atof(value)); |
FiveDollar | 0:b2b3955cd77b | 267 | pc->printf("\t%f",chamber->getPaceAmp()*7); |
FiveDollar | 0:b2b3955cd77b | 268 | interface::dataScreen(); |
FiveDollar | 0:b2b3955cd77b | 269 | break; |
FiveDollar | 0:b2b3955cd77b | 270 | case '2': |
FiveDollar | 2:fbba2687ddfe | 271 | pc->printf("\nChoose New Value:"); |
FiveDollar | 0:b2b3955cd77b | 272 | value = getInput(); |
FiveDollar | 0:b2b3955cd77b | 273 | chamber->chngPaceWidth(atof(value)); |
FiveDollar | 0:b2b3955cd77b | 274 | pc->printf("\t%f",chamber->getPaceWidth()); |
FiveDollar | 0:b2b3955cd77b | 275 | interface::dataScreen(); |
FiveDollar | 0:b2b3955cd77b | 276 | break; |
FiveDollar | 0:b2b3955cd77b | 277 | case '3': |
FiveDollar | 2:fbba2687ddfe | 278 | pc->printf("\nChoose New Value:"); |
FiveDollar | 0:b2b3955cd77b | 279 | value = getInput(); |
FiveDollar | 0:b2b3955cd77b | 280 | chamber->chngRP(atof(value)); |
FiveDollar | 0:b2b3955cd77b | 281 | pc->printf("\t%f",chamber->getRP()); |
FiveDollar | 0:b2b3955cd77b | 282 | interface::dataScreen(); |
FiveDollar | 0:b2b3955cd77b | 283 | break; |
FiveDollar | 0:b2b3955cd77b | 284 | case '4': |
FiveDollar | 2:fbba2687ddfe | 285 | pc->printf("\nChoose New Value:"); |
FiveDollar | 0:b2b3955cd77b | 286 | value = getInput(); |
FiveDollar | 0:b2b3955cd77b | 287 | chamber->chngSensitivity(atof(value)); |
FiveDollar | 0:b2b3955cd77b | 288 | pc->printf("\t%f",chamber->getSensitivity()); |
FiveDollar | 0:b2b3955cd77b | 289 | interface::dataScreen(); |
FiveDollar | 0:b2b3955cd77b | 290 | break; |
FiveDollar | 0:b2b3955cd77b | 291 | case '5': |
FiveDollar | 0:b2b3955cd77b | 292 | interface::dataScreen(); |
FiveDollar | 0:b2b3955cd77b | 293 | break; |
FiveDollar | 0:b2b3955cd77b | 294 | default: |
FiveDollar | 0:b2b3955cd77b | 295 | pc->printf("\nThat is not an option."); |
FiveDollar | 0:b2b3955cd77b | 296 | interface::getData(chamber); |
FiveDollar | 0:b2b3955cd77b | 297 | } |
FiveDollar | 0:b2b3955cd77b | 298 | } |
FiveDollar | 0:b2b3955cd77b | 299 | char* interface::getInput(){ |
FiveDollar | 0:b2b3955cd77b | 300 | char buffer[5]; |
FiveDollar | 0:b2b3955cd77b | 301 | fgets (buffer,5,stdin); |
FiveDollar | 0:b2b3955cd77b | 302 | return buffer; |
FiveDollar | 0:b2b3955cd77b | 303 | } |
FiveDollar | 0:b2b3955cd77b | 304 | |
FiveDollar | 0:b2b3955cd77b | 305 | char interface::getChar(){ |
FiveDollar | 0:b2b3955cd77b | 306 | while(true){ |
FiveDollar | 0:b2b3955cd77b | 307 | if(pc->readable()){ |
FiveDollar | 0:b2b3955cd77b | 308 | char command = pc->getc(); |
FiveDollar | 0:b2b3955cd77b | 309 | return command; |
FiveDollar | 0:b2b3955cd77b | 310 | } |
FiveDollar | 0:b2b3955cd77b | 311 | } |
FiveDollar | 0:b2b3955cd77b | 312 | } |
FiveDollar | 0:b2b3955cd77b | 313 | //**************************** |
FiveDollar | 0:b2b3955cd77b | 314 | |
FiveDollar | 0:b2b3955cd77b | 315 | //void interface::getAPulse(){ //TODO get this to work, the wait command has issues, see pulse.cpp . wait takes in seconds as argument |
FiveDollar | 0:b2b3955cd77b | 316 | // pulse myPulse(*atr); |
FiveDollar | 0:b2b3955cd77b | 317 | // myPulse.setWidth(1); |
FiveDollar | 0:b2b3955cd77b | 318 | // myPulse.startPulse(); |
FiveDollar | 0:b2b3955cd77b | 319 | // } |
FiveDollar | 0:b2b3955cd77b | 320 | |
FiveDollar | 0:b2b3955cd77b | 321 | //void interface::LEDon(AnalogOut* out){ |
FiveDollar | 0:b2b3955cd77b | 322 | // (*out) = 0; |
FiveDollar | 0:b2b3955cd77b | 323 | //// (*pc).printf(led); |
FiveDollar | 0:b2b3955cd77b | 324 | //} |
FiveDollar | 0:b2b3955cd77b | 325 | // |
FiveDollar | 0:b2b3955cd77b | 326 | //void interface::LEDoff(AnalogOut* out){ |
FiveDollar | 0:b2b3955cd77b | 327 | // (*out) = 1; |
FiveDollar | 0:b2b3955cd77b | 328 | //} |