Threads
Dependencies: mbed mbed-rtos C12832_lcd LCD_fonts
Diff: main.cpp
- Revision:
- 4:e1e874f4c973
- Parent:
- 3:3ec443c0842a
- Child:
- 5:9f4b49b1adbf
--- a/main.cpp Wed Dec 05 08:06:20 2012 +0000 +++ b/main.cpp Sat Jun 20 10:44:28 2020 +0000 @@ -10,15 +10,31 @@ #include "stdio.h" #include "C12832_lcd.h" -// LCD object +BusIn joy(p15,p12,p13,p16); +DigitalIn fire(p14); +BusOut leds(LED1,LED2,LED3,LED4); C12832_LCD LCD; - AnalogIn Pot1(p19); AnalogIn Pot2(p20); +Mutex lcd_mutex; -// mutex to make the lcd lib thread save -Mutex lcd_mutex; +// Thread 0 +// LEDs controlled by JOYSTICK +void thread0(void const *args) +{ + int j; + while(true) { // thread loop + if (fire) { + leds=0xf; + } else { + leds=joy; + } + wait(0.1); + } +} + + // Thread 1 // print counter into first line and wait for 1 s @@ -101,6 +117,7 @@ int j; LCD.cls(); + Thread t0(thread0); //start thread0 Thread t1(thread1); //start thread1 Thread t2(thread2); //start thread2 Thread t3(thread3); //start thread3