From 79763a3bb891b3c0b0066932aced8eebe5a362aa Mon Sep 17 00:00:00 2001 From: Neil McKechnie <75813993+Neil-McK@users.noreply.github.com> Date: Thu, 10 Jun 2021 16:24:44 +0100 Subject: [PATCH] SH1106 OLED Display Offset Fix (#169) Correct display offset for SH1106. The SH1106 supports 132 columns but most displays use 128 column OLED, connected to the middle columns 2-129. --- SSD1306Ascii.cpp | 4 ++-- SSD1306init.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/SSD1306Ascii.cpp b/SSD1306Ascii.cpp index c99383a..6ddc8f4 100644 --- a/SSD1306Ascii.cpp +++ b/SSD1306Ascii.cpp @@ -74,8 +74,8 @@ void SSD1306AsciiWire::setCursor(uint8_t col, uint8_t row) { m_col = col + m_colOffset; I2CManager.write(m_i2cAddr, 4, 0x00, // Set to command mode - SSD1306_SETLOWCOLUMN | (col & 0XF), - SSD1306_SETHIGHCOLUMN | (col >> 4), + SSD1306_SETLOWCOLUMN | (m_col & 0XF), + SSD1306_SETHIGHCOLUMN | (m_col >> 4), SSD1306_SETSTARTPAGE | m_row); } } diff --git a/SSD1306init.h b/SSD1306init.h index b861b81..4acb2ce 100644 --- a/SSD1306init.h +++ b/SSD1306init.h @@ -182,6 +182,7 @@ static const uint8_t MEM_TYPE SH1106_128x64init[] = { 0x00, // Set to command mode SSD1306_DISPLAYOFF, SSD1306_SETSTARTPAGE | 0X0, // set page address + SSD1306_SETSTARTLINE | 0x0, // set start line SSD1306_SETCONTRAST, 0x80, // 128 SSD1306_SEGREMAP | 0X1, // set segment remap SSD1306_NORMALDISPLAY, // normal / reverse