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
main.cpp
00001 #include "mbed.h" 00002 #include "Hexi_OLED_SSD1351.h" 00003 #include "string.h" 00004 #include "images.h" 00005 00006 int main() { 00007 char text[20]; /* Text Buffer */ 00008 Timer time; /* Instantiate Time */ 00009 00010 /* Instantiate the SSD1351 OLED Driver */ 00011 SSD1351 oled(PTB22,PTB21,PTC13,PTB20,PTE6, PTD15); /* (MOSI,SCLK,POWER,CS,RST,DC) */ 00012 00013 /* Get OLED Class Default Text Properties */ 00014 oled_text_properties_t textProperties = {0}; 00015 oled.GetTextProperties(&textProperties); 00016 00017 /* Turn on the backlight of the OLED Display */ 00018 oled.DimScreenON(); 00019 00020 /* Fills the screen with solid black */ 00021 oled.FillScreen(COLOR_BLACK); 00022 00023 /* Display Text at (x=7,y=0) */ 00024 strcpy((char *) text,"TEXT EXAMPLE"); 00025 oled.Label((uint8_t *)text,7,0); 00026 00027 /* Change font color to blue */ 00028 textProperties.fontColor = COLOR_BLUE; 00029 oled.SetTextProperties(&textProperties); 00030 00031 /* Display text at (x=5,y=40) */ 00032 strcpy(text,"Timer(s):"); 00033 oled.Label((uint8_t *)text,5,40); 00034 00035 /* Set text properties to white and right aligned for the dynamic text */ 00036 textProperties.fontColor = COLOR_WHITE; 00037 textProperties.alignParam = OLED_TEXT_ALIGN_RIGHT; 00038 oled.SetTextProperties(&textProperties); 00039 00040 /* Adding Banner Image to bottom of screen */ 00041 /* Setting pointer location of the 96 by 32 pixel bitmap */ 00042 const uint8_t *image = NXP_banner_bmp; 00043 /* Draws the image on the Screen starting at (x=0,y=64) */ 00044 oled.DrawImage(image,0,64); 00045 00046 time.start(); /* start timer */ 00047 00048 while (true) { 00049 00050 /* Format the time reading */ 00051 sprintf(text,"%.2f",time.read()); 00052 00053 /* Display time reading in 35px by 15px textbox at(x=55, y=40) */ 00054 oled.TextBox((uint8_t *)text,55,40,35,15); /*Expand textbox for more digits*/ 00055 00056 Thread::wait(1000); 00057 } 00058 } 00059 00060 00061 00062
Generated on Wed Jul 13 2022 03:00:20 by 1.7.2