CIS441 Controller

Dependencies:   TextLCD mbed-rtos mbed

Fork of PacemakerController by Chad Nachiappan

Committer:
chadnach1
Date:
Wed Dec 02 01:50:22 2015 +0000
Revision:
31:7f0e865e3d4b
Parent:
30:97db5a684eaa
Child:
32:c58b6651336c
OK keyboard inputs work for PacemakerController

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chadnach1 0:d92e0b71c6b5 1 #include "mbed.h"
lucastai 2:5e9c4d83d038 2 #include "LPC17xx.h"
lucastai 2:5e9c4d83d038 3 #include "TextLCD.h"
lucastai 2:5e9c4d83d038 4 #include "rtos.h"
lucastai 2:5e9c4d83d038 5 #include "Thread.h"
lucastai 2:5e9c4d83d038 6 using namespace rtos;
chadnach1 0:d92e0b71c6b5 7
chadnach1 0:d92e0b71c6b5 8 // This is for the pacemaker
lucastai 2:5e9c4d83d038 9 volatile unsigned short timer_count;
lucastai 2:5e9c4d83d038 10 Serial pc(USBTX, USBRX);
lucastai 2:5e9c4d83d038 11 TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x4); // rs, e, d4-d7
lucastai 2:5e9c4d83d038 12
mhowar 5:9eee15818b0e 13 int keyboard_needs_numeric = 0; // boolean - is in middle of interval input?
chadnach1 0:d92e0b71c6b5 14
chadnach1 0:d92e0b71c6b5 15 int h_clock;
amiche 3:44d132582373 16 int pm_clock;
chadnach1 27:2c5aefcf3000 17 Timer avi_clk;
chadnach1 0:d92e0b71c6b5 18
chadnach1 4:f04eb7f96f4b 19 int LRI = 1000;
chadnach1 4:f04eb7f96f4b 20 int AVI = 150;
chadnach1 4:f04eb7f96f4b 21 int PVARP = 300;
chadnach1 4:f04eb7f96f4b 22 int VRP = 200;
lucastai 2:5e9c4d83d038 23
lucastai 2:5e9c4d83d038 24 // constants
lucastai 2:5e9c4d83d038 25 int MAX_PM_RT = 180;
lucastai 2:5e9c4d83d038 26 int MIN_PM_RT = 40;
lucastai 2:5e9c4d83d038 27 enum mode {NORMAL, SLEEP, EXERCISE, MANUAL};
lucastai 2:5e9c4d83d038 28
lucastai 2:5e9c4d83d038 29 // counters
lucastai 2:5e9c4d83d038 30 int beats = 0;
lucastai 2:5e9c4d83d038 31
lucastai 2:5e9c4d83d038 32 // state variables
lucastai 2:5e9c4d83d038 33 int upper_bound = 100;
lucastai 2:5e9c4d83d038 34 int lower_bound = 40;
lucastai 2:5e9c4d83d038 35 int obs_int = 10;
lucastai 2:5e9c4d83d038 36 mode curr_mode = NORMAL;
lucastai 2:5e9c4d83d038 37
amiche 19:f3615321b5c4 38 // alarms
lucastai 14:a16b636c2bbc 39 DigitalOut led_apace(LED1);
lucastai 14:a16b636c2bbc 40 DigitalOut led_vpace(LED2);
lucastai 2:5e9c4d83d038 41 DigitalOut Asense(LED3);
lucastai 2:5e9c4d83d038 42 DigitalOut Vsense(LED4);
lucastai 2:5e9c4d83d038 43
chadnach1 27:2c5aefcf3000 44 DigitalIn agetSignal(p24);
chadnach1 27:2c5aefcf3000 45 DigitalIn vgetSignal(p23);
chadnach1 27:2c5aefcf3000 46 DigitalOut apaceSignal(p22);
chadnach1 27:2c5aefcf3000 47 DigitalOut vpaceSignal(p21);
chadnach1 27:2c5aefcf3000 48
chadnach1 27:2c5aefcf3000 49 bool v_sense;
chadnach1 27:2c5aefcf3000 50 bool a_sense;
chadnach1 27:2c5aefcf3000 51
chadnach1 27:2c5aefcf3000 52 void asense()
chadnach1 27:2c5aefcf3000 53 {
chadnach1 27:2c5aefcf3000 54 a_sense = 1;
chadnach1 30:97db5a684eaa 55 lcd.printf("asense fired\n");
chadnach1 27:2c5aefcf3000 56 Thread::wait(10);
chadnach1 27:2c5aefcf3000 57 a_sense = 0;
chadnach1 27:2c5aefcf3000 58 }
lucastai 18:d4cd9d12345e 59
chadnach1 27:2c5aefcf3000 60 void vsense()
chadnach1 27:2c5aefcf3000 61 {
chadnach1 27:2c5aefcf3000 62 v_sense = 1;
chadnach1 30:97db5a684eaa 63 lcd.printf("vssense fired\n");
chadnach1 27:2c5aefcf3000 64 Thread::wait(10);
chadnach1 27:2c5aefcf3000 65 v_sense = 0;
chadnach1 27:2c5aefcf3000 66 }
chadnach1 27:2c5aefcf3000 67
chadnach1 27:2c5aefcf3000 68 void apace()
chadnach1 27:2c5aefcf3000 69 {
chadnach1 27:2c5aefcf3000 70
chadnach1 30:97db5a684eaa 71 lcd.printf("apace fired\n");
chadnach1 27:2c5aefcf3000 72 apaceSignal = 1;
chadnach1 27:2c5aefcf3000 73 led_apace = 1;
chadnach1 27:2c5aefcf3000 74 Thread::wait(10);
chadnach1 27:2c5aefcf3000 75 apaceSignal = 0;
chadnach1 27:2c5aefcf3000 76
chadnach1 27:2c5aefcf3000 77 }
chadnach1 27:2c5aefcf3000 78
chadnach1 27:2c5aefcf3000 79 void vpace()
chadnach1 27:2c5aefcf3000 80 {
chadnach1 30:97db5a684eaa 81 lcd.printf("vpace fired\n");
chadnach1 27:2c5aefcf3000 82 vpaceSignal = 1;
chadnach1 27:2c5aefcf3000 83 led_vpace = 1;
chadnach1 27:2c5aefcf3000 84 Thread::wait(10);
chadnach1 27:2c5aefcf3000 85 vpaceSignal = 0;
chadnach1 27:2c5aefcf3000 86
chadnach1 27:2c5aefcf3000 87 }
amiche 24:81cd9ef5c4f6 88
lucastai 2:5e9c4d83d038 89 // hardware interrupt handler, adapted from code in piazza post by Dagaen
amiche 24:81cd9ef5c4f6 90 extern "C" void TIMER0_IRQHandler (void)
lucastai 2:5e9c4d83d038 91 {
amiche 19:f3615321b5c4 92 if((LPC_TIM0->IR & 0x01) == 0x01) { // if MR0 interrupt, proceed
amiche 19:f3615321b5c4 93 LPC_TIM0->IR |= 1 << 0; // Clear MR0 interrupt flag
amiche 19:f3615321b5c4 94 timer_count++; //increment timer_count
lucastai 2:5e9c4d83d038 95 }
lucastai 2:5e9c4d83d038 96 }
amiche 19:f3615321b5c4 97
lucastai 2:5e9c4d83d038 98 // init the hardware interrupt (timer0), adapted same as above
lucastai 2:5e9c4d83d038 99 void timer0_init(void)
lucastai 2:5e9c4d83d038 100 {
lucastai 2:5e9c4d83d038 101 LPC_SC->PCONP |=1<1; //timer0 power on
lucastai 2:5e9c4d83d038 102 LPC_SC-> PCLKSEL0 |= 1 << 2; // set timer clock to CCLCK nondivided (1 clock cycle = 1 increment)
lucastai 2:5e9c4d83d038 103 LPC_TIM0->MR0 = 1000000; //100mhz clock cycle, 1 cycle = 10ns, 10ms = 10 000 000 ns = 1M cycles
lucastai 2:5e9c4d83d038 104 LPC_TIM0->MCR = 3; //interrupt and reset control
amiche 19:f3615321b5c4 105 //3 = Interrupt & reset timer0 on match (111) sets all three bits
lucastai 2:5e9c4d83d038 106 NVIC_EnableIRQ(TIMER0_IRQn); //enable timer0 interrupt
chadnach1 0:d92e0b71c6b5 107 }
chadnach1 0:d92e0b71c6b5 108
lucastai 2:5e9c4d83d038 109
chadnach1 27:2c5aefcf3000 110 void PM_ALARM(void const *args)
amiche 19:f3615321b5c4 111 {
chadnach1 29:5cec671cb80d 112 while (1) {
chadnach1 29:5cec671cb80d 113 // min hr alarm
chadnach1 29:5cec671cb80d 114 if( beats < MIN_PM_RT) {
chadnach1 30:97db5a684eaa 115 lcd.cls();
chadnach1 29:5cec671cb80d 116 lcd.locate(0,1);
chadnach1 30:97db5a684eaa 117 lcd.printf("!<\n");
chadnach1 29:5cec671cb80d 118 }
chadnach1 31:7f0e865e3d4b 119
chadnach1 29:5cec671cb80d 120 // max hr alarm
chadnach1 29:5cec671cb80d 121 if(beats > MAX_PM_RT) {
chadnach1 30:97db5a684eaa 122 lcd.cls();
chadnach1 29:5cec671cb80d 123 lcd.locate(0,1);
chadnach1 30:97db5a684eaa 124 lcd.printf("!>\n");
chadnach1 29:5cec671cb80d 125 }
amiche 19:f3615321b5c4 126 }
amiche 19:f3615321b5c4 127
chadnach1 0:d92e0b71c6b5 128 }
chadnach1 0:d92e0b71c6b5 129
lucastai 2:5e9c4d83d038 130 // hw interrupt callback, deal with the keyboard input from PC
chadnach1 31:7f0e865e3d4b 131 /*void keyboard_handler()
amiche 19:f3615321b5c4 132 {
amiche 19:f3615321b5c4 133
lucastai 2:5e9c4d83d038 134 // get the char, put it on the PC command line
lucastai 2:5e9c4d83d038 135 char a = pc.getc();
lucastai 2:5e9c4d83d038 136
mhowar 5:9eee15818b0e 137 if (keyboard_needs_numeric) {
mhowar 5:9eee15818b0e 138 if (a >= '0' && a <= '9') {
mhowar 5:9eee15818b0e 139 // update observation interval
mhowar 9:fd8477284185 140 obs_int = (a - '0' + 1) * 5;
mhowar 5:9eee15818b0e 141 } else {
chadnach1 31:7f0e865e3d4b 142 lcd.printf("MODE IS N\n");
amiche 19:f3615321b5c4 143 pc.printf("Expected numeric key\n");
mhowar 5:9eee15818b0e 144 }
amiche 19:f3615321b5c4 145 } else if(a == 'N') {
mhowar 5:9eee15818b0e 146 // if the char is N, update bounds to normal mode
lucastai 2:5e9c4d83d038 147 curr_mode = NORMAL;
lucastai 2:5e9c4d83d038 148 upper_bound = 100;
lucastai 2:5e9c4d83d038 149 lower_bound = 40;
chadnach1 31:7f0e865e3d4b 150 lcd.printf("MODE IS N\n");
amiche 19:f3615321b5c4 151 pc.printf("MODE IS N\n");
amiche 19:f3615321b5c4 152 // if the char is S, set bounds to sleep
amiche 19:f3615321b5c4 153 } else if (a == 'S') {
lucastai 2:5e9c4d83d038 154 curr_mode = SLEEP;
lucastai 2:5e9c4d83d038 155 upper_bound = 60;
lucastai 2:5e9c4d83d038 156 lower_bound = 30;
chadnach1 31:7f0e865e3d4b 157 lcd.printf("MODE IS S\n");
amiche 19:f3615321b5c4 158 pc.printf("MODE IS S\n");
amiche 19:f3615321b5c4 159 // if the char is E, set bounds to exercise
amiche 19:f3615321b5c4 160 } else if (a == 'E') {
lucastai 2:5e9c4d83d038 161 curr_mode = EXERCISE;
lucastai 2:5e9c4d83d038 162 upper_bound = 175;
lucastai 2:5e9c4d83d038 163 lower_bound = 100;
chadnach1 31:7f0e865e3d4b 164 lcd.printf("MODE IS E\n");
amiche 19:f3615321b5c4 165 pc.printf("MODE IS E\n");
lucastai 2:5e9c4d83d038 166 beats = 2;
amiche 19:f3615321b5c4 167 // if the char is M, set to manual
amiche 19:f3615321b5c4 168 } else if (a == 'M') {
lucastai 2:5e9c4d83d038 169 curr_mode = MANUAL;
lucastai 2:5e9c4d83d038 170 upper_bound = 175;
lucastai 2:5e9c4d83d038 171 lower_bound = 30;
lucastai 2:5e9c4d83d038 172 beats = 300;
chadnach1 31:7f0e865e3d4b 173 lcd.printf("MODE IS MANUAL\n");
amiche 19:f3615321b5c4 174 pc.printf("MODE IS MANUAL\n");
amiche 19:f3615321b5c4 175 // check for A if mode is manual
amiche 19:f3615321b5c4 176 } else if (a == 'A') {
amiche 19:f3615321b5c4 177 if(curr_mode == MANUAL) {
amiche 19:f3615321b5c4 178 pc.printf("MODE IS MANUAL GOT APACE\n");
lucastai 2:5e9c4d83d038 179 }
amiche 19:f3615321b5c4 180 // check for V is mode is manual
amiche 19:f3615321b5c4 181 } else if (a == 'V') {
amiche 19:f3615321b5c4 182 if(curr_mode == MANUAL) {
amiche 19:f3615321b5c4 183 pc.printf("MODE IS MANUAL GOT VPACE\n");
amiche 19:f3615321b5c4 184 }
amiche 19:f3615321b5c4 185 } else if (a == 'O') {
mhowar 5:9eee15818b0e 186 keyboard_needs_numeric = 1;
amiche 19:f3615321b5c4 187 } else {
lucastai 2:5e9c4d83d038 188 // do nothing for invalid char
lucastai 2:5e9c4d83d038 189 }
amiche 19:f3615321b5c4 190
chadnach1 31:7f0e865e3d4b 191 }*/
lucastai 2:5e9c4d83d038 192
chadnach1 27:2c5aefcf3000 193 void pm_sense(void const *args)
amiche 19:f3615321b5c4 194 {
amiche 19:f3615321b5c4 195
chadnach1 4:f04eb7f96f4b 196 while(1) {
chadnach1 30:97db5a684eaa 197 //lcd.locate(0,1);
chadnach1 30:97db5a684eaa 198 //lcd.printf("in pmsense\n");
amiche 19:f3615321b5c4 199
chadnach1 27:2c5aefcf3000 200 if (timer_count >= VRP && vgetSignal == 1) {
amiche 24:81cd9ef5c4f6 201 // Valid_V state
amiche 24:81cd9ef5c4f6 202
amiche 19:f3615321b5c4 203 timer_count = 0;
amiche 24:81cd9ef5c4f6 204 vsense();
amiche 19:f3615321b5c4 205 // do something with Vsense!
amiche 24:81cd9ef5c4f6 206
chadnach1 27:2c5aefcf3000 207 } else if (timer_count < VRP && vgetSignal == 1) {
chadnach1 20:dc272bfaa276 208 // Invalid_V state
chadnach1 4:f04eb7f96f4b 209 }
amiche 19:f3615321b5c4 210
chadnach1 27:2c5aefcf3000 211 if (timer_count < PVARP && agetSignal == 1) {
chadnach1 20:dc272bfaa276 212 // Invalid_A state
chadnach1 27:2c5aefcf3000 213 } else if (timer_count >= PVARP && agetSignal == 1) {
chadnach1 20:dc272bfaa276 214 // Valid_A state
amiche 24:81cd9ef5c4f6 215 asense();
chadnach1 4:f04eb7f96f4b 216 // do something with Asense!
chadnach1 4:f04eb7f96f4b 217 }
amiche 19:f3615321b5c4 218
chadnach1 4:f04eb7f96f4b 219 }
amiche 3:44d132582373 220 }
amiche 3:44d132582373 221
chadnach1 27:2c5aefcf3000 222 void pm_response(void const *args)
amiche 19:f3615321b5c4 223 {
chadnach1 4:f04eb7f96f4b 224 while(1) {
chadnach1 30:97db5a684eaa 225 //lcd.cls();
chadnach1 30:97db5a684eaa 226 //lcd.printf("in response\n");
chadnach1 27:2c5aefcf3000 227 bool goInitalState = 1;
amiche 19:f3615321b5c4 228 if (timer_count >= LRI-AVI) {
chadnach1 30:97db5a684eaa 229 //lcd.cls();
chadnach1 30:97db5a684eaa 230 //lcd.printf("timer_count >= LRI-AVI\n");
chadnach1 27:2c5aefcf3000 231 goInitalState = 0;
amiche 19:f3615321b5c4 232 // PM_A! sets the LED high
amiche 19:f3615321b5c4 233 led_apace = 1;
amiche 19:f3615321b5c4 234
amiche 19:f3615321b5c4 235 // avi_clk = 0
amiche 19:f3615321b5c4 236 avi_clk.reset();
amiche 19:f3615321b5c4 237
amiche 19:f3615321b5c4 238 apace();
amiche 19:f3615321b5c4 239 // At Atrial Event State
amiche 24:81cd9ef5c4f6 240 while (avi_clk.read() < AVI) {
chadnach1 30:97db5a684eaa 241 //lcd.cls();
chadnach1 30:97db5a684eaa 242 //lcd.printf("avi_clk.read() < AVI\n");
chadnach1 27:2c5aefcf3000 243 if (v_sense == 1) {
chadnach1 27:2c5aefcf3000 244 goInitalState = 1;
amiche 24:81cd9ef5c4f6 245 break;
amiche 24:81cd9ef5c4f6 246 }
amiche 24:81cd9ef5c4f6 247 }
chadnach1 27:2c5aefcf3000 248 if (!goInitalState) {
amiche 24:81cd9ef5c4f6 249 // Ventricular Event
amiche 24:81cd9ef5c4f6 250 timer_count = 0;
amiche 19:f3615321b5c4 251
amiche 24:81cd9ef5c4f6 252 // PM_V! sets the LED high
amiche 24:81cd9ef5c4f6 253 led_vpace = 1;
amiche 19:f3615321b5c4 254
amiche 24:81cd9ef5c4f6 255 timer_count = 0;
amiche 24:81cd9ef5c4f6 256 vpace();
amiche 24:81cd9ef5c4f6 257 }
amiche 19:f3615321b5c4 258 } else if (timer_count < LRI - AVI) {
chadnach1 31:7f0e865e3d4b 259 //lcd.cls();
chadnach1 31:7f0e865e3d4b 260 //lcd.printf("timer_count < LRI - AVI\n");
amiche 24:81cd9ef5c4f6 261 // if Asense, move on to atrial event
chadnach1 27:2c5aefcf3000 262 if (a_sense == 1) {
chadnach1 27:2c5aefcf3000 263 goInitalState = 0;
chadnach1 31:7f0e865e3d4b 264
amiche 24:81cd9ef5c4f6 265 // avi_clk = 0
amiche 24:81cd9ef5c4f6 266 avi_clk.reset();
amiche 19:f3615321b5c4 267
amiche 24:81cd9ef5c4f6 268 // At Atrial Event State
amiche 24:81cd9ef5c4f6 269 while (avi_clk.read() < AVI) {
chadnach1 27:2c5aefcf3000 270 if (v_sense == 1) {
chadnach1 27:2c5aefcf3000 271 goInitalState = 1;
amiche 24:81cd9ef5c4f6 272 break;
amiche 24:81cd9ef5c4f6 273 }
amiche 24:81cd9ef5c4f6 274 }
amiche 19:f3615321b5c4 275
amiche 24:81cd9ef5c4f6 276 // Ventricular Event
amiche 24:81cd9ef5c4f6 277 timer_count = 0;
amiche 24:81cd9ef5c4f6 278
amiche 24:81cd9ef5c4f6 279 // PM_V! sets the LED high
amiche 24:81cd9ef5c4f6 280 led_vpace = 1;
amiche 24:81cd9ef5c4f6 281
amiche 24:81cd9ef5c4f6 282 timer_count = 0;
amiche 24:81cd9ef5c4f6 283 vpace();
amiche 24:81cd9ef5c4f6 284 }
amiche 19:f3615321b5c4 285 }
amiche 19:f3615321b5c4 286 }
amiche 3:44d132582373 287 }
lucastai 2:5e9c4d83d038 288
amiche 19:f3615321b5c4 289 int main()
amiche 19:f3615321b5c4 290 {
chadnach1 16:ae9df4194011 291 // https://developer.mbed.org/users/chadnach1/code/PacemakerController/
lucastai 2:5e9c4d83d038 292 // connect the serial device (PC keybd) to the interrupt
chadnach1 31:7f0e865e3d4b 293 //pc.attach(&keyboard_handler);
chadnach1 30:97db5a684eaa 294 lcd.printf("in main\n");
amiche 19:f3615321b5c4 295
chadnach1 16:ae9df4194011 296 // Start LED's Off
chadnach1 17:c89cddf30925 297 led_apace = 0;
chadnach1 17:c89cddf30925 298 led_vpace = 0;
amiche 19:f3615321b5c4 299
chadnach1 16:ae9df4194011 300 // Start the avi_clock
chadnach1 16:ae9df4194011 301 avi_clk.start();
amiche 19:f3615321b5c4 302
chadnach1 30:97db5a684eaa 303 Thread t1(pm_sense, (void *)"");
chadnach1 30:97db5a684eaa 304 Thread t2(pm_response, (void *)"");
chadnach1 31:7f0e865e3d4b 305 Thread t3(PM_ALARM, (void *)"");
chadnach1 31:7f0e865e3d4b 306
chadnach1 31:7f0e865e3d4b 307 char a = 'Z';
chadnach1 31:7f0e865e3d4b 308 while(1) {
chadnach1 31:7f0e865e3d4b 309 if (pc.readable()) {
chadnach1 31:7f0e865e3d4b 310
chadnach1 31:7f0e865e3d4b 311 a = pc.getc();
chadnach1 31:7f0e865e3d4b 312
chadnach1 31:7f0e865e3d4b 313 // Handle different keyboard inputs
chadnach1 31:7f0e865e3d4b 314
chadnach1 31:7f0e865e3d4b 315 if (a >= '0' && a <= '9') {
chadnach1 31:7f0e865e3d4b 316 // update observation interval
chadnach1 31:7f0e865e3d4b 317 obs_int = (a - '0' + 1) * 5;
chadnach1 31:7f0e865e3d4b 318 } else {
chadnach1 31:7f0e865e3d4b 319 lcd.printf("MODE IS N\n");
chadnach1 31:7f0e865e3d4b 320 pc.printf("Expected numeric key\n");
chadnach1 31:7f0e865e3d4b 321 }
chadnach1 31:7f0e865e3d4b 322 } else if(a == 'N') {
chadnach1 31:7f0e865e3d4b 323 // if the char is N, update bounds to normal mode
chadnach1 31:7f0e865e3d4b 324 curr_mode = NORMAL;
chadnach1 31:7f0e865e3d4b 325 upper_bound = 100;
chadnach1 31:7f0e865e3d4b 326 lower_bound = 40;
chadnach1 31:7f0e865e3d4b 327 lcd.printf("MODE IS N\n");
chadnach1 31:7f0e865e3d4b 328 pc.printf("MODE IS N\n");
chadnach1 31:7f0e865e3d4b 329 // if the char is S, set bounds to sleep
chadnach1 31:7f0e865e3d4b 330 } else if (a == 'S') {
chadnach1 31:7f0e865e3d4b 331 curr_mode = SLEEP;
chadnach1 31:7f0e865e3d4b 332 upper_bound = 60;
chadnach1 31:7f0e865e3d4b 333 lower_bound = 30;
chadnach1 31:7f0e865e3d4b 334 lcd.printf("MODE IS S\n");
chadnach1 31:7f0e865e3d4b 335 pc.printf("MODE IS S\n");
chadnach1 31:7f0e865e3d4b 336 // if the char is E, set bounds to exercise
chadnach1 31:7f0e865e3d4b 337 } else if (a == 'E') {
chadnach1 31:7f0e865e3d4b 338 curr_mode = EXERCISE;
chadnach1 31:7f0e865e3d4b 339 upper_bound = 175;
chadnach1 31:7f0e865e3d4b 340 lower_bound = 100;
chadnach1 31:7f0e865e3d4b 341 lcd.printf("MODE IS E\n");
chadnach1 31:7f0e865e3d4b 342 pc.printf("MODE IS E\n");
chadnach1 31:7f0e865e3d4b 343 beats = 2;
chadnach1 31:7f0e865e3d4b 344 // if the char is M, set to manual
chadnach1 31:7f0e865e3d4b 345 } else if (a == 'M') {
chadnach1 31:7f0e865e3d4b 346 curr_mode = MANUAL;
chadnach1 31:7f0e865e3d4b 347 upper_bound = 175;
chadnach1 31:7f0e865e3d4b 348 lower_bound = 30;
chadnach1 31:7f0e865e3d4b 349 beats = 300;
chadnach1 31:7f0e865e3d4b 350 lcd.printf("MODE IS MANUAL\n");
chadnach1 31:7f0e865e3d4b 351 pc.printf("MODE IS MANUAL\n");
chadnach1 31:7f0e865e3d4b 352 // check for A if mode is manual
chadnach1 31:7f0e865e3d4b 353 } else if (a == 'A') {
chadnach1 31:7f0e865e3d4b 354 if(curr_mode == MANUAL) {
chadnach1 31:7f0e865e3d4b 355 pc.printf("MODE IS MANUAL GOT APACE\n");
chadnach1 31:7f0e865e3d4b 356 }
chadnach1 31:7f0e865e3d4b 357 // check for V is mode is manual
chadnach1 31:7f0e865e3d4b 358 } else if (a == 'V') {
chadnach1 31:7f0e865e3d4b 359 if(curr_mode == MANUAL) {
chadnach1 31:7f0e865e3d4b 360 pc.printf("MODE IS MANUAL GOT VPACE\n");
chadnach1 31:7f0e865e3d4b 361 }
chadnach1 31:7f0e865e3d4b 362 } else if (a == 'O') {
chadnach1 31:7f0e865e3d4b 363 keyboard_needs_numeric = 1;
chadnach1 31:7f0e865e3d4b 364 } else {
chadnach1 31:7f0e865e3d4b 365 // do nothing for invalid char
chadnach1 31:7f0e865e3d4b 366 }
chadnach1 31:7f0e865e3d4b 367 }
chadnach1 31:7f0e865e3d4b 368 }