Displays a full size image (96px by 96px) on the Hexiwear OLED display then displays a smaller image (96px by 32px) on the bottom portion of the display.
Dependencies: Hexi_OLED_SSD1351
Fork of Hexi_OLED_Image_Example by
main.cpp@0:64580390e64a, 2016-08-18 (annotated)
- Committer:
- khuang
- Date:
- Thu Aug 18 23:55:29 2016 +0000
- Revision:
- 0:64580390e64a
- Child:
- 1:ecdf33275ec0
Hexiwear Image Example; Displays whole image on entire screen then displays smaller image on bottom portion of screen.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
khuang | 0:64580390e64a | 1 | #include "mbed.h" |
khuang | 0:64580390e64a | 2 | #include "rtos.h" |
khuang | 0:64580390e64a | 3 | #include "Hexi_OLED_SSD1351.h" |
khuang | 0:64580390e64a | 4 | #include "images.h" |
khuang | 0:64580390e64a | 5 | #include "OLED_types.h" |
khuang | 0:64580390e64a | 6 | #include "OLED_fonts.h" |
khuang | 0:64580390e64a | 7 | |
khuang | 0:64580390e64a | 8 | /* |
khuang | 0:64580390e64a | 9 | Bitmaps need to be formatted as 16bppRgb565, flipped vertically |
khuang | 0:64580390e64a | 10 | and a 6 byte header needs to be appended at the start of the array. |
khuang | 0:64580390e64a | 11 | Use the following tool to create arrays for images. |
khuang | 0:64580390e64a | 12 | https://github.com/MikroElektronika/HEXIWEAR/tree/master/SW/ResourceCollectionTool |
khuang | 0:64580390e64a | 13 | It takes an image and outputs the array. It handles the flipping and the 6 byte header. |
khuang | 0:64580390e64a | 14 | Image needs to be converted outside the tool to fit the screen (96px by 96px). |
khuang | 0:64580390e64a | 15 | */ |
khuang | 0:64580390e64a | 16 | |
khuang | 0:64580390e64a | 17 | int main() { |
khuang | 0:64580390e64a | 18 | |
khuang | 0:64580390e64a | 19 | //Pointer for the image to be displayed |
khuang | 0:64580390e64a | 20 | const uint8_t *image1; |
khuang | 0:64580390e64a | 21 | const uint8_t *image2; |
khuang | 0:64580390e64a | 22 | |
khuang | 0:64580390e64a | 23 | //Setting pointer location of the 96 by 96 pixel bitmap |
khuang | 0:64580390e64a | 24 | image1 = NXP_whole_bmp; |
khuang | 0:64580390e64a | 25 | |
khuang | 0:64580390e64a | 26 | //Setting pointer location of the 96 by 32 pixel bitmap |
khuang | 0:64580390e64a | 27 | image2 = NXP_banner_bmp; |
khuang | 0:64580390e64a | 28 | |
khuang | 0:64580390e64a | 29 | //Instantiate the SSD1351 OLED Driver |
khuang | 0:64580390e64a | 30 | SSD1351 oled(PTB22,PTB21,PTC13,PTB20,PTE6, PTD15); // (MOSI,SCLK,POWER,CS,RST,DC) |
khuang | 0:64580390e64a | 31 | |
khuang | 0:64580390e64a | 32 | //Turn on the backlight of the OLED Display |
khuang | 0:64580390e64a | 33 | oled.DimScreenON(); |
khuang | 0:64580390e64a | 34 | |
khuang | 0:64580390e64a | 35 | while (true) { |
khuang | 0:64580390e64a | 36 | |
khuang | 0:64580390e64a | 37 | //Fill the screen with white to overwrite previous image |
khuang | 0:64580390e64a | 38 | oled.FillScreen(COLOR_WHITE); |
khuang | 0:64580390e64a | 39 | //Fill 96px by 96px Screen with 96px by 96px NXP Image starting at x=0,y=0 |
khuang | 0:64580390e64a | 40 | oled.DrawImage(image1,0,0); |
khuang | 0:64580390e64a | 41 | |
khuang | 0:64580390e64a | 42 | Thread::wait(2000); |
khuang | 0:64580390e64a | 43 | |
khuang | 0:64580390e64a | 44 | //Fill the screen with white to overwrite previous image |
khuang | 0:64580390e64a | 45 | oled.FillScreen(COLOR_WHITE); |
khuang | 0:64580390e64a | 46 | //Draw 96px by 32px NXP Banner at the bottom by setting x =0,y=64(96-32) |
khuang | 0:64580390e64a | 47 | oled.DrawImage(image2,0,64); |
khuang | 0:64580390e64a | 48 | |
khuang | 0:64580390e64a | 49 | Thread::wait(2000); |
khuang | 0:64580390e64a | 50 | |
khuang | 0:64580390e64a | 51 | } |
khuang | 0:64580390e64a | 52 | } |
khuang | 0:64580390e64a | 53 |