Example showing usage of text and image. Builds on the text example with a banner image at the bottom of the screen.

Dependencies:   Hexi_OLED_SSD1351

Fork of Hexi_OLED_Text_Example by Hexiwear

Committer:
cotigac
Date:
Sun Aug 28 16:45:05 2016 +0000
Revision:
4:5625985ca4a4
Parent:
3:cc5f8e152f7f
removed dependencies to font and oled types

Who changed what in which revision?

UserRevisionLine numberNew contents of line
khuang 0:a1af4ae04b06 1 #include "mbed.h"
khuang 0:a1af4ae04b06 2 #include "Hexi_OLED_SSD1351.h"
khuang 0:a1af4ae04b06 3 #include "string.h"
khuang 2:47c3dad2c8ef 4 #include "images.h"
khuang 0:a1af4ae04b06 5
khuang 0:a1af4ae04b06 6 int main() {
khuang 1:42e8e50ae4ac 7 char text[20]; /* Text Buffer */
khuang 1:42e8e50ae4ac 8 Timer time; /* Instantiate Time */
khuang 0:a1af4ae04b06 9
khuang 1:42e8e50ae4ac 10 /* Instantiate the SSD1351 OLED Driver */
khuang 1:42e8e50ae4ac 11 SSD1351 oled(PTB22,PTB21,PTC13,PTB20,PTE6, PTD15); /* (MOSI,SCLK,POWER,CS,RST,DC) */
khuang 0:a1af4ae04b06 12
khuang 1:42e8e50ae4ac 13 /* Get OLED Class Default Text Properties */
khuang 1:42e8e50ae4ac 14 oled_text_properties_t textProperties = {0};
khuang 1:42e8e50ae4ac 15 oled.GetTextProperties(&textProperties);
khuang 0:a1af4ae04b06 16
khuang 1:42e8e50ae4ac 17 /* Turn on the backlight of the OLED Display */
khuang 1:42e8e50ae4ac 18 oled.DimScreenON();
khuang 1:42e8e50ae4ac 19
khuang 1:42e8e50ae4ac 20 /* Fills the screen with solid black */
khuang 1:42e8e50ae4ac 21 oled.FillScreen(COLOR_BLACK);
khuang 1:42e8e50ae4ac 22
khuang 1:42e8e50ae4ac 23 /* Display Text at (x=7,y=0) */
khuang 1:42e8e50ae4ac 24 strcpy((char *) text,"TEXT EXAMPLE");
khuang 1:42e8e50ae4ac 25 oled.Label((uint8_t *)text,7,0);
khuang 1:42e8e50ae4ac 26
khuang 1:42e8e50ae4ac 27 /* Change font color to blue */
khuang 1:42e8e50ae4ac 28 textProperties.fontColor = COLOR_BLUE;
khuang 0:a1af4ae04b06 29 oled.SetTextProperties(&textProperties);
khuang 0:a1af4ae04b06 30
khuang 1:42e8e50ae4ac 31 /* Display text at (x=5,y=40) */
khuang 0:a1af4ae04b06 32 strcpy(text,"Timer(s):");
khuang 1:42e8e50ae4ac 33 oled.Label((uint8_t *)text,5,40);
khuang 2:47c3dad2c8ef 34
khuang 1:42e8e50ae4ac 35 /* Set text properties to white and right aligned for the dynamic text */
khuang 0:a1af4ae04b06 36 textProperties.fontColor = COLOR_WHITE;
khuang 1:42e8e50ae4ac 37 textProperties.alignParam = OLED_TEXT_ALIGN_RIGHT;
khuang 0:a1af4ae04b06 38 oled.SetTextProperties(&textProperties);
khuang 2:47c3dad2c8ef 39
khuang 2:47c3dad2c8ef 40 /* Adding Banner Image to bottom of screen */
khuang 2:47c3dad2c8ef 41 /* Setting pointer location of the 96 by 32 pixel bitmap */
khuang 2:47c3dad2c8ef 42 const uint8_t *image = NXP_banner_bmp;
khuang 2:47c3dad2c8ef 43 /* Draws the image on the Screen starting at (x=0,y=64) */
khuang 2:47c3dad2c8ef 44 oled.DrawImage(image,0,64);
khuang 0:a1af4ae04b06 45
khuang 1:42e8e50ae4ac 46 time.start(); /* start timer */
khuang 0:a1af4ae04b06 47
khuang 0:a1af4ae04b06 48 while (true) {
khuang 1:42e8e50ae4ac 49
khuang 1:42e8e50ae4ac 50 /* Format the time reading */
khuang 1:42e8e50ae4ac 51 sprintf(text,"%.2f",time.read());
khuang 0:a1af4ae04b06 52
khuang 1:42e8e50ae4ac 53 /* Display time reading in 35px by 15px textbox at(x=55, y=40) */
khuang 3:cc5f8e152f7f 54 oled.TextBox((uint8_t *)text,55,40,35,15); /*Expand textbox for more digits*/
khuang 1:42e8e50ae4ac 55
khuang 0:a1af4ae04b06 56 Thread::wait(1000);
khuang 0:a1af4ae04b06 57 }
khuang 0:a1af4ae04b06 58 }
khuang 0:a1af4ae04b06 59
khuang 0:a1af4ae04b06 60
khuang 0:a1af4ae04b06 61
khuang 0:a1af4ae04b06 62