Running multiple threads on mbed using RTOS
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player_appbd
Diff: main.cpp
- Revision:
- 1:2129bb91c172
- Parent:
- 0:fdcdbc5499f7
- Child:
- 2:f4ad69c44c7e
--- a/main.cpp Sun Feb 28 21:58:15 2016 +0000 +++ b/main.cpp Sun Feb 28 22:40:13 2016 +0000 @@ -2,6 +2,7 @@ #include "rtos.h" #include "uLCD_4DGL.h" #include "SDFileSystem.h" +#include "USBHostMSD.h" SDFileSystem sd(p5, p6, p7, p8, "sd"); Serial pc(USBTX, USBRX); @@ -10,21 +11,25 @@ DigitalOut myled(LED1); void ulcd2_thread(void const *args) { + int count = 0; while(true) { ulcd_mutex.lock(); pc.printf("Activated mutex lock on uLCD screen: ulcd2_thread"); uLCD.cls(); uLCD.printf("\nECE 4180 L3: RTOS\n"); //Default Green on black text uLCD.printf("\nWes Schon Nick Liu"); + uLCD.printf("\n\nThread 2 count: %d", count); uLCD.text_width(4); //4X size text uLCD.text_height(4); Thread::wait(3000); ulcd_mutex.unlock(); + count++; } } int main() { Thread thread(ulcd2_thread); + int count2 = 0; while(1) { myled = 1; Thread::wait(200); @@ -35,10 +40,12 @@ //SD card needed with image and video files for last two demos uLCD.cls(); uLCD.media_init(); - uLCD.printf("\n\nAn SD card is needed for image and video data"); + uLCD.printf("\n\nThread 1 count: %d", count2); + Thread::wait(200); uLCD.set_sector_address(0x0000, 0x0000); uLCD.display_video(0,0); - Thread::wait(3000); + Thread::wait(100); ulcd_mutex.unlock(); + count2++; } }