~
Dependencies: mbed SimpleRGB mbed-rtos 4DGL-uLCD-SE SDFileSystem wave_player
Diff: main.cpp
- Revision:
- 5:420cda7cbfc5
- Parent:
- 4:4792f0db029a
- Child:
- 6:648cd6a6fae2
diff -r 4792f0db029a -r 420cda7cbfc5 main.cpp --- a/main.cpp Tue Oct 11 01:18:40 2016 +0000 +++ b/main.cpp Tue Oct 11 02:18:19 2016 +0000 @@ -1,12 +1,13 @@ #include "mbed.h" #include "rtos.h" +#include <string> #include "uLCD_4DGL.h" #include "SimpleRGB.h" #define SECOND 1000 // used with threads DigitalOut led(LED1); // test led -uLCD_4DGL lcd(p13,p14,p12); +uLCD_4DGL lcd(p9,p10,p11); /* 1 init/declare Ticker first; @@ -46,17 +47,23 @@ // lock, print 'Rebooting!' to uLCD with "progress_bar" underneath lcd.text_string("Rebooting", 2, 5, FONT_7X8, WHITE); // draw progress bar 8 sec - std::string progress("|"); for (int i = 0; i < 8; i++) { - lcd.text_string(progress, 2, 6, FONT_7X8, WHITE); - progress += '|'; - wait(SECOND); + lcd.text_string("|", 2 + i, 6, FONT_7X8, WHITE); + // progress[i+1] += arr[i]; + Thread::wait(SECOND); } // draw an ascii 'apple' - lcd.text_string("(_`_)", 2, 5, FONT_7X8, WHITE); - lcd.text_string("", 2, 6, FONT_7X8, WHITE); + lcd.text_string(" .:' ", 2, 4, FONT_7X8, WHITE); + lcd.text_string(" :' ", 2, 5, FONT_7X8, WHITE); + lcd.text_string(" .'` `-' ``. ", 2, 6, FONT_7X8, WHITE); + lcd.text_string(": .-' ", 2, 7, FONT_7X8, WHITE); + lcd.text_string(": : ", 2, 8, FONT_7X8, WHITE); + lcd.text_string(" : `-; ", 2, 9, FONT_7X8, WHITE); + lcd.text_string(" `.__.-.__.' ", 2, 10, FONT_7X8, WHITE); // unlock, wait for 52 - wait(52*SECOND); + Thread::wait(52 * SECOND); + // clear screen + lcd.cls(); } } @@ -65,22 +72,22 @@ // show time with smile, frown, sad face at top right set_time(1476146921); while (true) { + char buffer[32]; // lock, update time at top right with smiley at top left time_t seconds = time(NULL); - char buffer[32]; strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); lcd.text_string(buffer, 5, 1, FONT_7X8, RED); lcd.text_string(":-)", 1, 1, FONT_7X8, WHITE); // unlock, wait for 20 sec - wait(20*SECOND); + Thread::wait(20 * SECOND); // lock, change to frown lcd.text_string(">:|", 1, 1, FONT_7X8, WHITE); // unlock, wait for 20 sec - wait(20*SECOND); + Thread::wait(20 * SECOND); // lock, change to sad lcd.text_string(":-(", 1, 1, FONT_7X8, WHITE); // unlock, wait for 20 sec - wait(20*SECOND); + Thread::wait(20 * SECOND); } } @@ -133,7 +140,7 @@ /* 2 calls */ - //Thread thread2(uLCD_reboot_thread); + Thread thread2(uLCD_reboot_thread); //Thread thread3(uLCD_status_thread); Thread thread4(rainbow_led_thread); // - 2