Manuel Campos
/
TSI_sample_cvmanuel
first version
Fork of TSI_sample by
Revision 4:1654ec08fde4, committed 2018-03-01
- Comitter:
- cvmanuel
- Date:
- Thu Mar 01 03:18:40 2018 +0000
- Parent:
- 3:adf1bff83db6
- Commit message:
- first version;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Mar 01 02:10:30 2018 +0000 +++ b/main.cpp Thu Mar 01 03:18:40 2018 +0000 @@ -64,8 +64,8 @@ blueLED = false; Thread::wait(5000); greenLED = true ; // turn off - redLED = false; - blueLED = false; + redLED = true; + blueLED = true; greenThread.signal_clr(0x1) ; // Signal are automatically cleared by wait_signal but // the signal might have been set again while LED on @@ -79,37 +79,36 @@ greenLED = true ; // turn off redThread.start(&red_thread) ; // start the red thread greenThread.start(&green_thread) ; // start the green thread + blueThread.start(&blue_thread) ; // start the blue thread + allThread.start(&all_thread) ; // start the all thread softkeys key = grey; while (true) { uint8_t d = tsi.readDistance() ; // Distance is between 0 and 39 - - - - - - // When no touch --> 0 - // Left --> low value Right --> high value if(d>3 && d <9) { key = outer_left; + redThread.signal_set(0x1) ; } else if( d>13 && d < 19) { key=inner_left; + greenThread.signal_set(0x1) ; }else if(d>23 && d < 29) { key = inner_right; + blueThread.signal_set(0x1) ; }else if(d>33) { key = outer_right; + allThread.signal_set(0x1) ; } switch(key){ @@ -133,15 +132,16 @@ key = grey; } break ; + case grey: + greenLED = true ; // turn off + redLED = true; + blueLED = true; + break; } - - - + pc.printf("%d", d) ; pc.putc(' ') ; - pc.printf("\r"); - if (d == 10) redThread.signal_set(0x1) ; - if (d == 20) greenThread.signal_set(0x1) ; + Thread::wait(200); // This polling rate is too slow - increase it // The slower rate maks it easier to output on the terminal }