Example program for the SSH1106 library, written for LPC1768 and tested with a 1.3" 128x64 OLED LCD.

Dependencies:   SSH1106 mbed

Committer:
Anaesthetix
Date:
Mon Dec 19 15:05:35 2016 +0000
Revision:
0:160d9ed96c23
Child:
1:fee9be359627
-

Who changed what in which revision?

UserRevisionLine numberNew 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 0:160d9ed96c23 24 ssh1106.drawBitmap(test);
Anaesthetix 0:160d9ed96c23 25 wait(1);
Anaesthetix 0:160d9ed96c23 26 ssh1106.drawBitmap(einstein);
Anaesthetix 0:160d9ed96c23 27 wait(1);
Anaesthetix 0:160d9ed96c23 28 ssh1106.drawBitmap(biohazard);
Anaesthetix 0:160d9ed96c23 29 wait(1);
Anaesthetix 0:160d9ed96c23 30 ssh1106.drawBitmap(highvoltage);
Anaesthetix 0:160d9ed96c23 31 wait(1);
Anaesthetix 0:160d9ed96c23 32 ssh1106.drawBitmap(copter);
Anaesthetix 0:160d9ed96c23 33 wait(1);
Anaesthetix 0:160d9ed96c23 34 ssh1106.clear();
Anaesthetix 0:160d9ed96c23 35 ssh1106.writeText(0,0, font_6x6, str, n);
Anaesthetix 0:160d9ed96c23 36 ssh1106.writeText(0,1, font_7x7, str, n);
Anaesthetix 0:160d9ed96c23 37 ssh1106.writeText(0,2, bold_font, str, n);
Anaesthetix 0:160d9ed96c23 38 ssh1106.writeText(0,3, font_5x8, str, n);
Anaesthetix 0:160d9ed96c23 39 ssh1106.writeText2d(0,4, font2d_hunter, str, n);
Anaesthetix 0:160d9ed96c23 40 ssh1106.writeText(0,5, font_8x8_1, str, n);
Anaesthetix 0:160d9ed96c23 41 ssh1106.writeText2d(0,6, font2d_formplex12, str, n);
Anaesthetix 0:160d9ed96c23 42 ssh1106.writeText(0,7, font_4x5, str, n);
Anaesthetix 0:160d9ed96c23 43 wait(5);
Anaesthetix 0:160d9ed96c23 44 }
Anaesthetix 0:160d9ed96c23 45 }