This commit is contained in:
cyberman54 2022-08-06 19:19:54 +02:00
parent e477118696
commit 67350647c1
2 changed files with 12 additions and 8 deletions

View File

@ -25,17 +25,20 @@
#define MY_DISPLAY_FIRSTLINE 30 #define MY_DISPLAY_FIRSTLINE 30
#ifndef MY_DISPLAY_RST
#define MY_DISPLAY_RST NOT_A_PIN
#endif
#ifdef MY_DISPLAY_ADDR #ifdef MY_DISPLAY_ADDR
#define OLED_ADDR MY_DISPLAY_ADDR #define OLED_ADDR MY_DISPLAY_ADDR
#else #else
#define OLED_ADDR -1 #define OLED_ADDR -1
#endif #endif
#ifndef USE_HW_I2C
#define USE_HW_I2C 1
#endif
#ifndef OLED_FREQUENCY #ifndef OLED_FREQUENCY
#define OLED_FREQUENCY 400000L #define OLED_FREQUENCY 400000L
#endif #endif
#ifndef MY_DISPLAY_FGCOLOR #ifndef MY_DISPLAY_FGCOLOR
#define MY_DISPLAY_FGCOLOR OLED_WHITE #define MY_DISPLAY_FGCOLOR OLED_WHITE
#endif #endif

View File

@ -43,13 +43,13 @@ static const char TAG[] = __FILE__;
static uint8_t plotbuf[PLOTBUFFERSIZE] = {0}; static uint8_t plotbuf[PLOTBUFFERSIZE] = {0};
uint8_t DisplayIsOn = 0; uint8_t DisplayIsOn = 0;
hw_timer_t *displayIRQ = NULL; hw_timer_t *displayIRQ = NULL;
QRCode qrcode; static QRCode qrcode;
#ifdef HAS_DISPLAY #ifdef HAS_DISPLAY
#if (HAS_DISPLAY) == 1 #if (HAS_DISPLAY) == 1
ONE_BIT_DISPLAY oled; static ONE_BIT_DISPLAY oled;
#elif (HAS_DISPLAY) == 2 #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 #else
#error Unknown display type specified in hal file #error Unknown display type specified in hal file
#endif #endif
@ -58,9 +58,10 @@ TFT_eSPI tft = TFT_eSPI(MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT);
void dp_setup(int contrast) { void dp_setup(int contrast) {
#if (HAS_DISPLAY) == 1 // I2C OLED #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); 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.setTextWrap(false);
oled.setRotation( oled.setRotation(
MY_DISPLAY_FLIP ? 2 : 0); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 280° MY_DISPLAY_FLIP ? 2 : 0); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 280°