Paul Staron
/
Oled-SSD1331
Initial demo code
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "ssd1331.h" 00003 00004 ssd1331 oled(D8, D7, D10, D11, NC, D13); // cs, res, dc, miso, (nc), sck 00005 00006 00007 char Time[50],Date[50]; 00008 void gettime(); 00009 00010 int main() { 00011 00012 00013 while(1){ 00014 00015 oled.Fill_Screen(oled.toRGB(255,0,0)); //red 00016 // oled.dim(); 00017 wait_ms(500); 00018 oled.Fill_Screen(oled.toRGB(0,255,0)); //full green color in OLED 00019 // oled.dim(); 00020 wait_ms(500); 00021 oled.Fill_Screen(oled.toRGB(0,0,255)); //full blue color in OLED 00022 wait_ms(500); 00023 oled.Fill_Screen(oled.toRGB(255,255,255)); //full blue color in OLED 00024 wait_ms(500); 00025 00026 oled.cls(); 00027 00028 oled.circle (20, 40, 30 ,oled.toRGB(0,0,255) , 1); 00029 oled.circle (20, 40, 30 ,oled.toRGB(255,255,255) , 0); 00030 oled.circle (20, 60, 40 ,oled.toRGB(255,0,0) , 0); 00031 oled.line( 0, 0, width, height, oled.toRGB(0,255,255)); 00032 oled.line( width, 0, 0, height, oled.toRGB(255,0,255)); 00033 oled.rect(10,10,90,60,oled.toRGB(255,255,0)); 00034 oled.fillrect(20,20,40,40,oled.toRGB(255,255,255),oled.toRGB(0,255,0)); 00035 00036 for(int y = 9; y >= 0; y--) { 00037 oled.contrast(y); 00038 oled.foreground(oled.toRGB(255,255,255)); 00039 oled.locate(1, 10); 00040 oled.printf("%d",y); 00041 wait_ms(300); 00042 } 00043 00044 wait_ms(1000); 00045 oled.contrast(9); 00046 wait_ms(2000); 00047 oled.cls(); 00048 00049 oled.SetFontSize(HIGH); 00050 oled.foreground(oled.toRGB(0,255,0)); 00051 oled.locate(0, 10); 00052 oled.printf( "HIGH 12345"); 00053 00054 oled.SetFontSize(WIDE); 00055 oled.foreground(oled.toRGB(0,0,255)); 00056 oled.locate(0, 28); 00057 oled.printf( "WIDE 123"); 00058 00059 oled.SetFontSize(WH); 00060 oled.foreground(oled.toRGB(255,0,0)); 00061 oled.locate(0, 40); 00062 oled.printf( "WH 123"); 00063 00064 oled.SetFontSize(NORMAL); 00065 oled.foreground(oled.toRGB(255,255,255)); 00066 00067 oled.ScrollSet(0,8,18,1,0); 00068 oled.Scrollstart(); 00069 00070 gettime(); 00071 wait(1); 00072 gettime(); 00073 wait(1); 00074 gettime(); 00075 wait(1); 00076 00077 oled.ScrollSet(0,8,18,-2,0); 00078 // oled.Scrollstart(); 00079 00080 gettime(); 00081 wait(1); 00082 gettime(); 00083 wait(1); 00084 gettime(); 00085 wait(1); 00086 00087 oled.ScrollSet(0,8,18,3,0); 00088 // oled.Scrollstart(); 00089 00090 gettime(); 00091 wait(1); 00092 gettime(); 00093 wait(1); 00094 gettime(); 00095 wait(1); 00096 00097 oled.ScrollSet(0,8,18,-4,0); 00098 // oled.Scrollstart(); 00099 00100 gettime(); 00101 wait(1); 00102 gettime(); 00103 wait(1); 00104 gettime(); 00105 wait(1); 00106 00107 oled.Scrollstop(); 00108 wait(1); 00109 00110 // while(1); 00111 } 00112 } 00113 void gettime() 00114 { 00115 time_t seconds = time(NULL); 00116 strftime(Time,40,"%H:%M:%S %a", localtime(&seconds)); 00117 strftime(Date,40,"%d-%b-%Y", localtime(&seconds)); 00118 oled.locate(0, 0); 00119 oled.printf(Time); 00120 } 00121
Generated on Sat Jul 23 2022 17:58:04 by 1.7.2