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