From 37c598833c49f00a518e5362fa32ab4bde952e73 Mon Sep 17 00:00:00 2001 From: Marcel van der Boom Date: Sun, 14 Jun 2020 10:28:23 +0200 Subject: [PATCH] Add support for SH1106 controller The SH1106 is almost indistinguisable from a SSD1306. - the nr of columns in the sh1106 is 132 vs 128 - use the proper includes/library functions when in use --- src/configuration.h | 4 ++++ src/screen.cpp | 4 ++++ src/screen.h | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/src/configuration.h b/src/configuration.h index 4759dfc7..3a6626cf 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -104,6 +104,10 @@ along with this program. If not, see . #define SSD1306_ADDRESS 0x3C +// The SH1106 controller is almost, but not quite, the same as SSD1306 +// Define this if you know you have that controller or your "SSD1306" misbehaves. +//#define USE_SH1106 + // Flip the screen upside down by default as it makes more sense on T-BEAM // devices. Comment this out to not rotate screen 180 degrees. #define FLIP_SCREEN_VERTICALLY diff --git a/src/screen.cpp b/src/screen.cpp index 47f4f1c5..9198bc20 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -34,7 +34,11 @@ along with this program. If not, see . #define FONT_HEIGHT 14 // actually 13 for "ariel 10" but want a little extra space #define FONT_HEIGHT_16 (ArialMT_Plain_16[1] + 1) +#ifdef USE_SH1106 +#define SCREEN_WIDTH 132 +#else #define SCREEN_WIDTH 128 +#endif #define SCREEN_HEIGHT 64 #define TRANSITION_FRAMERATE 30 // fps #define IDLE_FRAMERATE 10 // in fps diff --git a/src/screen.h b/src/screen.h index be5444c1..302c8e33 100644 --- a/src/screen.h +++ b/src/screen.h @@ -3,7 +3,12 @@ #include #include + +#ifdef USE_SH1106 +#include +#else #include +#endif #include "PeriodicTask.h" #include "TypedQueue.h" @@ -211,7 +216,11 @@ class Screen : public PeriodicTask /// Holds state for debug information DebugInfo debugInfo; /// Display device +#ifdef USE_SH1106 + SH1106Wire dispdev; +#else SSD1306Wire dispdev; +#endif /// UI helper for rendering to frames and switching between them OLEDDisplayUi ui; };