Erik van de Coevering
/
SSH1106_OLED
Example program for the SSH1106 library, written for LPC1768 and tested with a 1.3" 128x64 OLED LCD.
main.cpp@1:fee9be359627, 2016-12-19 (annotated)
- Committer:
- Anaesthetix
- Date:
- Mon Dec 19 23:24:18 2016 +0000
- Revision:
- 1:fee9be359627
- Parent:
- 0:160d9ed96c23
Updated sample program with drawing / buffering
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Anaesthetix | 0:160d9ed96c23 | 1 | // -- Example program for the SSH1106 library - written for LPC1768 |
Anaesthetix | 0:160d9ed96c23 | 2 | // -- Tested with a 1.3" 128x64 OLED LCD |
Anaesthetix | 0:160d9ed96c23 | 3 | |
Anaesthetix | 0:160d9ed96c23 | 4 | #include "mbed.h" |
Anaesthetix | 0:160d9ed96c23 | 5 | #include "SSH1106.h" |
Anaesthetix | 0:160d9ed96c23 | 6 | |
Anaesthetix | 0:160d9ed96c23 | 7 | SPI lcd(p11, NC, p13); // mosi, miso (nc), sclk |
Anaesthetix | 0:160d9ed96c23 | 8 | DigitalOut cs(p15); // chip select (active low) |
Anaesthetix | 0:160d9ed96c23 | 9 | DigitalOut cd(p14); // command/data (0=command, 1=data) |
Anaesthetix | 0:160d9ed96c23 | 10 | DigitalOut rst(p16); // Reset (active low) |
Anaesthetix | 0:160d9ed96c23 | 11 | |
Anaesthetix | 0:160d9ed96c23 | 12 | SSH1106 ssh1106(lcd, cs, cd, rst); |
Anaesthetix | 0:160d9ed96c23 | 13 | |
Anaesthetix | 0:160d9ed96c23 | 14 | int main() |
Anaesthetix | 0:160d9ed96c23 | 15 | { |
Anaesthetix | 0:160d9ed96c23 | 16 | ssh1106.init(); |
Anaesthetix | 0:160d9ed96c23 | 17 | wait(1); |
Anaesthetix | 0:160d9ed96c23 | 18 | ssh1106.clear(); |
Anaesthetix | 0:160d9ed96c23 | 19 | wait(1); |
Anaesthetix | 0:160d9ed96c23 | 20 | char str[40]; |
Anaesthetix | 0:160d9ed96c23 | 21 | int n = 6; |
Anaesthetix | 0:160d9ed96c23 | 22 | n = sprintf(str, "01234ABCdefghijk"); |
Anaesthetix | 0:160d9ed96c23 | 23 | while(1) { |
Anaesthetix | 1:fee9be359627 | 24 | |
Anaesthetix | 0:160d9ed96c23 | 25 | ssh1106.drawBitmap(test); |
Anaesthetix | 0:160d9ed96c23 | 26 | wait(1); |
Anaesthetix | 0:160d9ed96c23 | 27 | ssh1106.drawBitmap(einstein); |
Anaesthetix | 0:160d9ed96c23 | 28 | wait(1); |
Anaesthetix | 0:160d9ed96c23 | 29 | ssh1106.drawBitmap(biohazard); |
Anaesthetix | 0:160d9ed96c23 | 30 | wait(1); |
Anaesthetix | 0:160d9ed96c23 | 31 | ssh1106.drawBitmap(highvoltage); |
Anaesthetix | 0:160d9ed96c23 | 32 | wait(1); |
Anaesthetix | 0:160d9ed96c23 | 33 | ssh1106.drawBitmap(copter); |
Anaesthetix | 0:160d9ed96c23 | 34 | wait(1); |
Anaesthetix | 0:160d9ed96c23 | 35 | ssh1106.clear(); |
Anaesthetix | 1:fee9be359627 | 36 | ssh1106.clearBuffer(); |
Anaesthetix | 1:fee9be359627 | 37 | ssh1106.drawbufferLineHor(10, 7, 4, 108); |
Anaesthetix | 1:fee9be359627 | 38 | ssh1106.drawbufferLineVert(62, 7, 55, 4); |
Anaesthetix | 1:fee9be359627 | 39 | ssh1106.update(); |
Anaesthetix | 1:fee9be359627 | 40 | wait(1); |
Anaesthetix | 1:fee9be359627 | 41 | //ssh1106.drawLineVert(62, 10, 40, 4); |
Anaesthetix | 1:fee9be359627 | 42 | //wait(5); |
Anaesthetix | 1:fee9be359627 | 43 | ssh1106.clear(); |
Anaesthetix | 0:160d9ed96c23 | 44 | ssh1106.writeText(0,0, font_6x6, str, n); |
Anaesthetix | 0:160d9ed96c23 | 45 | ssh1106.writeText(0,1, font_7x7, str, n); |
Anaesthetix | 0:160d9ed96c23 | 46 | ssh1106.writeText(0,2, bold_font, str, n); |
Anaesthetix | 0:160d9ed96c23 | 47 | ssh1106.writeText(0,3, font_5x8, str, n); |
Anaesthetix | 0:160d9ed96c23 | 48 | ssh1106.writeText2d(0,4, font2d_hunter, str, n); |
Anaesthetix | 0:160d9ed96c23 | 49 | ssh1106.writeText(0,5, font_8x8_1, str, n); |
Anaesthetix | 0:160d9ed96c23 | 50 | ssh1106.writeText2d(0,6, font2d_formplex12, str, n); |
Anaesthetix | 0:160d9ed96c23 | 51 | ssh1106.writeText(0,7, font_4x5, str, n); |
Anaesthetix | 0:160d9ed96c23 | 52 | wait(5); |
Anaesthetix | 0:160d9ed96c23 | 53 | } |
Anaesthetix | 0:160d9ed96c23 | 54 | } |