This demo uses the mbed RTOS to run eight threads (including main). The threads are using different I/O devices on the application board. Several of the threads output to the LCD and an OS mutex lock is used to control access to the LCD and make the LCD thread safe.
Dependencies: C12832_lcd LCD_fonts mbed-rtos mbed
Fork of lab1 by
Diff: main.cpp
- Revision:
- 3:3ec443c0842a
- Parent:
- 2:a69c8c5f5b03
- Child:
- 4:79863d2ea5a0
--- a/main.cpp Fri Oct 26 18:18:33 2012 +0000 +++ b/main.cpp Wed Dec 05 08:06:20 2012 +0000 @@ -11,7 +11,7 @@ #include "C12832_lcd.h" // LCD object -C12832_LCD LCD("LCD"); +C12832_LCD LCD; AnalogIn Pot1(p19); AnalogIn Pot2(p20); @@ -29,7 +29,7 @@ lcd_mutex.lock(); LCD.locate(0,0); LCD.set_font((unsigned char*) Small_6); - printf("Thread1 count: %d",i); + LCD.printf("Thread1 count: %d",i); lcd_mutex.unlock(); i++; Thread::wait(1000); @@ -45,7 +45,7 @@ lcd_mutex.lock(); LCD.locate(0,20); LCD.set_font((unsigned char*) Arial_9); - printf("Thread 2 count : %d",k); + LCD.printf("Thread 2 count : %d",k); lcd_mutex.unlock(); k++; Thread::wait(500); // wait 0.5s @@ -111,7 +111,7 @@ LCD.locate(0,9); LCD.set_font((unsigned char*) Small_7); j = LCD.get_contrast(); // read the actual contrast - printf("contrast : %d",j); + LCD.printf("contrast : %d",j); lcd_mutex.unlock(); Thread::wait(500); // wait 0.5s }