LCD Graphics Demo

Dependencies:   LCD_ST7735 mbed

Revision:
1:9ef80594d458
Parent:
0:7260a2716edf
--- a/main.cpp	Tue Jan 13 01:52:04 2015 +0000
+++ b/main.cpp	Sun Feb 01 06:59:26 2015 +0000
@@ -1,6 +1,7 @@
 #include "mbed.h"
 #include "Color565.h"
 #include "font_IBM.h"
+#include "font_OEM.h"
 #include "LCD_ST7735.h"
 
 static const uint16_t bmp[] = {
@@ -33,13 +34,29 @@
     P0_2,
     LCD_ST7735::RGB);
 
+const char *text = "LCD Demo";
+
 main()
 {
     Surface.setOrientation(LCD_ST7735::Rotate270, false);
     
     Surface.setForegroundColor(Color565::White);
     Surface.setBackgroundColor(Color565::Blue);
-    Surface.drawString(font_ibm, 48, 0, "LCD Demo");
+    
+    uint8_t width;
+    uint8_t height;
+    int     x;
+    
+    Surface.measureString(font_ibm, text, width, height);
+    x = (160 - width) / 2;
+    Surface.drawString(font_ibm, x, 0, "LCD Demo");
+    Surface.fillRect(x, height + 2, x + width, height + 4, Color565::Red, Color565::Red);
+        
+    Surface.measureString(font_oem, text, width, height);
+    x = (160 - width) / 2;
+    Surface.drawString(font_oem, x, 16, "LCD Demo");
+    Surface.fillRect(x, 16 + height + 2, x + width, 16 + height + 4, Color565::Green, Color565::Green);
+    
     
     while (true) {
         Surface.drawBitmap(72, 56, bmp, 0, 0, 16, 16);