![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Lab5: control 4 leds using soft touch keys
Fork of TSI_sample by
Revision 7:b6af45200e4e, committed 2018-03-02
- Comitter:
- natgovor
- Date:
- Fri Mar 02 14:19:29 2018 +0000
- Parent:
- 6:e1330d423bc3
- Commit message:
- Chenged the raises of events
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Mar 01 15:17:54 2018 +0000 +++ b/main.cpp Fri Mar 02 14:19:29 2018 +0000 @@ -11,7 +11,6 @@ TSISensor tsi; DigitalOut leds[4] = { PTA13, PTD5, PTD0, PTD2 }; -//Thread threads[4] ; Thread thread1(osPriorityNormal, 1000); // thread for LED1 Thread thread2(osPriorityNormal, 1000); // thread for LED2 Thread thread3(osPriorityNormal, 1000); // thread for LED3 @@ -49,6 +48,7 @@ for (int i=0; i<4; i++) { // turn off all leds leds[i] = 0; } + thread1.start(&led1_thread); thread2.start(&led2_thread); thread3.start(&led3_thread); @@ -66,38 +66,38 @@ pc.printf("none\n\r"); if (pos > 3 && pos < 9) { state = leftOut; + thread1.signal_set(0x1); } else if (pos > 13 && pos < 19) { state = leftIn; + thread2.signal_set(0x1); } else if (pos > 23 && pos < 29) { state = rightIn; + thread3.signal_set(0x1); } else if (pos > 33) { state = rightOut; + thread4.signal_set(0x1); } break; case leftOut: pc.printf("leftOut\n\r"); - thread1.signal_set(0x1); if (pos < 3 || pos > 9) { state = none; } break; case leftIn: pc.printf("leftIn\n\r"); - thread2.signal_set(0x1); if (pos < 13 || pos > 19) { state = none; } break; case rightIn: pc.printf("rightIn\n\r"); - thread3.signal_set(0x1); if (pos < 23 || pos > 29) { state = none; } break; case rightOut: pc.printf("rightOut\n\r"); - thread4.signal_set(0x1); if (pos < 33) { state = none; }