Seeed Studio's 0.96" OLED module

Dependencies:   Adafruit_GFX

Fork of SSD1308_128x64_I2C by Wim Huiskamp

Committer:
Nathan Yonkee
Date:
Thu Aug 03 06:26:07 2017 -0600
Revision:
14:e283a41c5fbc
Parent:
13:fe13e230c3f2
add Adafruit_GFX library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tulanthoar 7:dcff685d41a5 1 /* mbed Seeed 128x64 OLED Test
tulanthoar 7:dcff685d41a5 2 *
tulanthoar 7:dcff685d41a5 3 */
tulanthoar 7:dcff685d41a5 4 #include "mbed.h"
tulanthoar 10:74ef7544744e 5 #include "rtos.h"
tulanthoar 7:dcff685d41a5 6 /* #include "mbed_logo.h"
tulanthoar 7:dcff685d41a5 7 */
tulanthoar 7:dcff685d41a5 8 #include "SSD1308.h"
tulanthoar 7:dcff685d41a5 9
Nathan Yonkee 13:fe13e230c3f2 10 DigitalOut led(PA_8);
tulanthoar 7:dcff685d41a5 11 //Pin Defines for I2C Bus
tulanthoar 10:74ef7544744e 12 #define OLED_D_SDA PA_10
tulanthoar 10:74ef7544744e 13 #define OLED_D_SCL PA_9
tulanthoar 10:74ef7544744e 14 I2C i2c(OLED_D_SDA, OLED_D_SCL);
tulanthoar 7:dcff685d41a5 15
tulanthoar 7:dcff685d41a5 16 // Host PC Communication channels
tulanthoar 7:dcff685d41a5 17 Serial pc(USBTX, USBRX); // tx, rx
tulanthoar 7:dcff685d41a5 18
tulanthoar 7:dcff685d41a5 19 // Instantiate OLED
tulanthoar 10:74ef7544744e 20 SSD1308 oled(&i2c, 0x78);
tulanthoar 7:dcff685d41a5 21
Nathan Yonkee 13:fe13e230c3f2 22 Thread heartbeat;
Nathan Yonkee 13:fe13e230c3f2 23 void blink() {
Nathan Yonkee 13:fe13e230c3f2 24 for(DigitalOut led(LED2);; Thread::wait(500) ) {
Nathan Yonkee 13:fe13e230c3f2 25 led = !led;
Nathan Yonkee 13:fe13e230c3f2 26 }
Nathan Yonkee 13:fe13e230c3f2 27 }
Nathan Yonkee 13:fe13e230c3f2 28
tulanthoar 7:dcff685d41a5 29 int main() {
Nathan Yonkee 13:fe13e230c3f2 30 led = 1;
Nathan Yonkee 13:fe13e230c3f2 31 const int waitTime = 1000;
Nathan Yonkee 13:fe13e230c3f2 32 for (heartbeat.start(callback(blink));; Thread::wait(waitTime)) {
Nathan Yonkee 13:fe13e230c3f2 33 led = !led;
tulanthoar 7:dcff685d41a5 34 pc.printf("OLED test start\r");
tulanthoar 7:dcff685d41a5 35
tulanthoar 7:dcff685d41a5 36 oled.writeString(0, 0, "Hello World! a b");
tulanthoar 7:dcff685d41a5 37 oled.writeString(10, 0, "abcdefghij");
tulanthoar 7:dcff685d41a5 38 // oled.printf("Hello World !");
Nathan Yonkee 13:fe13e230c3f2 39 Thread::wait(3000);
Nathan Yonkee 13:fe13e230c3f2 40 led = !led;
tulanthoar 7:dcff685d41a5 41
tulanthoar 7:dcff685d41a5 42 oled.fillDisplay(0xAA);
Nathan Yonkee 13:fe13e230c3f2 43 Thread::wait(3000);
Nathan Yonkee 13:fe13e230c3f2 44 led = !led;
tulanthoar 7:dcff685d41a5 45
tulanthoar 7:dcff685d41a5 46 oled.setDisplayOff();
Nathan Yonkee 13:fe13e230c3f2 47 Thread::wait(500);
Nathan Yonkee 13:fe13e230c3f2 48 led = !led;
tulanthoar 7:dcff685d41a5 49
tulanthoar 7:dcff685d41a5 50 oled.setDisplayOn();
Nathan Yonkee 13:fe13e230c3f2 51 Thread::wait(500);
Nathan Yonkee 13:fe13e230c3f2 52 led = !led;
tulanthoar 7:dcff685d41a5 53
tulanthoar 7:dcff685d41a5 54 oled.clearDisplay();
Nathan Yonkee 13:fe13e230c3f2 55 Thread::wait(500);
Nathan Yonkee 13:fe13e230c3f2 56 led = !led;
tulanthoar 7:dcff685d41a5 57
tulanthoar 7:dcff685d41a5 58 oled.writeBigChar(0,0,'9');
tulanthoar 7:dcff685d41a5 59 oled.writeBigChar(12,0,'8');
tulanthoar 7:dcff685d41a5 60 oled.writeBigChar(12,18,'7');
Nathan Yonkee 13:fe13e230c3f2 61 Thread::wait(3000);
Nathan Yonkee 13:fe13e230c3f2 62 led = !led;
tulanthoar 7:dcff685d41a5 63 oled.setDisplayInverse();
Nathan Yonkee 13:fe13e230c3f2 64 Thread::wait(500);
Nathan Yonkee 13:fe13e230c3f2 65 led = !led;
tulanthoar 7:dcff685d41a5 66
tulanthoar 7:dcff685d41a5 67 oled.setDisplayNormal();
Nathan Yonkee 13:fe13e230c3f2 68 Thread::wait(500);
Nathan Yonkee 13:fe13e230c3f2 69 led = !led;
tulanthoar 7:dcff685d41a5 70 oled.clearDisplay();
tulanthoar 7:dcff685d41a5 71
tulanthoar 7:dcff685d41a5 72 /* oled.writeBitmap((uint8_t*) mbed_logo); */
tulanthoar 7:dcff685d41a5 73
tulanthoar 7:dcff685d41a5 74 pc.printf("OLED test done\r\n");
tulanthoar 7:dcff685d41a5 75 }
tulanthoar 7:dcff685d41a5 76 }