From 0c88c74706db84fe90d5934125a5ea0959d6ad08 Mon Sep 17 00:00:00 2001 From: Neil McKechnie Date: Tue, 7 Feb 2023 17:01:45 +0000 Subject: [PATCH] Revert "Refactor SSD1306 initialisation to support different initialisation sequences." This reverts commit 278a9c52a64d979ec99adc0535378d492f7b338e. --- SSD1306Ascii.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/SSD1306Ascii.cpp b/SSD1306Ascii.cpp index f57252f..7373a74 100644 --- a/SSD1306Ascii.cpp +++ b/SSD1306Ascii.cpp @@ -144,10 +144,7 @@ const uint8_t FLASH SSD1306AsciiWire::SH1106_132x64init[] = { //------------------------------------------------------------------------------ // Constructor -SSD1306AsciiWire::SSD1306AsciiWire() { - I2CManager.begin(); - I2CManager.setClock(400000L); // Set max supported I2C speed -} +SSD1306AsciiWire::SSD1306AsciiWire() {} // CS auto-detect and configure constructor SSD1306AsciiWire::SSD1306AsciiWire(int width, int height) { @@ -196,7 +193,7 @@ bool SSD1306AsciiWire::begin(I2CAddress address, int width, int height) { return false; } // Device found - DIAG(F("%dx%d OLED display configured on I2C:x%x"), m_displayWidth, m_displayHeight, (int)m_i2cAddr); + DIAG(F("%dx%d OLED display configured on I2C:x%x"), m_displayWidth, m_displayHeight, (uint8_t)m_i2cAddr); clear(); return true; } @@ -206,9 +203,8 @@ void SSD1306AsciiWire::clearNative() { const int maxBytes = sizeof(blankPixels); // max number of bytes sendable over Wire for (uint8_t r = 0; r <= m_displayHeight/8 - 1; r++) { setRowNative(r); // Position at start of row to be erased - for (uint8_t c = 0; c <= m_displayWidth - 1; c += maxBytes) { - uint8_t len = m_displayWidth-c; - if (len > maxBytes) len = maxBytes; + for (uint8_t c = 0; c <= m_displayWidth - 1; c += maxBytes-1) { + uint8_t len = min(m_displayWidth-c, maxBytes-1) + 1; I2CManager.write_P(m_i2cAddr, blankPixels, len); // Write a number of blank columns } }