hack gt final code
Dependencies: 4DGL-uLCD-SE BMP085 PinDetect SDFileSystem mbed wave_player
main_old.cpp@14:23390a020d1c, 2016-09-28 (annotated)
- Committer:
- otis22894
- Date:
- Wed Sep 28 00:16:16 2016 +0000
- Revision:
- 14:23390a020d1c
initial commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
otis22894 | 14:23390a020d1c | 1 | #include "mbed.h" |
otis22894 | 14:23390a020d1c | 2 | #include "SDFileSystem.h" |
otis22894 | 14:23390a020d1c | 3 | #include "wave_player.h" |
otis22894 | 14:23390a020d1c | 4 | //#include "uLCD_4DGL.h" |
otis22894 | 14:23390a020d1c | 5 | #include "PinDetect.h" |
otis22894 | 14:23390a020d1c | 6 | #include "Heart.h" |
otis22894 | 14:23390a020d1c | 7 | #include "statistics.h" |
otis22894 | 14:23390a020d1c | 8 | #include "spikes.h" |
otis22894 | 14:23390a020d1c | 9 | #include "BMP085.h" |
otis22894 | 14:23390a020d1c | 10 | #include <string> |
otis22894 | 14:23390a020d1c | 11 | #include <sstream> |
otis22894 | 14:23390a020d1c | 12 | |
otis22894 | 14:23390a020d1c | 13 | using namespace std; |
otis22894 | 14:23390a020d1c | 14 | |
otis22894 | 14:23390a020d1c | 15 | #define SHORT_SAMPLE 5 |
otis22894 | 14:23390a020d1c | 16 | #define LONG_SAMPLE 20 |
otis22894 | 14:23390a020d1c | 17 | |
otis22894 | 14:23390a020d1c | 18 | #define BEGIN_COMPRESSIONS "begin30ChestCompressions" |
otis22894 | 14:23390a020d1c | 19 | #define BREATH_TONE "breathTone" |
otis22894 | 14:23390a020d1c | 20 | #define CLIP_SENSOR "clipPulseSensorToEar" |
otis22894 | 14:23390a020d1c | 21 | #define CONTINUE_COMPRESSIONS "continueChestCompressions" |
otis22894 | 14:23390a020d1c | 22 | #define PLACE_MASK "placeMaskOverVictimsMouthWithTheSharpestCornerOverTheNose" |
otis22894 | 14:23390a020d1c | 23 | #define PREPARE_BREATH "prepareToBreatheIntoMask" |
otis22894 | 14:23390a020d1c | 24 | #define ROLL_VICTIM "rollVictimOntoSide" |
otis22894 | 14:23390a020d1c | 25 | #define START_BREATHING "startBreathing" |
otis22894 | 14:23390a020d1c | 26 | #define STOP_COMPRESSIONS "stopChestCompressions" |
otis22894 | 14:23390a020d1c | 27 | #define TILT_HEAD "tiltHeadBackFor10Seconds" |
otis22894 | 14:23390a020d1c | 28 | #define MONITOR_CONDITION "monitorVictimConditionAndReturnMaskToFaceIfBreathingStops" |
otis22894 | 14:23390a020d1c | 29 | #define RETILT_HEAD "retiltHeadByPushingChinAwayFromChest" |
otis22894 | 14:23390a020d1c | 30 | #define NEXT_KEY "pressNextKeyWhenReady" |
otis22894 | 14:23390a020d1c | 31 | #define NEXT_REMINDER "pleasePressNextKeyToContinueOrPressRepeatToHearTheLastCommand" |
otis22894 | 14:23390a020d1c | 32 | #define CHEST_COMPRESSIONS "prepareForChestCompressions" |
otis22894 | 14:23390a020d1c | 33 | #define REMOVE_MASK "removeTheMaskAndCheckTheAirway" |
otis22894 | 14:23390a020d1c | 34 | #define REMOVE_OBJECT "removeObject" |
otis22894 | 14:23390a020d1c | 35 | #define REPLACE_MASK "replaceMaskOnVictimsFace" |
otis22894 | 14:23390a020d1c | 36 | #define COUNT "count" |
otis22894 | 14:23390a020d1c | 37 | string lastMessage; |
otis22894 | 14:23390a020d1c | 38 | |
otis22894 | 14:23390a020d1c | 39 | SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card |
otis22894 | 14:23390a020d1c | 40 | AnalogOut DACout(p18); |
otis22894 | 14:23390a020d1c | 41 | wave_player waver(&DACout); |
otis22894 | 14:23390a020d1c | 42 | AnalogIn windSensor(p17); |
otis22894 | 14:23390a020d1c | 43 | PinDetect repeatButton(p14); |
otis22894 | 14:23390a020d1c | 44 | PinDetect nextButton(p13); |
otis22894 | 14:23390a020d1c | 45 | Timer timer; |
otis22894 | 14:23390a020d1c | 46 | Heart heart = Heart(); |
otis22894 | 14:23390a020d1c | 47 | BMP085 barometer(p9, p10); |
otis22894 | 14:23390a020d1c | 48 | Ticker ticker; |
otis22894 | 14:23390a020d1c | 49 | SpikeFinder s = SpikeFinder(4, 4, 4.0); |
otis22894 | 14:23390a020d1c | 50 | DigitalOut GLED1(p26); |
otis22894 | 14:23390a020d1c | 51 | DigitalOut GLED2(p25); |
otis22894 | 14:23390a020d1c | 52 | DigitalOut GLED3(p24); |
otis22894 | 14:23390a020d1c | 53 | DigitalOut RLED1(p23); |
otis22894 | 14:23390a020d1c | 54 | DigitalOut RLED2(p22); |
otis22894 | 14:23390a020d1c | 55 | DigitalOut RLED3(p21); |
otis22894 | 14:23390a020d1c | 56 | DigitalOut testLED(LED1); |
otis22894 | 14:23390a020d1c | 57 | float windSensorVoltage; |
otis22894 | 14:23390a020d1c | 58 | bool breathing; |
otis22894 | 14:23390a020d1c | 59 | bool pulse; |
otis22894 | 14:23390a020d1c | 60 | bool breath_success = true; |
otis22894 | 14:23390a020d1c | 61 | ostringstream stream; |
otis22894 | 14:23390a020d1c | 62 | Timer breathTimer; |
otis22894 | 14:23390a020d1c | 63 | bool next = false; |
otis22894 | 14:23390a020d1c | 64 | bool adult = true; |
otis22894 | 14:23390a020d1c | 65 | int cycleCount = 0; |
otis22894 | 14:23390a020d1c | 66 | Ticker LEDTicker; |
otis22894 | 14:23390a020d1c | 67 | |
otis22894 | 14:23390a020d1c | 68 | void playMessage(string messageName); |
otis22894 | 14:23390a020d1c | 69 | void getBreathing(); |
otis22894 | 14:23390a020d1c | 70 | void getPulse(); |
otis22894 | 14:23390a020d1c | 71 | void getVitals(); |
otis22894 | 14:23390a020d1c | 72 | bool checkBreath(); |
otis22894 | 14:23390a020d1c | 73 | void promptBreaths(int amt,bool check); |
otis22894 | 14:23390a020d1c | 74 | void chestCompressions(); |
otis22894 | 14:23390a020d1c | 75 | void CPR(); |
otis22894 | 14:23390a020d1c | 76 | void rescueBreathing(); |
otis22894 | 14:23390a020d1c | 77 | void auditVitals(); |
otis22894 | 14:23390a020d1c | 78 | void unconsciousChocking(); |
otis22894 | 14:23390a020d1c | 79 | void repeat_callback_function (void); |
otis22894 | 14:23390a020d1c | 80 | void next_callback_function (void); |
otis22894 | 14:23390a020d1c | 81 | void waitForNext(); |
otis22894 | 14:23390a020d1c | 82 | void tick(); |
otis22894 | 14:23390a020d1c | 83 | void welcomeLED(); |
otis22894 | 14:23390a020d1c | 84 | void cycleLEDs(); |
otis22894 | 14:23390a020d1c | 85 | |
otis22894 | 14:23390a020d1c | 86 | int main(){ |
otis22894 | 14:23390a020d1c | 87 | repeatButton.mode(PullUp); |
otis22894 | 14:23390a020d1c | 88 | nextButton.mode(PullUp); |
otis22894 | 14:23390a020d1c | 89 | wait(1); |
otis22894 | 14:23390a020d1c | 90 | repeatButton.attach_deasserted(&repeat_callback_function); |
otis22894 | 14:23390a020d1c | 91 | nextButton.attach_deasserted(&next_callback_function); |
otis22894 | 14:23390a020d1c | 92 | repeatButton.setSampleFrequency(); |
otis22894 | 14:23390a020d1c | 93 | nextButton.setSampleFrequency(); |
otis22894 | 14:23390a020d1c | 94 | wait(1); |
otis22894 | 14:23390a020d1c | 95 | |
otis22894 | 14:23390a020d1c | 96 | /*while(1){ |
otis22894 | 14:23390a020d1c | 97 | printf("HERE"); |
otis22894 | 14:23390a020d1c | 98 | waitForNext(); |
otis22894 | 14:23390a020d1c | 99 | checkBreath(); |
otis22894 | 14:23390a020d1c | 100 | wait(0.5); |
otis22894 | 14:23390a020d1c | 101 | }*/ |
otis22894 | 14:23390a020d1c | 102 | |
otis22894 | 14:23390a020d1c | 103 | welcomeLED(); |
otis22894 | 14:23390a020d1c | 104 | testLED = 1; |
otis22894 | 14:23390a020d1c | 105 | wait(3); |
otis22894 | 14:23390a020d1c | 106 | playMessage(PLACE_MASK); |
otis22894 | 14:23390a020d1c | 107 | testLED = 0; |
otis22894 | 14:23390a020d1c | 108 | wait(3); |
otis22894 | 14:23390a020d1c | 109 | waitForNext(); |
otis22894 | 14:23390a020d1c | 110 | playMessage(CLIP_SENSOR); |
otis22894 | 14:23390a020d1c | 111 | waitForNext(); |
otis22894 | 14:23390a020d1c | 112 | playMessage(TILT_HEAD); |
otis22894 | 14:23390a020d1c | 113 | waitForNext(); |
otis22894 | 14:23390a020d1c | 114 | getVitals(); |
otis22894 | 14:23390a020d1c | 115 | |
otis22894 | 14:23390a020d1c | 116 | if(pulse){ |
otis22894 | 14:23390a020d1c | 117 | playMessage(ROLL_VICTIM); |
otis22894 | 14:23390a020d1c | 118 | while(1){ |
otis22894 | 14:23390a020d1c | 119 | playMessage(MONITOR_CONDITION); |
otis22894 | 14:23390a020d1c | 120 | wait(5); |
otis22894 | 14:23390a020d1c | 121 | } |
otis22894 | 14:23390a020d1c | 122 | } |
otis22894 | 14:23390a020d1c | 123 | |
otis22894 | 14:23390a020d1c | 124 | promptBreaths(2,true); |
otis22894 | 14:23390a020d1c | 125 | if(breath_success){ |
otis22894 | 14:23390a020d1c | 126 | auditVitals(); |
otis22894 | 14:23390a020d1c | 127 | }else{ |
otis22894 | 14:23390a020d1c | 128 | playMessage(RETILT_HEAD); |
otis22894 | 14:23390a020d1c | 129 | waitForNext(); |
otis22894 | 14:23390a020d1c | 130 | promptBreaths(1,true); |
otis22894 | 14:23390a020d1c | 131 | if(breath_success){ |
otis22894 | 14:23390a020d1c | 132 | auditVitals(); |
otis22894 | 14:23390a020d1c | 133 | }else{ |
otis22894 | 14:23390a020d1c | 134 | unconsciousChocking(); |
otis22894 | 14:23390a020d1c | 135 | } |
otis22894 | 14:23390a020d1c | 136 | } |
otis22894 | 14:23390a020d1c | 137 | } |
otis22894 | 14:23390a020d1c | 138 | |
otis22894 | 14:23390a020d1c | 139 | void repeat_callback_function (void){ |
otis22894 | 14:23390a020d1c | 140 | playMessage(lastMessage); |
otis22894 | 14:23390a020d1c | 141 | } |
otis22894 | 14:23390a020d1c | 142 | |
otis22894 | 14:23390a020d1c | 143 | void next_callback_function (void){ |
otis22894 | 14:23390a020d1c | 144 | next = true; |
otis22894 | 14:23390a020d1c | 145 | } |
otis22894 | 14:23390a020d1c | 146 | |
otis22894 | 14:23390a020d1c | 147 | void tick() { |
otis22894 | 14:23390a020d1c | 148 | __disable_irq(); |
otis22894 | 14:23390a020d1c | 149 | barometer.update(); |
otis22894 | 14:23390a020d1c | 150 | s.addSample(barometer.get_pressure()); |
otis22894 | 14:23390a020d1c | 151 | __enable_irq(); |
otis22894 | 14:23390a020d1c | 152 | } |
otis22894 | 14:23390a020d1c | 153 | |
otis22894 | 14:23390a020d1c | 154 | void waitForNext(){ |
otis22894 | 14:23390a020d1c | 155 | playMessage(NEXT_KEY); |
otis22894 | 14:23390a020d1c | 156 | timer.start(); |
otis22894 | 14:23390a020d1c | 157 | while(!next){ |
otis22894 | 14:23390a020d1c | 158 | if(timer.read()>3){ |
otis22894 | 14:23390a020d1c | 159 | playMessage(NEXT_REMINDER); |
otis22894 | 14:23390a020d1c | 160 | timer.reset(); |
otis22894 | 14:23390a020d1c | 161 | } |
otis22894 | 14:23390a020d1c | 162 | } |
otis22894 | 14:23390a020d1c | 163 | timer.stop(); |
otis22894 | 14:23390a020d1c | 164 | timer.reset(); |
otis22894 | 14:23390a020d1c | 165 | next = false; |
otis22894 | 14:23390a020d1c | 166 | } |
otis22894 | 14:23390a020d1c | 167 | |
otis22894 | 14:23390a020d1c | 168 | void playMessage(string messageName){ |
otis22894 | 14:23390a020d1c | 169 | string pathName = "/sd/" + messageName + ".wav"; |
otis22894 | 14:23390a020d1c | 170 | char * cstrName = new char[pathName.length() + 1]; |
otis22894 | 14:23390a020d1c | 171 | cstrName[pathName.length()]=0; |
otis22894 | 14:23390a020d1c | 172 | memcpy(cstrName,pathName.c_str(),pathName.size()); |
otis22894 | 14:23390a020d1c | 173 | FILE *wave_file; |
otis22894 | 14:23390a020d1c | 174 | wave_file=fopen(cstrName,"r"); |
otis22894 | 14:23390a020d1c | 175 | waver.play(wave_file); |
otis22894 | 14:23390a020d1c | 176 | fclose(wave_file); |
otis22894 | 14:23390a020d1c | 177 | wait(1); |
otis22894 | 14:23390a020d1c | 178 | if(messageName.compare(NEXT_REMINDER) != 0 |
otis22894 | 14:23390a020d1c | 179 | && messageName.compare(NEXT_KEY) != 0){ |
otis22894 | 14:23390a020d1c | 180 | lastMessage = messageName; |
otis22894 | 14:23390a020d1c | 181 | } |
otis22894 | 14:23390a020d1c | 182 | } |
otis22894 | 14:23390a020d1c | 183 | |
otis22894 | 14:23390a020d1c | 184 | void getBreathing(){ |
otis22894 | 14:23390a020d1c | 185 | //SENSOR DATA |
otis22894 | 14:23390a020d1c | 186 | breathing = false; |
otis22894 | 14:23390a020d1c | 187 | } |
otis22894 | 14:23390a020d1c | 188 | |
otis22894 | 14:23390a020d1c | 189 | void getPulse(){ |
otis22894 | 14:23390a020d1c | 190 | pulse = heart.beatDetected(); |
otis22894 | 14:23390a020d1c | 191 | } |
otis22894 | 14:23390a020d1c | 192 | |
otis22894 | 14:23390a020d1c | 193 | void getVitals(){ |
otis22894 | 14:23390a020d1c | 194 | timer.start(); |
otis22894 | 14:23390a020d1c | 195 | heart.startReading(); |
otis22894 | 14:23390a020d1c | 196 | while(timer.read()<10){} |
otis22894 | 14:23390a020d1c | 197 | heart.stopReading(); |
otis22894 | 14:23390a020d1c | 198 | |
otis22894 | 14:23390a020d1c | 199 | getBreathing(); |
otis22894 | 14:23390a020d1c | 200 | getPulse(); |
otis22894 | 14:23390a020d1c | 201 | |
otis22894 | 14:23390a020d1c | 202 | timer.stop(); |
otis22894 | 14:23390a020d1c | 203 | timer.reset(); |
otis22894 | 14:23390a020d1c | 204 | heart.reset(); |
otis22894 | 14:23390a020d1c | 205 | } |
otis22894 | 14:23390a020d1c | 206 | |
otis22894 | 14:23390a020d1c | 207 | bool checkBreath(){ |
otis22894 | 14:23390a020d1c | 208 | windSensorVoltage = 0; |
otis22894 | 14:23390a020d1c | 209 | ticker.attach(&tick, .1); |
otis22894 | 14:23390a020d1c | 210 | while(windSensorVoltage<6.15){ |
otis22894 | 14:23390a020d1c | 211 | while(windSensorVoltage<6.15){ |
otis22894 | 14:23390a020d1c | 212 | wait(0.1); |
otis22894 | 14:23390a020d1c | 213 | windSensorVoltage = windSensor*10; |
otis22894 | 14:23390a020d1c | 214 | printf("%f",windSensorVoltage); |
otis22894 | 14:23390a020d1c | 215 | //THINK OF ANOTHER WAY THAT DOESN'T INVOLVE A SECOND WHILE LOOP |
otis22894 | 14:23390a020d1c | 216 | } |
otis22894 | 14:23390a020d1c | 217 | windSensorVoltage = windSensor*10; |
otis22894 | 14:23390a020d1c | 218 | wait(0.5); |
otis22894 | 14:23390a020d1c | 219 | } |
otis22894 | 14:23390a020d1c | 220 | //uLCD.printf("BREATH DETECTED"); |
otis22894 | 14:23390a020d1c | 221 | cycleLEDs(); |
otis22894 | 14:23390a020d1c | 222 | LEDTicker.attach(&cycleLEDs,0.116); |
otis22894 | 14:23390a020d1c | 223 | cycleLEDs(); |
otis22894 | 14:23390a020d1c | 224 | playMessage(BREATH_TONE); |
otis22894 | 14:23390a020d1c | 225 | LEDTicker.detach(); |
otis22894 | 14:23390a020d1c | 226 | ticker.detach(); |
otis22894 | 14:23390a020d1c | 227 | while(windSensorVoltage>6.15){ |
otis22894 | 14:23390a020d1c | 228 | windSensorVoltage = windSensor*10; |
otis22894 | 14:23390a020d1c | 229 | } |
otis22894 | 14:23390a020d1c | 230 | if(s.highSpikeFound()){ |
otis22894 | 14:23390a020d1c | 231 | s.reset(); |
otis22894 | 14:23390a020d1c | 232 | return false; |
otis22894 | 14:23390a020d1c | 233 | }else{ |
otis22894 | 14:23390a020d1c | 234 | s.reset(); |
otis22894 | 14:23390a020d1c | 235 | return true; |
otis22894 | 14:23390a020d1c | 236 | } |
otis22894 | 14:23390a020d1c | 237 | } |
otis22894 | 14:23390a020d1c | 238 | |
otis22894 | 14:23390a020d1c | 239 | void promptBreaths(int amt,bool check){ |
otis22894 | 14:23390a020d1c | 240 | bool local_check;; |
otis22894 | 14:23390a020d1c | 241 | for(int i = 0;i<amt;i++){ |
otis22894 | 14:23390a020d1c | 242 | playMessage(PREPARE_BREATH); |
otis22894 | 14:23390a020d1c | 243 | if(check){ |
otis22894 | 14:23390a020d1c | 244 | waitForNext(); |
otis22894 | 14:23390a020d1c | 245 | } |
otis22894 | 14:23390a020d1c | 246 | playMessage(START_BREATHING); |
otis22894 | 14:23390a020d1c | 247 | local_check = checkBreath(); |
otis22894 | 14:23390a020d1c | 248 | breath_success = breath_success & local_check; |
otis22894 | 14:23390a020d1c | 249 | } |
otis22894 | 14:23390a020d1c | 250 | } |
otis22894 | 14:23390a020d1c | 251 | |
otis22894 | 14:23390a020d1c | 252 | void chestCompressions(){ |
otis22894 | 14:23390a020d1c | 253 | playMessage(CHEST_COMPRESSIONS); |
otis22894 | 14:23390a020d1c | 254 | waitForNext(); |
otis22894 | 14:23390a020d1c | 255 | playMessage(BEGIN_COMPRESSIONS); |
otis22894 | 14:23390a020d1c | 256 | wait(1); |
otis22894 | 14:23390a020d1c | 257 | playMessage(COUNT); |
otis22894 | 14:23390a020d1c | 258 | playMessage(STOP_COMPRESSIONS); |
otis22894 | 14:23390a020d1c | 259 | } |
otis22894 | 14:23390a020d1c | 260 | |
otis22894 | 14:23390a020d1c | 261 | void CPR(){ |
otis22894 | 14:23390a020d1c | 262 | while(1){ |
otis22894 | 14:23390a020d1c | 263 | promptBreaths(2,true); |
otis22894 | 14:23390a020d1c | 264 | chestCompressions(); |
otis22894 | 14:23390a020d1c | 265 | } |
otis22894 | 14:23390a020d1c | 266 | } |
otis22894 | 14:23390a020d1c | 267 | |
otis22894 | 14:23390a020d1c | 268 | void rescueBreathing(){ |
otis22894 | 14:23390a020d1c | 269 | while(pulse){ |
otis22894 | 14:23390a020d1c | 270 | timer.start(); |
otis22894 | 14:23390a020d1c | 271 | while(timer.read()<120){ |
otis22894 | 14:23390a020d1c | 272 | promptBreaths(1,false); |
otis22894 | 14:23390a020d1c | 273 | if(adult){ |
otis22894 | 14:23390a020d1c | 274 | wait(3); //Need 5s total loop time if adult |
otis22894 | 14:23390a020d1c | 275 | }else{ |
otis22894 | 14:23390a020d1c | 276 | wait(1); //Need 3s total loop time if child |
otis22894 | 14:23390a020d1c | 277 | } |
otis22894 | 14:23390a020d1c | 278 | } |
otis22894 | 14:23390a020d1c | 279 | timer.stop(); |
otis22894 | 14:23390a020d1c | 280 | timer.reset(); |
otis22894 | 14:23390a020d1c | 281 | playMessage(TILT_HEAD); |
otis22894 | 14:23390a020d1c | 282 | waitForNext(); |
otis22894 | 14:23390a020d1c | 283 | getVitals(); |
otis22894 | 14:23390a020d1c | 284 | } |
otis22894 | 14:23390a020d1c | 285 | CPR(); |
otis22894 | 14:23390a020d1c | 286 | } |
otis22894 | 14:23390a020d1c | 287 | |
otis22894 | 14:23390a020d1c | 288 | void auditVitals(){ |
otis22894 | 14:23390a020d1c | 289 | if(pulse && !breathing){ |
otis22894 | 14:23390a020d1c | 290 | rescueBreathing(); |
otis22894 | 14:23390a020d1c | 291 | }else if(!pulse && !breathing){ |
otis22894 | 14:23390a020d1c | 292 | CPR(); |
otis22894 | 14:23390a020d1c | 293 | }else{//ERROR} |
otis22894 | 14:23390a020d1c | 294 | } |
otis22894 | 14:23390a020d1c | 295 | } |
otis22894 | 14:23390a020d1c | 296 | |
otis22894 | 14:23390a020d1c | 297 | void unconsciousChocking(){ |
otis22894 | 14:23390a020d1c | 298 | bool stillChocking = true; |
otis22894 | 14:23390a020d1c | 299 | while(stillChocking){ |
otis22894 | 14:23390a020d1c | 300 | chestCompressions(); |
otis22894 | 14:23390a020d1c | 301 | playMessage(REMOVE_MASK); |
otis22894 | 14:23390a020d1c | 302 | playMessage(REMOVE_OBJECT); |
otis22894 | 14:23390a020d1c | 303 | waitForNext(); |
otis22894 | 14:23390a020d1c | 304 | playMessage(REPLACE_MASK); |
otis22894 | 14:23390a020d1c | 305 | promptBreaths(2,true); |
otis22894 | 14:23390a020d1c | 306 | if(breath_success){ |
otis22894 | 14:23390a020d1c | 307 | stillChocking = false; |
otis22894 | 14:23390a020d1c | 308 | } |
otis22894 | 14:23390a020d1c | 309 | } |
otis22894 | 14:23390a020d1c | 310 | playMessage(TILT_HEAD); |
otis22894 | 14:23390a020d1c | 311 | waitForNext(); |
otis22894 | 14:23390a020d1c | 312 | getVitals(); |
otis22894 | 14:23390a020d1c | 313 | auditVitals(); |
otis22894 | 14:23390a020d1c | 314 | } |
otis22894 | 14:23390a020d1c | 315 | |
otis22894 | 14:23390a020d1c | 316 | void cycleLEDs(){ |
otis22894 | 14:23390a020d1c | 317 | cycleCount++; |
otis22894 | 14:23390a020d1c | 318 | if(cycleCount==1){ |
otis22894 | 14:23390a020d1c | 319 | RLED1 = 1; |
otis22894 | 14:23390a020d1c | 320 | } |
otis22894 | 14:23390a020d1c | 321 | if(cycleCount==2){ |
otis22894 | 14:23390a020d1c | 322 | RLED2 = 1; |
otis22894 | 14:23390a020d1c | 323 | } |
otis22894 | 14:23390a020d1c | 324 | if(cycleCount==3){ |
otis22894 | 14:23390a020d1c | 325 | RLED3 = 1; |
otis22894 | 14:23390a020d1c | 326 | } |
otis22894 | 14:23390a020d1c | 327 | if(cycleCount==4){ |
otis22894 | 14:23390a020d1c | 328 | GLED1 = 1; |
otis22894 | 14:23390a020d1c | 329 | } |
otis22894 | 14:23390a020d1c | 330 | if(cycleCount==5){ |
otis22894 | 14:23390a020d1c | 331 | GLED2 = 1; |
otis22894 | 14:23390a020d1c | 332 | } |
otis22894 | 14:23390a020d1c | 333 | if(cycleCount==6){ |
otis22894 | 14:23390a020d1c | 334 | GLED3 = 1; |
otis22894 | 14:23390a020d1c | 335 | } |
otis22894 | 14:23390a020d1c | 336 | if(cycleCount==7){ |
otis22894 | 14:23390a020d1c | 337 | GLED1 = 0; |
otis22894 | 14:23390a020d1c | 338 | GLED2 = 0; |
otis22894 | 14:23390a020d1c | 339 | GLED3 = 0; |
otis22894 | 14:23390a020d1c | 340 | RLED1 = 0; |
otis22894 | 14:23390a020d1c | 341 | RLED2 = 0; |
otis22894 | 14:23390a020d1c | 342 | RLED3 = 0; |
otis22894 | 14:23390a020d1c | 343 | cycleCount = 0; |
otis22894 | 14:23390a020d1c | 344 | } |
otis22894 | 14:23390a020d1c | 345 | } |
otis22894 | 14:23390a020d1c | 346 | |
otis22894 | 14:23390a020d1c | 347 | void welcomeLED(){ |
otis22894 | 14:23390a020d1c | 348 | for(int i =0;i<5;i++){ |
otis22894 | 14:23390a020d1c | 349 | GLED1 = 1; |
otis22894 | 14:23390a020d1c | 350 | GLED2 = 1; |
otis22894 | 14:23390a020d1c | 351 | GLED3 = 1; |
otis22894 | 14:23390a020d1c | 352 | RLED1 = 1; |
otis22894 | 14:23390a020d1c | 353 | RLED2 = 1; |
otis22894 | 14:23390a020d1c | 354 | RLED3 = 1; |
otis22894 | 14:23390a020d1c | 355 | wait (0.5); |
otis22894 | 14:23390a020d1c | 356 | GLED1 = 0; |
otis22894 | 14:23390a020d1c | 357 | GLED2 = 0; |
otis22894 | 14:23390a020d1c | 358 | GLED3 = 0; |
otis22894 | 14:23390a020d1c | 359 | RLED1 = 0; |
otis22894 | 14:23390a020d1c | 360 | RLED2 = 0; |
otis22894 | 14:23390a020d1c | 361 | RLED3 = 0; |
otis22894 | 14:23390a020d1c | 362 | } |
otis22894 | 14:23390a020d1c | 363 | RLED1 = 1; |
otis22894 | 14:23390a020d1c | 364 | wait(0.1); |
otis22894 | 14:23390a020d1c | 365 | RLED1 = 0; |
otis22894 | 14:23390a020d1c | 366 | RLED2 = 1; |
otis22894 | 14:23390a020d1c | 367 | wait(0.1); |
otis22894 | 14:23390a020d1c | 368 | RLED2 = 0; |
otis22894 | 14:23390a020d1c | 369 | RLED3 = 1; |
otis22894 | 14:23390a020d1c | 370 | wait(0.1); |
otis22894 | 14:23390a020d1c | 371 | RLED3 = 0; |
otis22894 | 14:23390a020d1c | 372 | GLED1 = 1; |
otis22894 | 14:23390a020d1c | 373 | wait(0.1); |
otis22894 | 14:23390a020d1c | 374 | GLED1 = 0; |
otis22894 | 14:23390a020d1c | 375 | GLED2 = 1; |
otis22894 | 14:23390a020d1c | 376 | wait(0.1); |
otis22894 | 14:23390a020d1c | 377 | GLED2 = 0; |
otis22894 | 14:23390a020d1c | 378 | GLED3 = 1; |
otis22894 | 14:23390a020d1c | 379 | wait(0.2); |
otis22894 | 14:23390a020d1c | 380 | GLED3 = 0; |
otis22894 | 14:23390a020d1c | 381 | GLED2 = 1; |
otis22894 | 14:23390a020d1c | 382 | wait(0.1); |
otis22894 | 14:23390a020d1c | 383 | GLED2 = 0; |
otis22894 | 14:23390a020d1c | 384 | GLED1 = 1; |
otis22894 | 14:23390a020d1c | 385 | wait(0.1); |
otis22894 | 14:23390a020d1c | 386 | GLED1 = 0; |
otis22894 | 14:23390a020d1c | 387 | RLED3 = 1; |
otis22894 | 14:23390a020d1c | 388 | wait(0.1); |
otis22894 | 14:23390a020d1c | 389 | RLED3 = 0; |
otis22894 | 14:23390a020d1c | 390 | RLED2 = 1; |
otis22894 | 14:23390a020d1c | 391 | wait(0.1); |
otis22894 | 14:23390a020d1c | 392 | RLED2 = 0; |
otis22894 | 14:23390a020d1c | 393 | RLED1 = 1; |
otis22894 | 14:23390a020d1c | 394 | wait(0.1); |
otis22894 | 14:23390a020d1c | 395 | RLED1 = 0; |
otis22894 | 14:23390a020d1c | 396 | } |