From 4b216fb564d6513ac60fdf630b43ac77effc1597 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Fri, 19 Aug 2022 16:35:02 +0200 Subject: [PATCH] simplify TFT display definition --- include/display.h | 7 ++----- include/globals.h | 3 +++ include/i2c.h | 1 + include/led.h | 4 ++++ src/display.cpp | 9 +++------ src/hal/m5core.h | 3 +-- src/hal/m5fire.h | 4 ++-- src/hal/ttgotdisplay.h | 11 +---------- src/hal/ttgotdisplays3.h | 27 +++++++++++++++++++++++++++ src/hal/ttgotwristband.h | 3 +-- 10 files changed, 45 insertions(+), 27 deletions(-) create mode 100644 src/hal/ttgotdisplays3.h diff --git a/include/display.h b/include/display.h index b4569481..4965f526 100644 --- a/include/display.h +++ b/include/display.h @@ -2,6 +2,7 @@ #define _DISPLAY_H #include +#include #include "cyclic.h" #include "qrcode.h" #include "power.h" @@ -48,7 +49,7 @@ extern BB_SPI_LCD *dp; #endif // settings for TFT display library -#elif (HAS_DISPLAY == 2) +#elif (HAS_DISPLAY) == 2 #define MY_FONT_SMALL 2 #define MY_FONT_NORMAL 2 @@ -74,10 +75,6 @@ extern BB_SPI_LCD *dp; #define OLED_TYPE OLED_128x64 #endif -#ifndef MY_DISPLAY_INVERT -#define MY_DISPLAY_INVERT 0 -#endif - #ifndef MY_DISPLAY_FLIP #define MY_DISPLAY_FLIP 0 #endif diff --git a/include/globals.h b/include/globals.h index 9150be80..8d57f1dd 100644 --- a/include/globals.h +++ b/include/globals.h @@ -12,7 +12,10 @@ #include #include #include + +#ifdef HAS_BME680 #include +#endif #define _bit(b) (1U << (b)) #define _bitl(b) (1UL << (b)) diff --git a/include/i2c.h b/include/i2c.h index ce64ff70..a8c7c8ea 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -2,6 +2,7 @@ #define _I2C_H #include +#include #include #define SSD1306_PRIMARY_ADDRESS (0x3D) diff --git a/include/led.h b/include/led.h index 6ee08289..6bbef12d 100644 --- a/include/led.h +++ b/include/led.h @@ -1,8 +1,12 @@ #ifndef _LED_H #define _LED_H +#ifdef RGB_LED_COUNT #include +#endif +#ifdef HAS_LORA #include "lorawan.h" +#endif #ifndef RGB_LED_COUNT #define RGB_LED_COUNT 1 diff --git a/src/display.cpp b/src/display.cpp index 56dc2ac5..c9aaad20 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -68,16 +68,13 @@ void dp_setup(int contrast) { dp->setRotation( MY_DISPLAY_FLIP ? 2 : 0); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 280° -#elif (HAS_DISPLAY) == 2 // SPI TFT +#elif (HAS_DISPLAY) == 2 // TFT LCD dp = new BB_SPI_LCD; - dp->begin(TFT_TYPE, FLAGS_NONE, TFT_FREQUENCY, TFT_CS, TFT_DC, TFT_RST, - TFT_BL, TFT_MISO, TFT_MOSI, TFT_SCLK); + dp->begin(TFT_TYPE); dp->allocBuffer(); // render all outputs to lib internal backbuffer dp->setRotation( MY_DISPLAY_FLIP ? 1 : 3); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 280° - // dp->invertDisplay(MY_DISPLAY_INVERT ? true : false); - // dp->setTextWrap(false); dp->setTextColor(MY_DISPLAY_FGCOLOR, MY_DISPLAY_BGCOLOR); #endif @@ -138,7 +135,7 @@ void dp_init(bool verbose) { #endif #endif // HAS_LORA - } // verbose + } // verbose dp_power(cfg.screenon); // set display off if disabled } // dp_init diff --git a/src/hal/m5core.h b/src/hal/m5core.h index 1f3cd537..d1bd87c6 100644 --- a/src/hal/m5core.h +++ b/src/hal/m5core.h @@ -48,8 +48,6 @@ //#define MY_DISPLAY_FLIP 1 // use if display is rotated #define MY_DISPLAY_WIDTH 320 #define MY_DISPLAY_HEIGHT 240 -#define MY_DISPLAY_INVERT 1 -#define TFT_TYPE LCD_ILI9341 #define TFT_MOSI MOSI // SPI #define TFT_MISO MISO // SPI #define TFT_SCLK SCK // SPI @@ -58,5 +56,6 @@ #define TFT_RST GPIO_NUM_33 // Reset #define TFT_BL GPIO_NUM_32 // LED back-light #define TFT_FREQUENCY 40000000 +#define TFT_TYPE LCD_ILI9341, FLAGS_NONE, TFT_FREQUENCY, TFT_CS, TFT_DC, TFT_RST, TFT_BL, TFT_MISO, TFT_MOSI, TFT_SCLK #endif diff --git a/src/hal/m5fire.h b/src/hal/m5fire.h index e93d0f5f..156cd494 100644 --- a/src/hal/m5fire.h +++ b/src/hal/m5fire.h @@ -53,8 +53,6 @@ //#define MY_DISPLAY_FLIP 1 // use if display is rotated #define MY_DISPLAY_WIDTH 320 #define MY_DISPLAY_HEIGHT 240 -#define MY_DISPLAY_INVERT 1 -#define TFT_TYPE LCD_ILI9341 #define TFT_MOSI MOSI // SPI #define TFT_MISO MISO // SPI #define TFT_SCLK SCK // SPI @@ -63,5 +61,7 @@ #define TFT_RST GPIO_NUM_33 // Reset #define TFT_BL GPIO_NUM_32 // LED back-light #define TFT_FREQUENCY 40000000 +#define TFT_TYPE LCD_ILI9341, FLAGS_NONE, TFT_FREQUENCY, TFT_CS, TFT_DC, TFT_RST, TFT_BL, TFT_MISO, TFT_MOSI, TFT_SCLK + #endif \ No newline at end of file diff --git a/src/hal/ttgotdisplay.h b/src/hal/ttgotdisplay.h index b1f625eb..4cabd198 100644 --- a/src/hal/ttgotdisplay.h +++ b/src/hal/ttgotdisplay.h @@ -18,18 +18,9 @@ // Display Settings #define HAS_DISPLAY 2 // TFT-LCD +#define TFT_TYPE DISPLAY_T_DISPLAY #define MY_DISPLAY_FLIP 1 // use if display is rotated #define MY_DISPLAY_WIDTH 135 #define MY_DISPLAY_HEIGHT 240 -#define MY_DISPLAY_INVERT 1 -#define TFT_TYPE LCD_ST7789_135 // size 135x240 px -#define TFT_MOSI GPIO_NUM_19 // SPI -#define TFT_MISO NOT_A_PIN // SPI -#define TFT_SCLK GPIO_NUM_18 // SPI -#define TFT_CS GPIO_NUM_5 // Chip select control -#define TFT_DC GPIO_NUM_16 // Data Command control -#define TFT_RST GPIO_NUM_23 // Reset -#define TFT_BL GPIO_NUM_4 // LED back-light -#define TFT_FREQUENCY 40000000 #endif diff --git a/src/hal/ttgotdisplays3.h b/src/hal/ttgotdisplays3.h new file mode 100644 index 00000000..fc0a60fd --- /dev/null +++ b/src/hal/ttgotdisplays3.h @@ -0,0 +1,27 @@ +// clang-format off +// upload_speed 1500000 +// board ESP32-S3-DevKitC-1 + +#ifndef _TTGOTDISPLAYS3_H +#define _TTGOTDISPLAYS3_H + +#include + +#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature + +#define HAS_LED LED_BUILTIN +#define HAS_BUTTON 14 // on board button (right side) + +// power management settings +//#define BAT_MEASURE_ADC ADC1_GPIO4_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_6 +//#define BAT_VOLTAGE_DIVIDER 2.605f // voltage divider + +// Display Settings +#define HAS_DISPLAY 2 // TFT-LCD parallel +#define TFT_TYPE DISPLAY_T_DISPLAY_S3 +#define MY_DISPLAY_FLIP 1 // use if display is rotated +#define MY_DISPLAY_WIDTH 172 +#define MY_DISPLAY_HEIGHT 320 + + +#endif \ No newline at end of file diff --git a/src/hal/ttgotwristband.h b/src/hal/ttgotwristband.h index 2439de6e..91c06633 100644 --- a/src/hal/ttgotwristband.h +++ b/src/hal/ttgotwristband.h @@ -21,8 +21,6 @@ #define MY_DISPLAY_FLIP 1 // use if display is rotated #define MY_DISPLAY_WIDTH 80 #define MY_DISPLAY_HEIGHT 160 -#define MY_DISPLAY_INVERT 1 -#define TFT_TYPE LCD_ST7735S #define TFT_MOSI GPIO_NUM_19 // SPI #define TFT_MISO NOT_A_PIN // SPI #define TFT_SCLK GPIO_NUM_18 // SPI @@ -31,6 +29,7 @@ #define TFT_RST GPIO_NUM_26 // Reset #define TFT_BL GPIO_NUM_27 // LED back-light #define TFT_FREQUENCY 27000000 +#define TFT_TYPE LCD_ST7735S, FLAGS_NONE, TFT_FREQUENCY, TFT_CS, TFT_DC, TFT_RST, TFT_BL, TFT_MISO, TFT_MOSI, TFT_SCLK #endif