Skip to content

Commit 3865bcd

Browse files
committed
fix 8-bit address for ESP32
1 parent a9405c6 commit 3865bcd

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/SSD1306I2C.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ class SSD1306I2C : public OLEDDisplay {
5555
public:
5656
#ifdef __MBED__
5757
SSD1306I2C(uint8_t address, PinName sda, PinName scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
58+
this->_address = address << 1; // convert from 7 to 8 bit for mbed.
5859
#elif ESP_PLATFORM
5960
SSD1306I2C(uint8_t address, gpio_num_t sda, gpio_num_t scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
61+
this->_address = address;
6062
#endif
6163
setGeometry(g);
6264

63-
this->_address = address << 1; // convert from 7 to 8 bit for mbed.
6465
this->_sda = sda;
6566
this->_scl = scl;
6667

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ void app_main()
1818
display.flipScreenVertically();
1919
display.setFont(ArialMT_Plain_10);
2020
display.setTextAlignment(TEXT_ALIGN_LEFT);
21-
char buffer[12];
22-
display.drawStringf(0, 24, buffer, "ESP-IDF %s", IDF_VER);
21+
char buffer[16];
22+
display.drawStringf(28, 24, buffer, "ESP-IDF %s", IDF_VER);
2323
display.display();
2424
}
2525

0 commit comments

Comments
 (0)