Running multiple threads on mbed using RTOS

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player_appbd

main.cpp

Committer:
wschon
Date:
2016-02-28
Revision:
0:fdcdbc5499f7
Child:
1:2129bb91c172

File content as of revision 0:fdcdbc5499f7:

#include "mbed.h"
#include "rtos.h"
#include "uLCD_4DGL.h"
#include "SDFileSystem.h"

SDFileSystem sd(p5, p6, p7, p8, "sd"); 
Serial pc(USBTX, USBRX);
Mutex ulcd_mutex;
uLCD_4DGL uLCD(p9,p10,p11); // serial tx, serial rx, reset pin;
DigitalOut myled(LED1);

void ulcd2_thread(void const *args) {
    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.text_width(4); //4X size text
        uLCD.text_height(4);
        Thread::wait(3000);
        ulcd_mutex.unlock();
        }
    }

int main() {
    Thread thread(ulcd2_thread);
    while(1) {
        myled = 1;
        Thread::wait(200);
        myled = 0;
        Thread::wait(200);
        ulcd_mutex.lock();
        uLCD.cls();
    //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.set_sector_address(0x0000, 0x0000);
        uLCD.display_video(0,0);
        Thread::wait(3000);
        ulcd_mutex.unlock();
    }
}