WIP demo program for using my Hexidraw library
Demo app for using my Hexidraw library for drawing on the Hexiwear's OLED
Diff: main.cpp
- Revision:
- 1:e5806bc5d2e9
- Parent:
- 0:3975ec26d269
diff -r 3975ec26d269 -r e5806bc5d2e9 main.cpp --- a/main.cpp Fri Aug 19 01:18:32 2016 +0000 +++ b/main.cpp Fri Aug 19 22:12:34 2016 +0000 @@ -1,37 +1,36 @@ #include "mbed.h" - #include "hexidraw.h" -//DigitalOut led_red(PTC8); -//DigitalOut led_green(PTD0); +#include "images.h" + DigitalOut led_blue(PTC9); OLED oled; -// main() runs in its own thread in the OS -// (note the calls to Thread::wait below for delays) int main() { oled.begin(); oled.wake(); + oled.clear(BLACK); - oled.rect(0, 0, OLED_WIDTH, OLED_HEIGHT, BLACK); - oled.pixel(1, 1, Color565(0, 255, 0)); - uint16_t c1 = Color565(255, 0, 0); - uint16_t c2 = Color565(0, 255, 0); - uint16_t c3 = Color565(0, 0, 255); - uint8_t i = 0; + //Draw a background image + oled.image(0,0,hexi_gradiant_bmp_bmp); + + //Draw the olympic rings + uint16_t rad = 10; + uint8_t pad = 2; + uint8_t width = 3; + oled.circle(OLED_WIDTH/2, OLED_HEIGHT/2, rad, Color565(0,0,0), width); + + oled.circle((OLED_WIDTH/2)-((rad*2)+pad), OLED_HEIGHT/2, rad, Color565(0,0,255), width); + oled.circle((OLED_WIDTH/2)+((rad*2)+pad), OLED_HEIGHT/2, rad, Color565(255,0,0), width); + + oled.circle((OLED_WIDTH/2)-((rad*2)/2), OLED_HEIGHT/2+(rad+pad), rad, Color565(255,255,0), width); + oled.circle((OLED_WIDTH/2)+((rad*2)/2), OLED_HEIGHT/2+(rad+pad), rad, Color565(0,255,0), width); + + while (true) { - if(i == 0) - oled.rect(0, 0, OLED_WIDTH, OLED_HEIGHT, c1); - if(i == 1) - oled.rect(0, 0, OLED_WIDTH, OLED_HEIGHT, c2); - if(i == 2) - oled.rect(0, 0, OLED_WIDTH, OLED_HEIGHT, c3); led_blue = !led_blue; Thread::wait(500); - ++i; - if(i > 2) - i = 0; } }