From fcea41ead3fadd962342ffdf8241e48c1f84358e Mon Sep 17 00:00:00 2001 From: Kevin <68612569+diyelectromusic@users.noreply.github.com> Date: Sun, 22 Jan 2023 13:31:54 +0000 Subject: [PATCH] SSD1306 display rotation support and fix for #421 (#422) * Update Circle develop branch for SSD1306 display rotation support https://github.com/probonopd/MiniDexed/discussions/412 * 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> * circle-stdlib e318f89 Needed to support Circle develop * Fix for Issue 421 - circle sound drivers have moved to their own subdirectory and library. * Updated to keep in step with updates from the original in circle-stdlib. * git checkout circle-newlib 48bf91d Needed for circle ec09d7e Co-authored-by: probonopd --- .github/workflows/build.yml | 10 ++++++++-- src/Rules.mk | 1 + src/circle_stdlib_app.h | 6 ++++-- src/config.cpp | 12 ++++++++++++ src/config.h | 4 ++++ src/minidexed.cpp | 6 +++--- src/minidexed.h | 2 +- src/minidexed.ini | 2 ++ src/userinterface.cpp | 4 +++- 9 files changed, 38 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cbd4bdd..7ee4ebb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,11 +20,17 @@ jobs: run: | set -ex git submodule update --init --recursive - - name: Use Circle develop branch for WM8960 and i2c display support until it is merged upstream + - name: Use Circle develop branch for SSD1306 display rotation support until it is merged upstream run: | set -ex + cd circle-stdlib/ + git checkout e318f89 # Needed to support Circle develop? + cd - cd circle-stdlib/libs/circle - git checkout 646c362 # develop + git checkout ec09d7e # develop + cd - + cd circle-stdlib/libs/circle-newlib + git checkout 48bf91d # needed for circle ec09d7e cd - - name: Install toolchains run: | diff --git a/src/Rules.mk b/src/Rules.mk index 39b9f25..d466b74 100644 --- a/src/Rules.mk +++ b/src/Rules.mk @@ -23,6 +23,7 @@ LIBS += \ $(CIRCLEHOME)/addon/SDCard/libsdcard.a \ $(CIRCLEHOME)/lib/usb/libusb.a \ $(CIRCLEHOME)/lib/input/libinput.a \ + $(CIRCLEHOME)/lib/sound/libsound.a \ $(CIRCLEHOME)/addon/fatfs/libfatfs.a \ $(CIRCLEHOME)/lib/fs/libfs.a \ $(CIRCLEHOME)/lib/sched/libsched.a \ diff --git a/src/circle_stdlib_app.h b/src/circle_stdlib_app.h index 75cbde2..3c38f0d 100644 --- a/src/circle_stdlib_app.h +++ b/src/circle_stdlib_app.h @@ -214,8 +214,10 @@ public: return false; } - // Initialize newlib stdio with a reference to Circle's file system and console - CGlueStdioInit (mFileSystem, mConsole); + // Initialize newlib stdio with a reference to Circle's console + // (Remove mFileSystem as a parameter to mirror change in circle-stdlib's + // commit "Remove obsolete FATFS-related code", dated Dec 2022) + CGlueStdioInit (mConsole); mLogger.Write (GetKernelName (), LogNotice, "Compile time: " __DATE__ " " __TIME__); diff --git a/src/config.cpp b/src/config.cpp index 9ad98f0..b5279a8 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -85,6 +85,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); @@ -237,6 +239,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 2465507..8a34239 100644 --- a/src/config.h +++ b/src/config.h @@ -94,6 +94,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; @@ -169,6 +171,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.cpp b/src/minidexed.cpp index 8df8d6d..6a3897e 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -20,9 +20,9 @@ #include "minidexed.h" #include #include -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/minidexed.h b/src/minidexed.h index 3b7de4e..a74a04f 100644 --- a/src/minidexed.h +++ b/src/minidexed.h @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include "common.h" #include "effect_mixer.hpp" diff --git a/src/minidexed.ini b/src/minidexed.ini index f2bfbf6..bb3edd7 100644 --- a/src/minidexed.ini +++ b/src/minidexed.ini @@ -35,6 +35,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 ()) {