music mixer code
Dependencies: mbed wave_player mbed-rtos SimpleRGB 4DGL-uLCD-SE PinDetect
Diff: main.cpp
- Revision:
- 6:648cd6a6fae2
- Parent:
- 5:420cda7cbfc5
- Child:
- 7:f3eb2b2c295d
--- a/main.cpp Tue Oct 11 02:18:19 2016 +0000 +++ b/main.cpp Tue Oct 11 02:23:07 2016 +0000 @@ -8,6 +8,7 @@ DigitalOut led(LED1); // test led uLCD_4DGL lcd(p9,p10,p11); +Mutex stdio_mutex; /* 1 init/declare Ticker first; @@ -45,6 +46,7 @@ // show reboot process, associated with clip of apple restart while (true) { // lock, print 'Rebooting!' to uLCD with "progress_bar" underneath + stdio_mutex.lock(); lcd.text_string("Rebooting", 2, 5, FONT_7X8, WHITE); // draw progress bar 8 sec for (int i = 0; i < 8; i++) { @@ -61,6 +63,7 @@ lcd.text_string(" : `-; ", 2, 9, FONT_7X8, WHITE); lcd.text_string(" `.__.-.__.' ", 2, 10, FONT_7X8, WHITE); // unlock, wait for 52 + stdio_mutex.unlock(); Thread::wait(52 * SECOND); // clear screen lcd.cls(); @@ -73,21 +76,28 @@ set_time(1476146921); while (true) { char buffer[32]; - // lock, update time at top right with smiley at top left time_t seconds = time(NULL); strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); + // lock, update time at top right with smiley at top left + stdio_mutex.lock(); lcd.text_string(buffer, 5, 1, FONT_7X8, RED); lcd.text_string(":-)", 1, 1, FONT_7X8, WHITE); // unlock, wait for 20 sec + stdio_mutex.unlock(); Thread::wait(20 * SECOND); // lock, change to frown + stdio_mutex.lock(); lcd.text_string(">:|", 1, 1, FONT_7X8, WHITE); // unlock, wait for 20 sec + stdio_mutex.unlock(); Thread::wait(20 * SECOND); // lock, change to sad + stdio_mutex.lock(); lcd.text_string(":-(", 1, 1, FONT_7X8, WHITE); // unlock, wait for 20 sec + stdio_mutex.unlock(); Thread::wait(20 * SECOND); + lcd.cls(); } }