change in mbed rtos library

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

Fork of rtos_basic by mbed official

main.cpp

Committer:
bjs9
Date:
2018-02-28
Revision:
12:fb46c68fa360
Parent:
11:0309bef74ba8
Child:
13:b0bfe7f4472a

File content as of revision 12:fb46c68fa360:

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


DigitalOut led1(LED1);
DigitalOut led2(LED2);
Thread thread;
Thread thread2;
Thread thread3;
Thread thread4;
Mutex stdio_mutex;
uLCD_4DGL uLCD(p28,p27,p29);
RGBLed myRGBled(p22,p23,p24);
void printName() {
  stdio_mutex.lock();
  uLCD.printf("\nMy name is Barry Johnson-Smith\n");
  //Time to dance at same time as color changing.
  uLCD.cls();
  stdio_mutex.unlock();
 }
void colorULCD() {
  stdio_mutex.lock();
  uLCD.line(60,80,60,0,128*65536+128*256+128);
  uLCD.filled_circle(60,60,20,RED);
  Thread::wait(500);
  uLCD.line(60,80,60,0,128*65536+128*256+128);
  uLCD.filled_circle(60,60,20,BLUE);
  Thread::wait(500);
  uLCD.line(60,80,60,0,128*65536+128*256+128);
  uLCD.filled_circle(60,60,20,RED);
  Thread::wait(500);
  uLCD.line(60,80,60,0,128*65536+128*256+128);
  uLCD.filled_circle(60,60,20, 255*65536+165*256+0);
  Thread::wait(500);
  uLCD.line(60,80,60,0,128*65536+128*256+128);
  uLCD.filled_circle(60,60,20,255*65536+255*256+0);
  Thread::wait(500);
  uLCD.line(60,80,60,0,128*65536+128*256+128);
  uLCD.filled_circle(60,60,20,GREEN);
  Thread::wait(500);
  uLCD.line(60,80,60,0,128*65536+128*256+128);
  uLCD.filled_circle(60,60,20,BLUE);
  Thread::wait(500);
  uLCD.line(60,80,60,0,128*65536+128*256+128);
  uLCD.filled_circle(60,60,20,75*65536+0*256+130);
  Thread::wait(500);
  uLCD.line(60,80,60,0,128*65536+128*256+128);
  uLCD.filled_circle(60,60,20,128*65536+0*256+128);
  stdio_mutex.unlock();
 }
 
void uLCD_thread1() {
    while (true) {
    colorULCD();
    Thread::wait(500);
    }
        
}
void uLCD_thread2() {
    while (true) {
    printName();
    Thread::wait(1000);    
    }
    
 }
void RGB_LED() {
  while(true) {
  myRGBled.write(1.0f, 0, 0); // turn the RGB LED red 
  Thread::wait(500); // wait for 1 second 
  myRGBled.write(0, 0, 255); // turn the RGB LED blue 
  Thread::wait(500); // wait for 1 second 
  // Example blended myRGBled.writes: 
  myRGBled.write(255,0,0); // turn the RGB LED red 
  Thread::wait(500); // wait for 1 second 
  myRGBled.write(237,109,0); // turn the RGB LED orange 
  Thread::wait(500); // wait for 1 second 
  myRGBled.write(255,215,0); // turn the RGB LED yellow 
  Thread::wait(500); // wait for 1 second 
  myRGBled.write(34,139,34); // turn the RGB LED green 
  Thread::wait(500); // wait for 1 second 
  myRGBled.write(0,0,255); // turn the RGB LED blue 
  Thread::wait(050); // wait for 1 second
  myRGBled.write(0,46,90); // turn the RGB LED indigo 
  Thread::wait(500); // wait for 1 second
  myRGBled.write(128,0,128); // turn the RGB LED purple 
  Thread::wait(500); // wait for 1 second
  }
} 
int main() {
   thread.start(uLCD_thread1);
    //thread2.start(uLCD_thread2);
    thread3.start(RGB_LED);  
}