Demo program for the Oled display

Dependencies:   mbed-src

Revision:
0:94bf5ec759da
Child:
1:793dbd6d6498
diff -r 000000000000 -r 94bf5ec759da main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jan 08 12:05:23 2015 +0000
@@ -0,0 +1,53 @@
+#include "mbed.h"
+#include "OLED32028P1T.h"
+
+/*
+    This display requires 5v, 200mA power supply, serial and reset connections are 3.3v - 5v.
+    Set Oled to any serial port. It is Target dependant, some platforms may not work at
+    higher baud rates. Set baud rates as per the list in .cpp file, NOT in the program.
+    Freescale KLxx MCU's will only work upt to 128k baud and some have been defined.
+*/ 
+
+OLED32028P1T oled(PTB17,PTB16,PTC0);  // Oled Display TX, RX, RESET
+
+char timebuffer[50];
+char datebuffer[50];
+
+int main() {
+              
+    oled.init();    // initialise the display. This will start at 9600 baud then auto set
+                    // to the higher baud rate as set in the .cpp file
+                    // This can be called at any time in the program to restart the display
+                    // if required, display power down for instance.
+    
+    oled.clear();
+    oled.setTextBackgroundType(TEXT_OPAQUE);    
+    oled.setFontColor(WHITE);                   // some predefined colours
+            
+    oled.drawText(1,1,(FONT12X16)," --RTC Clock Time-- ",oled.toRGB(255,255,255));
+    oled.setFontSize(FONT12X16); 
+    oled.setFontColor(oled.toRGB(255,255,0));
+    
+         while(1){
+            
+            time_t seconds = time(NULL);
+            
+            strftime(timebuffer, 32, "RTC %I:%M:%S %p", localtime(&seconds));           
+            strftime(datebuffer, 32, "%a %d %b %Y ", localtime(&seconds));
+            
+            oled.drawText(2,3,(FONT12X16),timebuffer,oled.toRGB(255,255,0)); // print using drawText is faster
+            oled.drawText(2,4,(FONT12X16),datebuffer,oled.toRGB(255,128,0));
+            
+            oled.locate(3,6);  // print start posistion x,y in characters (not pixels)
+            oled.setFontSize(FONT12X16); // Font size  
+            
+            oled.setFontColor(oled.toRGB(255,255,255)); // 'R' 'G' 'B' can be set for upto 16 million colurs
+            oled.printf(timebuffer); // print using printf is slower than drawText
+            
+            oled.locate(3,7);
+            oled.printf(datebuffer); 
+                        
+            
+            wait(.2);       
+        } 
+}
\ No newline at end of file