OLED I2C demo for the SSD1306 and SH1106 displays
Dependencies: mbed OLED_SSD1306_SH1106
main.cpp
- Committer:
- cspista
- Date:
- 2022-02-02
- Revision:
- 2:330a46b0b876
- Parent:
- 1:ec7f794146bb
File content as of revision 2:330a46b0b876:
/* * OLED I2C display demo based on the Adafruit_GFX * library forked from Neal Horman * Link: https://os.mbed.com/users/nkhorman/code/Adafruit_GFX/ * The library was modified and extended so that it could be used * also for 128x64 I2C OLED displays driven by SH1106 controller. * See the documentation page for Adafruit_SH1106_I2c */ #include "mbed.h" #include "Adafruit_SSD1306.h" I2C i2c(D14,D15); Adafruit_SH1106_I2c oled(i2c, NC, 0x78, 64, 128); // SH1106 I2C 128x64, with no reset pin // Adafruit_SSD1306_I2c oled(i2c, NC, 0x78, 64, 128); // SSD1306 I2C 128x64, with no reset pin // Adafruit_SSD1306_I2c oled(i2c, NC, 0x78, 32, 128); // SSD1306 I2C 128x32, with no reset pin int main() { uint16_t x=0; i2c.frequency(400000); oled.setRotation(0); oled.clearDisplay(); oled.drawRect(0,0,oled.width(),oled.height(),1); oled.display(); oled.setTextColor(WHITE); oled.setTextSize(1); oled.setTextCursor(10,8); oled.printf("SH1106 %ux%u",oled.width(),oled.height()); oled.display(); wait(2.0); oled.setTextSize(2); while(1) { oled.clearDisplay(); oled.drawRect(0,0,oled.width(),oled.height(),1); oled.setTextCursor(10,8); oled.printf("x = %u",x++); oled.display(); wait(1.0); } }