Skip to content

Commit f96fd6a

Browse files
authored
Improve display speed for SSD1306 with ESP32 (#380)
1 parent e2e063a commit f96fd6a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/SSD1306Wire.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
#define _min min
4040
#define _max max
4141
#endif
42+
#if defined(ARDUINO_ARCH_ESP32)
43+
#define I2C_MAX_TRANSFER_BYTE 128 /** ESP32 can Transfer 128 bytes */
44+
#else
45+
#define I2C_MAX_TRANSFER_BYTE 17
46+
#endif
4247
//--------------------------------------
4348

4449
class SSD1306Wire : public OLEDDisplay {
@@ -147,7 +152,7 @@ class SSD1306Wire : public OLEDDisplay {
147152

148153
_wire->write(buffer[x + y * this->width()]);
149154
k++;
150-
if (k == 16) {
155+
if (k == (I2C_MAX_TRANSFER_BYTE - 1)) {
151156
_wire->endTransmission();
152157
k = 0;
153158
}
@@ -170,7 +175,7 @@ class SSD1306Wire : public OLEDDisplay {
170175
for (uint16_t i=0; i < displayBufferSize; i++) {
171176
_wire->beginTransmission(this->_address);
172177
_wire->write(0x40);
173-
for (uint8_t x = 0; x < 16; x++) {
178+
for (uint8_t x = 0; x < (I2C_MAX_TRANSFER_BYTE - 1); x++) {
174179
_wire->write(buffer[i]);
175180
i++;
176181
}

0 commit comments

Comments
 (0)