Chris Taylor
/
LCD_DEMO
LCD Graphics Demo
Revision 1:9ef80594d458, committed 2015-02-01
- Comitter:
- taylorza
- Date:
- Sun Feb 01 06:59:26 2015 +0000
- Parent:
- 0:7260a2716edf
- Commit message:
- Enhanced demo to show the new font and the measure font function.
Changed in this revision
LCD_ST7735.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/LCD_ST7735.lib Tue Jan 13 01:52:04 2015 +0000 +++ b/LCD_ST7735.lib Sun Feb 01 06:59:26 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/taylorza/code/LCD_ST7735/#7ecd74dcb8ef +http://mbed.org/users/taylorza/code/LCD_ST7735/#c94d0a2c2ba0
--- 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);