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