From 67350647c15494d5f9e3c33d2c71f235378b3ec6 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 6 Aug 2022 19:19:54 +0200 Subject: [PATCH] fix issue #882 --- include/display.h | 9 ++++++--- src/display.cpp | 11 ++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/display.h b/include/display.h index 2f753e5b..b30ec372 100644 --- a/include/display.h +++ b/include/display.h @@ -25,17 +25,20 @@ #define MY_DISPLAY_FIRSTLINE 30 +#ifndef MY_DISPLAY_RST +#define MY_DISPLAY_RST NOT_A_PIN +#endif + #ifdef MY_DISPLAY_ADDR #define OLED_ADDR MY_DISPLAY_ADDR #else #define OLED_ADDR -1 #endif -#ifndef USE_HW_I2C -#define USE_HW_I2C 1 -#endif + #ifndef OLED_FREQUENCY #define OLED_FREQUENCY 400000L #endif + #ifndef MY_DISPLAY_FGCOLOR #define MY_DISPLAY_FGCOLOR OLED_WHITE #endif diff --git a/src/display.cpp b/src/display.cpp index b7a284eb..6cb029f4 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -43,13 +43,13 @@ static const char TAG[] = __FILE__; static uint8_t plotbuf[PLOTBUFFERSIZE] = {0}; uint8_t DisplayIsOn = 0; hw_timer_t *displayIRQ = NULL; -QRCode qrcode; +static QRCode qrcode; #ifdef HAS_DISPLAY #if (HAS_DISPLAY) == 1 -ONE_BIT_DISPLAY oled; +static ONE_BIT_DISPLAY oled; #elif (HAS_DISPLAY) == 2 -TFT_eSPI tft = TFT_eSPI(MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT); +static TFT_eSPI tft = TFT_eSPI(MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT); #else #error Unknown display type specified in hal file #endif @@ -58,9 +58,10 @@ TFT_eSPI tft = TFT_eSPI(MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT); void dp_setup(int contrast) { #if (HAS_DISPLAY) == 1 // I2C OLED - + oled.setI2CPins(MY_DISPLAY_SDA, MY_DISPLAY_SCL, MY_DISPLAY_RST); + oled.setBitBang(false); oled.I2Cbegin(OLED_TYPE, OLED_ADDR, OLED_FREQUENCY); - assert(oled.allocBuffer()); // render all outputs to lib internal backbuffer + oled.allocBuffer(); // render all outputs to lib internal backbuffer oled.setTextWrap(false); oled.setRotation( MY_DISPLAY_FLIP ? 2 : 0); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 280°