Skip to content

Commit

Permalink
Improve display speed for SSD1306 with ESP32 (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
FREEWING-JP authored Mar 12, 2023
1 parent e2e063a commit f96fd6a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/SSD1306Wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
#define _min min
#define _max max
#endif
#if defined(ARDUINO_ARCH_ESP32)
#define I2C_MAX_TRANSFER_BYTE 128 /** ESP32 can Transfer 128 bytes */
#else
#define I2C_MAX_TRANSFER_BYTE 17
#endif
//--------------------------------------

class SSD1306Wire : public OLEDDisplay {
Expand Down Expand Up @@ -147,7 +152,7 @@ class SSD1306Wire : public OLEDDisplay {

_wire->write(buffer[x + y * this->width()]);
k++;
if (k == 16) {
if (k == (I2C_MAX_TRANSFER_BYTE - 1)) {
_wire->endTransmission();
k = 0;
}
Expand All @@ -170,7 +175,7 @@ class SSD1306Wire : public OLEDDisplay {
for (uint16_t i=0; i < displayBufferSize; i++) {
_wire->beginTransmission(this->_address);
_wire->write(0x40);
for (uint8_t x = 0; x < 16; x++) {
for (uint8_t x = 0; x < (I2C_MAX_TRANSFER_BYTE - 1); x++) {
_wire->write(buffer[i]);
i++;
}
Expand Down

0 comments on commit f96fd6a

Please sign in to comment.