Paul Staron
/
Oled-SSD1331
Initial demo code
Diff: main.cpp
- Revision:
- 0:eb819dd71954
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 23 16:54:44 2016 +0000 @@ -0,0 +1,121 @@ +#include "mbed.h" +#include "ssd1331.h" + +ssd1331 oled(D8, D7, D10, D11, NC, D13); // cs, res, dc, miso, (nc), sck + + +char Time[50],Date[50]; +void gettime(); + +int main() { + + + while(1){ + + oled.Fill_Screen(oled.toRGB(255,0,0)); //red + // oled.dim(); + wait_ms(500); + oled.Fill_Screen(oled.toRGB(0,255,0)); //full green color in OLED + // oled.dim(); + wait_ms(500); + oled.Fill_Screen(oled.toRGB(0,0,255)); //full blue color in OLED + wait_ms(500); + oled.Fill_Screen(oled.toRGB(255,255,255)); //full blue color in OLED + wait_ms(500); + + oled.cls(); + + oled.circle (20, 40, 30 ,oled.toRGB(0,0,255) , 1); + oled.circle (20, 40, 30 ,oled.toRGB(255,255,255) , 0); + oled.circle (20, 60, 40 ,oled.toRGB(255,0,0) , 0); + oled.line( 0, 0, width, height, oled.toRGB(0,255,255)); + oled.line( width, 0, 0, height, oled.toRGB(255,0,255)); + oled.rect(10,10,90,60,oled.toRGB(255,255,0)); + oled.fillrect(20,20,40,40,oled.toRGB(255,255,255),oled.toRGB(0,255,0)); + + for(int y = 9; y >= 0; y--) { + oled.contrast(y); + oled.foreground(oled.toRGB(255,255,255)); + oled.locate(1, 10); + oled.printf("%d",y); + wait_ms(300); + } + + wait_ms(1000); + oled.contrast(9); + wait_ms(2000); + oled.cls(); + + oled.SetFontSize(HIGH); + oled.foreground(oled.toRGB(0,255,0)); + oled.locate(0, 10); + oled.printf( "HIGH 12345"); + + oled.SetFontSize(WIDE); + oled.foreground(oled.toRGB(0,0,255)); + oled.locate(0, 28); + oled.printf( "WIDE 123"); + + oled.SetFontSize(WH); + oled.foreground(oled.toRGB(255,0,0)); + oled.locate(0, 40); + oled.printf( "WH 123"); + + oled.SetFontSize(NORMAL); + oled.foreground(oled.toRGB(255,255,255)); + + oled.ScrollSet(0,8,18,1,0); + oled.Scrollstart(); + + gettime(); + wait(1); + gettime(); + wait(1); + gettime(); + wait(1); + + oled.ScrollSet(0,8,18,-2,0); + // oled.Scrollstart(); + + gettime(); + wait(1); + gettime(); + wait(1); + gettime(); + wait(1); + + oled.ScrollSet(0,8,18,3,0); + // oled.Scrollstart(); + + gettime(); + wait(1); + gettime(); + wait(1); + gettime(); + wait(1); + + oled.ScrollSet(0,8,18,-4,0); + // oled.Scrollstart(); + + gettime(); + wait(1); + gettime(); + wait(1); + gettime(); + wait(1); + + oled.Scrollstop(); + wait(1); + + // while(1); + } +} +void gettime() +{ + time_t seconds = time(NULL); + strftime(Time,40,"%H:%M:%S %a", localtime(&seconds)); + strftime(Date,40,"%d-%b-%Y", localtime(&seconds)); + oled.locate(0, 0); + oled.printf(Time); +} +