Skip to content

ESP32 improve display speed for SH1106 #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/SH1106Wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
#include "OLEDDisplay.h"
#include <Wire.h>

#if defined(ARDUINO_ARCH_ESP32)
#define I2C_OLED_TRANSFER_BYTE 64 /** ESP32 can Transfer Max 128 bytes */
#else
#define I2C_OLED_TRANSFER_BYTE 16
#endif

#define SH1106_SET_PUMP_VOLTAGE 0X30
#define SH1106_SET_PUMP_MODE 0XAD
#define SH1106_PUMP_ON 0X8B
Expand Down Expand Up @@ -142,7 +148,7 @@ class SH1106Wire : public OLEDDisplay {
}
_wire->write(buffer[x + y * displayWidth]);
k++;
if (k == 16) {
if (k == I2C_OLED_TRANSFER_BYTE) {
_wire->endTransmission();
k = 0;
}
Expand All @@ -163,10 +169,10 @@ class SH1106Wire : public OLEDDisplay {
sendCommand(0xB0+y);
sendCommand(0x02);
sendCommand(0x10);
for( uint8_t x=0; x<8; x++) {
for( uint8_t x=0; x<(128/I2C_OLED_TRANSFER_BYTE); x++) {
_wire->beginTransmission(_address);
_wire->write(0x40);
for (uint8_t k = 0; k < 16; k++) {
for (uint8_t k = 0; k < I2C_OLED_TRANSFER_BYTE; k++) {
_wire->write(*p++);
}
_wire->endTransmission();
Expand Down