Pacemaker code Implementation for SFWRENG 3K04

Dependencies:   mbed Queue mbed-rtos FXOS8700Q

Fork of Pacemaker by Eric dollar

SWFRENG 3K04 Project to design, develop, and document a functional pacemaker.

The project uses the Freescale K64F Microcontroller and C++ mbed library.

Committer:
trane3
Date:
Tue Nov 29 21:07:56 2016 +0000
Revision:
30:cc7586a259fd
Parent:
26:3b49e8c3793f
temp changes (eric)

Who changed what in which revision?

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