Skip to content

Commit c182b8e

Browse files
authored
Improve display speed for SH1106 with ESP32 (#382)
1 parent cdb3585 commit c182b8e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/SH1106Wire.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
#include "OLEDDisplay.h"
3535
#include <Wire.h>
3636

37+
#if defined(ARDUINO_ARCH_ESP32)
38+
#define I2C_OLED_TRANSFER_BYTE 64 /** ESP32 can Transfer Max 128 bytes */
39+
#else
40+
#define I2C_OLED_TRANSFER_BYTE 16
41+
#endif
42+
3743
#define SH1106_SET_PUMP_VOLTAGE 0X30
3844
#define SH1106_SET_PUMP_MODE 0XAD
3945
#define SH1106_PUMP_ON 0X8B
@@ -142,7 +148,7 @@ class SH1106Wire : public OLEDDisplay {
142148
}
143149
_wire->write(buffer[x + y * displayWidth]);
144150
k++;
145-
if (k == 16) {
151+
if (k == I2C_OLED_TRANSFER_BYTE) {
146152
_wire->endTransmission();
147153
k = 0;
148154
}
@@ -163,10 +169,10 @@ class SH1106Wire : public OLEDDisplay {
163169
sendCommand(0xB0+y);
164170
sendCommand(0x02);
165171
sendCommand(0x10);
166-
for( uint8_t x=0; x<8; x++) {
172+
for( uint8_t x=0; x<(128/I2C_OLED_TRANSFER_BYTE); x++) {
167173
_wire->beginTransmission(_address);
168174
_wire->write(0x40);
169-
for (uint8_t k = 0; k < 16; k++) {
175+
for (uint8_t k = 0; k < I2C_OLED_TRANSFER_BYTE; k++) {
170176
_wire->write(*p++);
171177
}
172178
_wire->endTransmission();

0 commit comments

Comments
 (0)