display defines restructured for t_dongle_display

This commit is contained in:
cyberman54 2022-11-12 19:34:18 +01:00
parent ba8eb8130d
commit 09f9581e76
3 changed files with 45 additions and 46 deletions

View File

@ -8,19 +8,30 @@
#include "power.h" #include "power.h"
#include "timekeeper.h" #include "timekeeper.h"
#if (HAS_DISPLAY) == 1 // Settings for all display types
#include <OneBitDisplay.h> #ifndef MY_DISPLAY_FLIP
extern ONE_BIT_DISPLAY *dp; #define MY_DISPLAY_FLIP 0
#elif (HAS_DISPLAY) == 2 #endif
#include <bb_spi_lcd.h> #ifndef MY_DISPLAY_WIDTH
extern BB_SPI_LCD *dp; #define MY_DISPLAY_WIDTH 128
#endif
#ifndef MY_DISPLAY_HEIGHT
#define MY_DISPLAY_HEIGHT 64
#endif
#ifndef MY_DISPLAY_FIRSTLINE
#define MY_DISPLAY_FIRSTLINE 0
#endif #endif
#define DISPLAY_PAGES (7) // number of paxcounter display pages #define DISPLAY_PAGES (7) // number of paxcounter display pages
#define PLOTBUFFERSIZE (MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8) #define PLOTBUFFERSIZE (MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8)
#define QR_VERSION 3 // 29 x 29px
// settings for OLED display library // Settings for OLED display library
#if (HAS_DISPLAY) == 1 #if (HAS_DISPLAY) == 1
#include <OneBitDisplay.h>
extern ONE_BIT_DISPLAY *dp;
#define MY_FONT_SMALL FONT_6x8 #define MY_FONT_SMALL FONT_6x8
#define MY_FONT_NORMAL FONT_8x8 #define MY_FONT_NORMAL FONT_8x8
#define MY_FONT_LARGE FONT_16x32 #define MY_FONT_LARGE FONT_16x32
@ -30,17 +41,17 @@ extern BB_SPI_LCD *dp;
#ifndef MY_DISPLAY_RST #ifndef MY_DISPLAY_RST
#define MY_DISPLAY_RST NOT_A_PIN #define MY_DISPLAY_RST NOT_A_PIN
#endif #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 OLED_FREQUENCY #ifndef OLED_FREQUENCY
#define OLED_FREQUENCY 400000L #define OLED_FREQUENCY 400000L
#endif #endif
#ifndef OLED_TYPE
#define OLED_TYPE OLED_128x64
#endif
#ifndef MY_DISPLAY_FGCOLOR #ifndef MY_DISPLAY_FGCOLOR
#define MY_DISPLAY_FGCOLOR 1 // OLED_WHITE #define MY_DISPLAY_FGCOLOR 1 // OLED_WHITE
#endif #endif
@ -48,19 +59,15 @@ extern BB_SPI_LCD *dp;
#define MY_DISPLAY_BGCOLOR 0 // OLED_BLACK #define MY_DISPLAY_BGCOLOR 0 // OLED_BLACK
#endif #endif
// settings for TFT display library // Settings for TFT display library
#elif (HAS_DISPLAY) == 2 #elif (HAS_DISPLAY) > 1
#define MY_FONT_SMALL 2 #include <bb_spi_lcd.h>
#define MY_FONT_NORMAL 2 extern BB_SPI_LCD *dp;
#define MY_FONT_LARGE 2
#define MY_FONT_STRETCHED 2
#define MY_DISPLAY_FIRSTLINE 30
#ifndef TFT_FREQUENCY #ifndef TFT_FREQUENCY
#define TFT_FREQUENCY 400000L #define TFT_FREQUENCY 400000L
#endif #endif
#ifndef MY_DISPLAY_FGCOLOR #ifndef MY_DISPLAY_FGCOLOR
#define MY_DISPLAY_FGCOLOR TFT_YELLOW #define MY_DISPLAY_FGCOLOR TFT_YELLOW
#endif #endif
@ -70,31 +77,25 @@ extern BB_SPI_LCD *dp;
#endif #endif
// setup display hardware type, default is OLED 128x64 // Fonts for large TFT display library
#ifndef OLED_TYPE #if (HAS_DISPLAY) == 2
#define OLED_TYPE OLED_128x64 #define MY_FONT_SMALL FONT_12x16
#define MY_FONT_NORMAL FONT_12x16
#define MY_FONT_LARGE FONT_12x16
#define MY_FONT_STRETCHED FONT_12x16
#define MY_DISPLAY_FIRSTLINE 30
#endif #endif
#ifndef MY_DISPLAY_FLIP // Settings for small TFT display library
#define MY_DISPLAY_FLIP 0 #if (HAS_DISPLAY) == 3
#define MY_FONT_SMALL FONT_6x8
#define MY_FONT_NORMAL FONT_8x8
#define MY_FONT_LARGE FONT_16x16
#define MY_FONT_STRETCHED FONT_12x16
#define MY_DISPLAY_FIRSTLINE 30
#endif #endif
#ifndef MY_DISPLAY_WIDTH
#define MY_DISPLAY_WIDTH 128 // Width in pixels of OLED-display, must be 32X
#endif
#ifndef MY_DISPLAY_HEIGHT
#define MY_DISPLAY_HEIGHT 64 // Height in pixels of OLED-display, must be 64X
#endif
#ifndef MY_DISPLAY_FIRSTLINE
#define MY_DISPLAY_FIRSTLINE 0
#endif
// settings for qr code generator
#define QR_VERSION 3 // 29 x 29px
const uint8_t QR_SCALEFACTOR = (MY_DISPLAY_HEIGHT - 4) / 29; // 4px borderlines const uint8_t QR_SCALEFACTOR = (MY_DISPLAY_HEIGHT - 4) / 29; // 4px borderlines
extern uint8_t DisplayIsOn; extern uint8_t DisplayIsOn;
extern hw_timer_t *displayIRQ; extern hw_timer_t *displayIRQ;
extern uint8_t volatile channel; // wifi channel rotation counter extern uint8_t volatile channel; // wifi channel rotation counter

View File

@ -49,7 +49,7 @@ static QRCode qrcode;
#ifdef HAS_DISPLAY #ifdef HAS_DISPLAY
#if (HAS_DISPLAY) == 1 #if (HAS_DISPLAY) == 1
ONE_BIT_DISPLAY *dp = NULL; ONE_BIT_DISPLAY *dp = NULL;
#elif (HAS_DISPLAY) == 2 #elif (HAS_DISPLAY) > 1
BB_SPI_LCD *dp = NULL; BB_SPI_LCD *dp = NULL;
#else #else
#error Unknown display type specified in hal file #error Unknown display type specified in hal file
@ -68,7 +68,7 @@ void dp_setup(int contrast) {
dp->setRotation( dp->setRotation(
MY_DISPLAY_FLIP ? 2 : 0); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 270° MY_DISPLAY_FLIP ? 2 : 0); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 270°
#elif (HAS_DISPLAY) == 2 // TFT LCD #elif (HAS_DISPLAY) > 1 // TFT LCD
dp = new BB_SPI_LCD; dp = new BB_SPI_LCD;
dp->begin(TFT_TYPE); dp->begin(TFT_TYPE);
@ -421,7 +421,7 @@ void dp_clear(void) {
void dp_contrast(uint8_t contrast) { void dp_contrast(uint8_t contrast) {
#if (HAS_DISPLAY) == 1 #if (HAS_DISPLAY) == 1
dp->setContrast(contrast); dp->setContrast(contrast);
#elif (HAS_DISPLAY) == 2 #elif (HAS_DISPLAY) > 1
// to do: gamma correction for TFT // to do: gamma correction for TFT
#endif #endif
} }
@ -429,7 +429,7 @@ void dp_contrast(uint8_t contrast) {
void dp_power(uint8_t screenon) { void dp_power(uint8_t screenon) {
#if (HAS_DISPLAY) == 1 #if (HAS_DISPLAY) == 1
dp->setPower(screenon); dp->setPower(screenon);
#elif (HAS_DISPLAY) == 2 #elif (HAS_DISPLAY) > 1
// to come // to come
#endif #endif
} }
@ -438,7 +438,7 @@ void dp_shutdown(void) {
#if (HAS_DISPLAY) == 1 #if (HAS_DISPLAY) == 1
dp->setPower(false); dp->setPower(false);
delay(DISPLAYREFRESH_MS / 1000 * 1.1); delay(DISPLAYREFRESH_MS / 1000 * 1.1);
#elif (HAS_DISPLAY) == 2 #elif (HAS_DISPLAY) > 1
// to come // to come
#endif #endif
} }

View File

@ -18,12 +18,10 @@
#define SDCARD_SLOTWIDTH 4 // dongle has 4 line interface #define SDCARD_SLOTWIDTH 4 // dongle has 4 line interface
#define SDCARD_SLOTCONFIG { .clk = GPIO_NUM_12, .cmd = GPIO_NUM_16, .d0 = GPIO_NUM_14, .d1 = GPIO_NUM_17, .d2 = GPIO_NUM_21, .d3 = GPIO_NUM_18, .cd = SDMMC_SLOT_NO_CD, .wp = SDMMC_SLOT_NO_WP, .width = 4, .flags = 0, } #define SDCARD_SLOTCONFIG { .clk = GPIO_NUM_12, .cmd = GPIO_NUM_16, .d0 = GPIO_NUM_14, .d1 = GPIO_NUM_17, .d2 = GPIO_NUM_21, .d3 = GPIO_NUM_18, .cd = SDMMC_SLOT_NO_CD, .wp = SDMMC_SLOT_NO_WP, .width = 4, .flags = 0, }
#define HAS_DISPLAY 2 // TFT-LCD #define HAS_DISPLAY 3 // TFT-LCD
#define TFT_TYPE DISPLAY_T_DONGLE_S3 #define TFT_TYPE DISPLAY_T_DONGLE_S3
#define MY_DISPLAY_FLIP 1 // use if display is rotated #define MY_DISPLAY_FLIP 1 // use if display is rotated
#define MY_DISPLAY_WIDTH 80 #define MY_DISPLAY_WIDTH 80
#define MY_DISPLAY_HEIGHT 160 #define MY_DISPLAY_HEIGHT 160
#endif #endif