Working reset, flipped logic

Dependencies:   SDFileSystem emic2 mbed-rtos mbed

Fork of BAT_senior_design_Nhi by BAT

Committer:
aismail1997
Date:
Fri Oct 27 13:34:49 2017 +0000
Revision:
18:d14bf57f435b
Parent:
17:08c575082052
Child:
19:ceac47be2e64
6 button threads

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aismail1997 0:9eda4611081a 1 #include "mbed.h"
aismail1997 6:1aa86ad19af9 2 #include "rtos.h"
aismail1997 9:418a4437a693 3 #include "wave_player.h"
aismail1997 9:418a4437a693 4 #include "SDFileSystem.h"
aismail1997 10:21268d8bf979 5 #include "button.h"
aismail1997 3:9ed43e974156 6
aismail1997 13:b80dde24e9bc 7 // DEFINE I/O
aismail1997 0:9eda4611081a 8 PwmOut myservo(p21);
aismail1997 0:9eda4611081a 9 DigitalIn pb1 (p20);
aismail1997 14:581a3b02f4c3 10 PwmOut myservo2(p22);
aismail1997 14:581a3b02f4c3 11 DigitalIn pb2 (p19);
aismail1997 18:d14bf57f435b 12 PwmOut myservo3(p23);
aismail1997 18:d14bf57f435b 13 DigitalIn pb3 (p18);
aismail1997 18:d14bf57f435b 14 PwmOut myservo4(p24);
aismail1997 18:d14bf57f435b 15 DigitalIn pb4 (p17);
aismail1997 18:d14bf57f435b 16 PwmOut myservo5(p25);
aismail1997 18:d14bf57f435b 17 DigitalIn pb5 (p16);
aismail1997 18:d14bf57f435b 18 PwmOut myservo6(p26);
aismail1997 18:d14bf57f435b 19 DigitalIn pb6 (p15);
aismail1997 18:d14bf57f435b 20
aismail1997 18:d14bf57f435b 21 //DigitalOut led1(LED1);
aismail1997 18:d14bf57f435b 22 //DigitalOut led3(LED3);
aismail1997 18:d14bf57f435b 23 //DigitalOut led4(LED4);
aismail1997 14:581a3b02f4c3 24
aismail1997 0:9eda4611081a 25 //AnalogIn linpot(p20);
aismail1997 14:581a3b02f4c3 26 //Serial pc(USBTX, USBRX);
aismail1997 14:581a3b02f4c3 27 //SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
aismail1997 14:581a3b02f4c3 28 //AnalogOut DACout(p26);
aismail1997 14:581a3b02f4c3 29 //wave_player waver(&DACout);
aismail1997 10:21268d8bf979 30 button button1(myservo, pb1);
aismail1997 14:581a3b02f4c3 31 button button2(myservo2, pb2);
aismail1997 18:d14bf57f435b 32 button button3(myservo3, pb3);
aismail1997 18:d14bf57f435b 33 button button4(myservo4, pb4);
aismail1997 18:d14bf57f435b 34 button button5(myservo5, pb5);
aismail1997 18:d14bf57f435b 35 button button6(myservo6, pb6);
aismail1997 4:cc181f8f2bd1 36
aismail1997 13:b80dde24e9bc 37 // INITIALIZE VARIABLES
aismail1997 13:b80dde24e9bc 38 // add mode, reset buttons
aismail1997 9:418a4437a693 39 int start = 0;
aismail1997 9:418a4437a693 40 int submit = 0;
aismail1997 18:d14bf57f435b 41 // Buttons begins in up state
aismail1997 17:08c575082052 42 int state = 0;
aismail1997 18:d14bf57f435b 43 int state2 = 0;
aismail1997 18:d14bf57f435b 44 int state3 = 0;
aismail1997 18:d14bf57f435b 45 int state4 = 0;
aismail1997 18:d14bf57f435b 46 int state5 = 0;
aismail1997 18:d14bf57f435b 47 int state6 = 0;
aismail1997 14:581a3b02f4c3 48 int count = 0;
aismail1997 6:1aa86ad19af9 49
aismail1997 9:418a4437a693 50 // FUNCTIONS
aismail1997 13:b80dde24e9bc 51 // play a file on the speaker
aismail1997 14:581a3b02f4c3 52 /*void playSound(wave_player waver)
aismail1997 9:418a4437a693 53 {
aismail1997 9:418a4437a693 54 FILE *wave_file;
aismail1997 13:b80dde24e9bc 55 wave_file=fopen("/sd/lesson.wav","r");
aismail1997 9:418a4437a693 56 waver.play(wave_file);
aismail1997 9:418a4437a693 57 fclose(wave_file);
aismail1997 14:581a3b02f4c3 58 }*/
aismail1997 6:1aa86ad19af9 59
aismail1997 6:1aa86ad19af9 60 // THREADS
aismail1997 13:b80dde24e9bc 61
aismail1997 13:b80dde24e9bc 62 // thread for the custom button
aismail1997 18:d14bf57f435b 63 //int count = 0;
aismail1997 18:d14bf57f435b 64
aismail1997 6:1aa86ad19af9 65 void button_thread()
aismail1997 4:cc181f8f2bd1 66 {
aismail1997 14:581a3b02f4c3 67 while(true) {
aismail1997 17:08c575082052 68 // state 0 - button is up, pb = 0
aismail1997 17:08c575082052 69 if (pb1 == 0 && state == 3) {
aismail1997 17:08c575082052 70 // nothing happens here, servo is still
aismail1997 17:08c575082052 71 state = 0;
aismail1997 17:08c575082052 72 }
aismail1997 17:08c575082052 73 // state 1 - button is moving down, pb = 1
aismail1997 17:08c575082052 74 if (pb1 == 1 && state == 0) {
aismail1997 14:581a3b02f4c3 75 button1.moveServoIn();
aismail1997 14:581a3b02f4c3 76 state = 1;
aismail1997 14:581a3b02f4c3 77 }
aismail1997 17:08c575082052 78 // state 2 - button is down, pb = 0
aismail1997 17:08c575082052 79 if (pb1 == 0 && state == 1) {
aismail1997 17:08c575082052 80 // nothing happens here, servo is still
aismail1997 17:08c575082052 81 state = 2;
aismail1997 17:08c575082052 82 }
aismail1997 17:08c575082052 83 // state 3 - button is moving up, pb = 1
aismail1997 17:08c575082052 84 if (pb1 == 1 && state == 2) {
aismail1997 14:581a3b02f4c3 85 button1.moveServoOut();
aismail1997 17:08c575082052 86 state = 3;
aismail1997 14:581a3b02f4c3 87 }
aismail1997 17:08c575082052 88 // state 4 - handle debouncing while button is down
aismail1997 17:08c575082052 89 /*if (pb1 = 1 && state == 2) {
aismail1997 18:d14bf57f435b 90 count++;
aismail1997 17:08c575082052 91 }*/
aismail1997 10:21268d8bf979 92 }
aismail1997 14:581a3b02f4c3 93 }
aismail1997 14:581a3b02f4c3 94
aismail1997 14:581a3b02f4c3 95 void button2_thread()
aismail1997 14:581a3b02f4c3 96 {
aismail1997 14:581a3b02f4c3 97 while(true) {
aismail1997 15:7e9308d14faa 98 // state 0 - button is up, pb = 0
aismail1997 16:5c91af9b4e7c 99 if (pb2 == 0 && state2 == 3) {
aismail1997 15:7e9308d14faa 100 // nothing happens here, servo is still
aismail1997 16:5c91af9b4e7c 101 state2 = 0;
aismail1997 18:d14bf57f435b 102 //led3 = 0;
aismail1997 18:d14bf57f435b 103 //led4 = 0;
aismail1997 16:5c91af9b4e7c 104 }
aismail1997 15:7e9308d14faa 105 // state 1 - button is moving down, pb = 1
aismail1997 16:5c91af9b4e7c 106 if (pb2 == 1 && state2 == 0) {
aismail1997 16:5c91af9b4e7c 107 button2.moveServoIn();
aismail1997 16:5c91af9b4e7c 108 state2 = 1;
aismail1997 18:d14bf57f435b 109 //led3 = 0;
aismail1997 18:d14bf57f435b 110 //led4 = 1;
aismail1997 16:5c91af9b4e7c 111 }
aismail1997 15:7e9308d14faa 112 // state 2 - button is down, pb = 0
aismail1997 16:5c91af9b4e7c 113 if (pb2 == 0 && state2 == 1) {
aismail1997 15:7e9308d14faa 114 // nothing happens here, servo is still
aismail1997 16:5c91af9b4e7c 115 state2 = 2;
aismail1997 18:d14bf57f435b 116 //led3 = 1;
aismail1997 18:d14bf57f435b 117 //led4 = 0;
aismail1997 16:5c91af9b4e7c 118 }
aismail1997 15:7e9308d14faa 119 // state 3 - button is moving up, pb = 1
aismail1997 16:5c91af9b4e7c 120 if (pb2 == 1 && state2 == 2) {
aismail1997 16:5c91af9b4e7c 121 button2.moveServoOut();
aismail1997 16:5c91af9b4e7c 122 state2 = 3;
aismail1997 18:d14bf57f435b 123 //led3 = 1;
aismail1997 18:d14bf57f435b 124 //led4 = 1;
aismail1997 16:5c91af9b4e7c 125 }
aismail1997 17:08c575082052 126 // state 4 - handle debouncing while button is down
aismail1997 16:5c91af9b4e7c 127 /*if (pb2 = 1 && state2 == 2) {
aismail1997 16:5c91af9b4e7c 128
aismail1997 16:5c91af9b4e7c 129 }*/
aismail1997 15:7e9308d14faa 130
aismail1997 14:581a3b02f4c3 131 Thread::wait(100); // wait till thread is done
aismail1997 10:21268d8bf979 132 }
aismail1997 4:cc181f8f2bd1 133 }
aismail1997 4:cc181f8f2bd1 134
aismail1997 18:d14bf57f435b 135 // thread for the custom button
aismail1997 18:d14bf57f435b 136 void button3_thread()
aismail1997 18:d14bf57f435b 137 {
aismail1997 18:d14bf57f435b 138 while(true) {
aismail1997 18:d14bf57f435b 139 // state 0 - button is up, pb = 0
aismail1997 18:d14bf57f435b 140 if (pb3 == 0 && state3 == 3) {
aismail1997 18:d14bf57f435b 141 // nothing happens here, servo is still
aismail1997 18:d14bf57f435b 142 state3 = 0;
aismail1997 18:d14bf57f435b 143 }
aismail1997 18:d14bf57f435b 144 // state 1 - button is moving down, pb = 1
aismail1997 18:d14bf57f435b 145 if (pb3 == 1 && state3 == 0) {
aismail1997 18:d14bf57f435b 146 button3.moveServoIn();
aismail1997 18:d14bf57f435b 147 state3 = 1;
aismail1997 18:d14bf57f435b 148 }
aismail1997 18:d14bf57f435b 149 // state 2 - button is down, pb = 0
aismail1997 18:d14bf57f435b 150 if (pb3 == 0 && state3 == 1) {
aismail1997 18:d14bf57f435b 151 // nothing happens here, servo is still
aismail1997 18:d14bf57f435b 152 state3 = 2;
aismail1997 18:d14bf57f435b 153 }
aismail1997 18:d14bf57f435b 154 // state 3 - button is moving up, pb = 1
aismail1997 18:d14bf57f435b 155 if (pb3 == 1 && state3 == 2) {
aismail1997 18:d14bf57f435b 156 button3.moveServoOut();
aismail1997 18:d14bf57f435b 157 state3 = 3;
aismail1997 18:d14bf57f435b 158 }
aismail1997 18:d14bf57f435b 159 // state 4 - handle debouncing while button is down
aismail1997 18:d14bf57f435b 160 /*if (pb3 = 1 && state3 == 2) {
aismail1997 18:d14bf57f435b 161
aismail1997 18:d14bf57f435b 162 }*/
aismail1997 18:d14bf57f435b 163
aismail1997 18:d14bf57f435b 164 }
aismail1997 18:d14bf57f435b 165 }
aismail1997 18:d14bf57f435b 166
aismail1997 18:d14bf57f435b 167 // thread for the custom button
aismail1997 18:d14bf57f435b 168 void button4_thread()
aismail1997 18:d14bf57f435b 169 {
aismail1997 18:d14bf57f435b 170 while(true) {
aismail1997 18:d14bf57f435b 171 // state 0 - button is up, pb = 0
aismail1997 18:d14bf57f435b 172 if (pb4 == 0 && state4 == 3) {
aismail1997 18:d14bf57f435b 173 // nothing happens here, servo is still
aismail1997 18:d14bf57f435b 174 state4 = 0;
aismail1997 18:d14bf57f435b 175 }
aismail1997 18:d14bf57f435b 176 // state 1 - button is moving down, pb = 1
aismail1997 18:d14bf57f435b 177 if (pb4 == 1 && state4 == 0) {
aismail1997 18:d14bf57f435b 178 button4.moveServoIn();
aismail1997 18:d14bf57f435b 179 state4 = 1;
aismail1997 18:d14bf57f435b 180 }
aismail1997 18:d14bf57f435b 181 // state 2 - button is down, pb = 0
aismail1997 18:d14bf57f435b 182 if (pb4 == 0 && state4 == 1) {
aismail1997 18:d14bf57f435b 183 // nothing happens here, servo is still
aismail1997 18:d14bf57f435b 184 state4 = 2;
aismail1997 18:d14bf57f435b 185 }
aismail1997 18:d14bf57f435b 186 // state 3 - button is moving up, pb = 1
aismail1997 18:d14bf57f435b 187 if (pb4 == 1 && state4 == 2) {
aismail1997 18:d14bf57f435b 188 button4.moveServoOut();
aismail1997 18:d14bf57f435b 189 state4 = 3;
aismail1997 18:d14bf57f435b 190 }
aismail1997 18:d14bf57f435b 191 // state 4 - handle debouncing while button is down
aismail1997 18:d14bf57f435b 192 /*if (pb4 = 1 && state4 == 2) {
aismail1997 18:d14bf57f435b 193
aismail1997 18:d14bf57f435b 194 }*/
aismail1997 18:d14bf57f435b 195
aismail1997 18:d14bf57f435b 196 }
aismail1997 18:d14bf57f435b 197 }
aismail1997 18:d14bf57f435b 198
aismail1997 18:d14bf57f435b 199 // thread for the custom button
aismail1997 18:d14bf57f435b 200 void button5_thread()
aismail1997 18:d14bf57f435b 201 {
aismail1997 18:d14bf57f435b 202
aismail1997 18:d14bf57f435b 203 while(true) {
aismail1997 18:d14bf57f435b 204 // state 0 - button is up, pb = 0
aismail1997 18:d14bf57f435b 205 if (pb5 == 0 && state5 == 3) {
aismail1997 18:d14bf57f435b 206 // nothing happens here, servo is still
aismail1997 18:d14bf57f435b 207 state5 = 0;
aismail1997 18:d14bf57f435b 208 }
aismail1997 18:d14bf57f435b 209 // state 1 - button is moving down, pb = 1
aismail1997 18:d14bf57f435b 210 if (pb5 == 1 && state5 == 0) {
aismail1997 18:d14bf57f435b 211 button5.moveServoIn();
aismail1997 18:d14bf57f435b 212 state5 = 1;
aismail1997 18:d14bf57f435b 213 }
aismail1997 18:d14bf57f435b 214 // state 2 - button is down, pb = 0
aismail1997 18:d14bf57f435b 215 if (pb5 == 0 && state5 == 1) {
aismail1997 18:d14bf57f435b 216 // nothing happens here, servo is still
aismail1997 18:d14bf57f435b 217 state5 = 2;
aismail1997 18:d14bf57f435b 218 }
aismail1997 18:d14bf57f435b 219 // state 3 - button is moving up, pb = 1
aismail1997 18:d14bf57f435b 220 if (pb5 == 1 && state5 == 2) {
aismail1997 18:d14bf57f435b 221 button5.moveServoOut();
aismail1997 18:d14bf57f435b 222 state5 = 3;
aismail1997 18:d14bf57f435b 223 }
aismail1997 18:d14bf57f435b 224 // state 4 - handle debouncing while button is down
aismail1997 18:d14bf57f435b 225 /*if (pb5 = 1 && state5 == 2) {
aismail1997 18:d14bf57f435b 226
aismail1997 18:d14bf57f435b 227 }*/
aismail1997 18:d14bf57f435b 228
aismail1997 18:d14bf57f435b 229 }
aismail1997 18:d14bf57f435b 230 }
aismail1997 18:d14bf57f435b 231
aismail1997 18:d14bf57f435b 232 // thread for the custom button
aismail1997 18:d14bf57f435b 233 void button6_thread()
aismail1997 18:d14bf57f435b 234 {
aismail1997 18:d14bf57f435b 235 while(true) {
aismail1997 18:d14bf57f435b 236 // state 0 - button is up, pb = 0
aismail1997 18:d14bf57f435b 237 if (pb6 == 0 && state6 == 3) {
aismail1997 18:d14bf57f435b 238 // nothing happens here, servo is still
aismail1997 18:d14bf57f435b 239 state6 = 0;
aismail1997 18:d14bf57f435b 240 }
aismail1997 18:d14bf57f435b 241 // state 1 - button is moving down, pb = 1
aismail1997 18:d14bf57f435b 242 if (pb6 == 1 && state6 == 0) {
aismail1997 18:d14bf57f435b 243 button6.moveServoIn();
aismail1997 18:d14bf57f435b 244 state6 = 1;
aismail1997 18:d14bf57f435b 245 }
aismail1997 18:d14bf57f435b 246 // state 2 - button is down, pb = 0
aismail1997 18:d14bf57f435b 247 if (pb6 == 0 && state6 == 1) {
aismail1997 18:d14bf57f435b 248 // nothing happens here, servo is still
aismail1997 18:d14bf57f435b 249 state6 = 2;
aismail1997 18:d14bf57f435b 250 }
aismail1997 18:d14bf57f435b 251 // state 3 - button is moving up, pb = 1
aismail1997 18:d14bf57f435b 252 if (pb6 == 1 && state6 == 2) {
aismail1997 18:d14bf57f435b 253 button6.moveServoOut();
aismail1997 18:d14bf57f435b 254 state6 = 3;
aismail1997 18:d14bf57f435b 255 }
aismail1997 18:d14bf57f435b 256 // state 4 - handle debouncing while button is down
aismail1997 18:d14bf57f435b 257 /*if (pb6 = 1 && state6 == 2) {
aismail1997 18:d14bf57f435b 258
aismail1997 18:d14bf57f435b 259 }*/
aismail1997 18:d14bf57f435b 260
aismail1997 18:d14bf57f435b 261 }
aismail1997 18:d14bf57f435b 262 }
aismail1997 18:d14bf57f435b 263
aismail1997 6:1aa86ad19af9 264 void submit_thread()
aismail1997 4:cc181f8f2bd1 265 {
aismail1997 13:b80dde24e9bc 266 Thread::wait(500); // wait till thread is done
aismail1997 4:cc181f8f2bd1 267 }
aismail1997 4:cc181f8f2bd1 268
aismail1997 6:1aa86ad19af9 269 void start_thread()
aismail1997 4:cc181f8f2bd1 270 {
aismail1997 6:1aa86ad19af9 271 // read pb_start
aismail1997 6:1aa86ad19af9 272 // if 1
aismail1997 14:581a3b02f4c3 273 start = 1;
aismail1997 14:581a3b02f4c3 274 //pc.printf("start %d ", start);
aismail1997 6:1aa86ad19af9 275 // else 0
aismail1997 13:b80dde24e9bc 276 Thread::wait(500); // wait till thread is done
aismail1997 4:cc181f8f2bd1 277 }
aismail1997 0:9eda4611081a 278
aismail1997 14:581a3b02f4c3 279
aismail1997 0:9eda4611081a 280 int main()
aismail1997 0:9eda4611081a 281 {
aismail1997 6:1aa86ad19af9 282 // SETUP
aismail1997 4:cc181f8f2bd1 283 // pull up the pushbutton to prevent bouncing
aismail1997 16:5c91af9b4e7c 284 pb1.mode(PullUp);
aismail1997 16:5c91af9b4e7c 285 pb2.mode(PullUp);
aismail1997 18:d14bf57f435b 286 pb3.mode(PullUp);
aismail1997 18:d14bf57f435b 287 pb4.mode(PullUp);
aismail1997 18:d14bf57f435b 288 pb5.mode(PullUp);
aismail1997 18:d14bf57f435b 289 pb6.mode(PullUp);
aismail1997 16:5c91af9b4e7c 290 wait(.001);
aismail1997 15:7e9308d14faa 291
aismail1997 4:cc181f8f2bd1 292 // servo begins at 30 degrees
aismail1997 10:21268d8bf979 293 // replace with a button setup function
aismail1997 0:9eda4611081a 294 for(int i=0; i<=3; i++) {
aismail1997 0:9eda4611081a 295 myservo = i/100.0;
aismail1997 0:9eda4611081a 296 wait(0.01);
aismail1997 0:9eda4611081a 297 }
aismail1997 14:581a3b02f4c3 298 for(int i=0; i<=3; i++) {
aismail1997 14:581a3b02f4c3 299 myservo2 = i/100.0;
aismail1997 14:581a3b02f4c3 300 wait(0.01);
aismail1997 14:581a3b02f4c3 301 }
aismail1997 18:d14bf57f435b 302
aismail1997 18:d14bf57f435b 303 for(int i=0; i<=3; i++) {
aismail1997 18:d14bf57f435b 304 myservo3 = i/100.0;
aismail1997 18:d14bf57f435b 305 wait(0.01);
aismail1997 18:d14bf57f435b 306 }
aismail1997 18:d14bf57f435b 307
aismail1997 18:d14bf57f435b 308 for(int i=0; i<=3; i++) {
aismail1997 18:d14bf57f435b 309 myservo4 = i/100.0;
aismail1997 18:d14bf57f435b 310 wait(0.01);
aismail1997 18:d14bf57f435b 311 }
aismail1997 18:d14bf57f435b 312
aismail1997 18:d14bf57f435b 313 for(int i=0; i<=3; i++) {
aismail1997 18:d14bf57f435b 314 myservo5 = i/100.0;
aismail1997 18:d14bf57f435b 315 wait(0.01);
aismail1997 18:d14bf57f435b 316 }
aismail1997 4:cc181f8f2bd1 317
aismail1997 18:d14bf57f435b 318 for(int i=0; i<=3; i++) {
aismail1997 18:d14bf57f435b 319 myservo6 = i/100.0;
aismail1997 18:d14bf57f435b 320 wait(0.01);
aismail1997 18:d14bf57f435b 321 }
aismail1997 18:d14bf57f435b 322
aismail1997 18:d14bf57f435b 323 //led1 = 1;
aismail1997 16:5c91af9b4e7c 324 //led2 = 1;
aismail1997 18:d14bf57f435b 325 Thread t1(button_thread);
aismail1997 18:d14bf57f435b 326 Thread t2(button2_thread);
aismail1997 18:d14bf57f435b 327 Thread t3(button3_thread);
aismail1997 18:d14bf57f435b 328 Thread t4(button4_thread);
aismail1997 18:d14bf57f435b 329 Thread t5(button5_thread);
aismail1997 18:d14bf57f435b 330 Thread t6(button6_thread);
aismail1997 18:d14bf57f435b 331 t1.start(button_thread);
aismail1997 18:d14bf57f435b 332 t2.start(button2_thread);
aismail1997 18:d14bf57f435b 333 t3.start(button3_thread);
aismail1997 18:d14bf57f435b 334 t4.start(button4_thread);
aismail1997 18:d14bf57f435b 335 t5.start(button5_thread);
aismail1997 18:d14bf57f435b 336 t6.start(button6_thread);
aismail1997 14:581a3b02f4c3 337
aismail1997 14:581a3b02f4c3 338 // start threads for reset, mode, start
aismail1997 14:581a3b02f4c3 339 //Thread t1(start_thread);
aismail1997 14:581a3b02f4c3 340 //pc.printf("start thread");
aismail1997 14:581a3b02f4c3 341 //Thread t2(submit_thread);
aismail1997 14:581a3b02f4c3 342 // setup SDcard and Speaker
aismail1997 14:581a3b02f4c3 343
aismail1997 14:581a3b02f4c3 344 // when started
aismail1997 14:581a3b02f4c3 345 //while (start == 0){}
aismail1997 14:581a3b02f4c3 346 //Thread t3(button_thread);
aismail1997 14:581a3b02f4c3 347 //pc.printf("button thread");
aismail1997 14:581a3b02f4c3 348 //Thread t4(button2_thread);
aismail1997 14:581a3b02f4c3 349 //pc.printf("button2 thread");
aismail1997 14:581a3b02f4c3 350
aismail1997 14:581a3b02f4c3 351 //Thread t3(submit_thread);
aismail1997 14:581a3b02f4c3 352
aismail1997 14:581a3b02f4c3 353 // when submitted
aismail1997 14:581a3b02f4c3 354 //while (submit == 0) {}
aismail1997 14:581a3b02f4c3 355
aismail1997 14:581a3b02f4c3 356 // start button threads and submit thread
aismail1997 14:581a3b02f4c3 357 // if submit close button threads and submit thread
aismail1997 14:581a3b02f4c3 358 // check result
aismail1997 14:581a3b02f4c3 359 // play results on speaker
aismail1997 14:581a3b02f4c3 360 // save results
aismail1997 14:581a3b02f4c3 361
aismail1997 14:581a3b02f4c3 362 // read linear potentiometer
aismail1997 14:581a3b02f4c3 363 //if (linpot < 0.5) {
aismail1997 14:581a3b02f4c3 364 //float potval = linpot;
aismail1997 14:581a3b02f4c3 365 //pc.printf("linear pot: %f\n", potval);
aismail1997 18:d14bf57f435b 366
aismail1997 6:1aa86ad19af9 367 // MAIN THREAD
aismail1997 6:1aa86ad19af9 368 while(true) {
aismail1997 14:581a3b02f4c3 369 Thread::wait(500); // wait till thread is done
aismail1997 0:9eda4611081a 370 }
aismail1997 0:9eda4611081a 371 }