From 29193db631650e9af053bcc1918cc877b1233723 Mon Sep 17 00:00:00 2001 From: probonopd Date: Wed, 18 Jan 2023 19:42:01 +0000 Subject: [PATCH] Implements rotation and mirroring options for SSD1306 displays (only). (#420) Requires an update to circle (PR submitted to develop branch) Co-authored-by: diyelectromusic <68612569+diyelectromusic@users.noreply.github.com> --- src/config.cpp | 12 ++++++++++++ src/config.h | 4 ++++ src/minidexed.ini | 2 ++ src/userinterface.cpp | 4 +++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/config.cpp b/src/config.cpp index 1143476..5c52852 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -84,6 +84,8 @@ void CConfig::Load (void) m_nSSD1306LCDI2CAddress = m_Properties.GetNumber ("SSD1306LCDI2CAddress", 0); m_nSSD1306LCDWidth = m_Properties.GetNumber ("SSD1306LCDWidth", 128); m_nSSD1306LCDHeight = m_Properties.GetNumber ("SSD1306LCDHeight", 32); + m_bSSD1306LCDRotate = m_Properties.GetNumber ("SSD1306LCDRotate", 0) != 0; + m_bSSD1306LCDMirror = m_Properties.GetNumber ("SSD1306LCDMirror", 0) != 0; m_nLCDColumns = m_Properties.GetNumber ("LCDColumns", 16); m_nLCDRows = m_Properties.GetNumber ("LCDRows", 2); @@ -231,6 +233,16 @@ unsigned CConfig::GetSSD1306LCDHeight (void) const return m_nSSD1306LCDHeight; } +bool CConfig::GetSSD1306LCDRotate (void) const +{ + return m_bSSD1306LCDRotate; +} + +bool CConfig::GetSSD1306LCDMirror (void) const +{ + return m_bSSD1306LCDMirror; +} + unsigned CConfig::GetLCDColumns (void) const { return m_nLCDColumns; diff --git a/src/config.h b/src/config.h index be75100..eb14918 100644 --- a/src/config.h +++ b/src/config.h @@ -93,6 +93,8 @@ public: unsigned GetSSD1306LCDI2CAddress (void) const; unsigned GetSSD1306LCDWidth (void) const; unsigned GetSSD1306LCDHeight (void) const; + bool GetSSD1306LCDRotate (void) const; + bool GetSSD1306LCDMirror (void) const; unsigned GetLCDColumns (void) const; unsigned GetLCDRows (void) const; @@ -167,6 +169,8 @@ private: unsigned m_nSSD1306LCDI2CAddress; unsigned m_nSSD1306LCDWidth; unsigned m_nSSD1306LCDHeight; + bool m_bSSD1306LCDRotate; + bool m_bSSD1306LCDMirror; unsigned m_nLCDColumns; unsigned m_nLCDRows; diff --git a/src/minidexed.ini b/src/minidexed.ini index 7d73416..8083e19 100644 --- a/src/minidexed.ini +++ b/src/minidexed.ini @@ -34,6 +34,8 @@ LCDI2CAddress=0x00 SSD1306LCDI2CAddress=0x0 SSD1306LCDWidth=128 SSD1306LCDHeight=32 +SSD1306LCDRotate=0 +SSD1306LCDMirror=0 # Default is 16x2 display (e.g. HD44780) LCDColumns=16 diff --git a/src/userinterface.cpp b/src/userinterface.cpp index f34e561..0bcd931 100644 --- a/src/userinterface.cpp +++ b/src/userinterface.cpp @@ -58,7 +58,9 @@ bool CUserInterface::Initialize (void) unsigned i2caddr = m_pConfig->GetLCDI2CAddress (); unsigned ssd1306addr = m_pConfig->GetSSD1306LCDI2CAddress (); if (ssd1306addr != 0) { - m_pSSD1306 = new CSSD1306Device (m_pConfig->GetSSD1306LCDWidth (), m_pConfig->GetSSD1306LCDHeight (), m_pI2CMaster, ssd1306addr); + m_pSSD1306 = new CSSD1306Device (m_pConfig->GetSSD1306LCDWidth (), m_pConfig->GetSSD1306LCDHeight (), + m_pI2CMaster, ssd1306addr, + m_pConfig->GetSSD1306LCDRotate (), m_pConfig->GetSSD1306LCDMirror ()); LOGDBG ("LCD: SSD1306"); if (!m_pSSD1306->Initialize ()) {