From fcef6fbb14e92ed8a636932919305d2518d6ec46 Mon Sep 17 00:00:00 2001 From: mverch67 Date: Wed, 26 Mar 2025 16:40:24 +0100 Subject: [PATCH] fix touch screen --- src/graphics/TFTDisplay.cpp | 150 ++++++++++++++++++------------------ 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index 94974d3b0..14787baff 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -120,11 +120,11 @@ static void rak14014_tpIntHandle(void) _rak14014_touch_int = true; } -#elif defined (ST72xx_DE) +#elif defined(ST72xx_DE) #include +#include #include #include -#include TCA9534 ioex; class LGFX : public lgfx::LGFX_Device @@ -133,11 +133,11 @@ class LGFX : public lgfx::LGFX_Device lgfx::Panel_RGB _panel_instance; lgfx::Touch_GT911 _touch_instance; - public: - const uint16_t screenWidth = TFT_WIDTH; - const uint16_t screenHeight = TFT_HEIGHT; + public: + const uint16_t screenWidth = TFT_WIDTH; + const uint16_t screenHeight = TFT_HEIGHT; - bool init_impl(bool use_reset, bool use_clear) override + bool init_impl(bool use_reset, bool use_clear) override { ioex.attach(Wire); ioex.setDeviceAddress(0x18); @@ -145,11 +145,11 @@ class LGFX : public lgfx::LGFX_Device ioex.config(2, TCA9534::Config::OUT); ioex.config(3, TCA9534::Config::OUT); ioex.config(4, TCA9534::Config::OUT); - + ioex.output(1, TCA9534::Level::H); ioex.output(3, TCA9534::Level::L); ioex.output(4, TCA9534::Level::H); - + pinMode(1, OUTPUT); digitalWrite(1, LOW); ioex.output(2, TCA9534::Level::L); @@ -190,16 +190,16 @@ class LGFX : public lgfx::LGFX_Device cfg.pin_d2 = ST72xx_B2; // B2 cfg.pin_d3 = ST72xx_B3; // B3 cfg.pin_d4 = ST72xx_B4; // B4 - cfg.pin_d5 = ST72xx_G0; // G0 + cfg.pin_d5 = ST72xx_G0; // G0 cfg.pin_d6 = ST72xx_G1; // G1 cfg.pin_d7 = ST72xx_G2; // G2 cfg.pin_d8 = ST72xx_G3; // G3 cfg.pin_d9 = ST72xx_G4; // G4 cfg.pin_d10 = ST72xx_G5; // G5 - cfg.pin_d11 = ST72xx_R0; // R0 + cfg.pin_d11 = ST72xx_R0; // R0 cfg.pin_d12 = ST72xx_R1; // R1 cfg.pin_d13 = ST72xx_R2; // R2 - cfg.pin_d14 = ST72xx_R3; // R3 + cfg.pin_d14 = ST72xx_R3; // R3 cfg.pin_d15 = ST72xx_R4; // R4 cfg.pin_henable = ST72xx_DE; @@ -210,53 +210,53 @@ class LGFX : public lgfx::LGFX_Device #ifdef ST7265_HSYNC_POLARITY cfg.hsync_polarity = ST7265_HSYNC_POLARITY; - cfg.hsync_front_porch = ST7265_HSYNC_FRONT_PORCH; //8; - cfg.hsync_pulse_width = ST7265_HSYNC_PULSE_WIDTH; //4; - cfg.hsync_back_porch = ST7265_HSYNC_BACK_PORCH; //8; + cfg.hsync_front_porch = ST7265_HSYNC_FRONT_PORCH; // 8; + cfg.hsync_pulse_width = ST7265_HSYNC_PULSE_WIDTH; // 4; + cfg.hsync_back_porch = ST7265_HSYNC_BACK_PORCH; // 8; - cfg.vsync_polarity = ST7265_VSYNC_POLARITY; //0; - cfg.vsync_front_porch = ST7265_VSYNC_FRONT_PORCH; //8; - cfg.vsync_pulse_width = ST7265_VSYNC_PULSE_WIDTH; //4; - cfg.vsync_back_porch = ST7265_VSYNC_BACK_PORCH; //8; + cfg.vsync_polarity = ST7265_VSYNC_POLARITY; // 0; + cfg.vsync_front_porch = ST7265_VSYNC_FRONT_PORCH; // 8; + cfg.vsync_pulse_width = ST7265_VSYNC_PULSE_WIDTH; // 4; + cfg.vsync_back_porch = ST7265_VSYNC_BACK_PORCH; // 8; cfg.pclk_idle_high = 1; - cfg.pclk_active_neg = ST7265_PCLK_ACTIVE_NEG; //0; - //cfg.pclk_idle_high = 0; - //cfg.de_idle_high = 1; + cfg.pclk_active_neg = ST7265_PCLK_ACTIVE_NEG; // 0; + // cfg.pclk_idle_high = 0; + // cfg.de_idle_high = 1; #endif #ifdef ST7262_HSYNC_POLARITY cfg.hsync_polarity = ST7262_HSYNC_POLARITY; - cfg.hsync_front_porch = ST7262_HSYNC_FRONT_PORCH; //8; - cfg.hsync_pulse_width = ST7262_HSYNC_PULSE_WIDTH; //4; - cfg.hsync_back_porch = ST7262_HSYNC_BACK_PORCH; //8; + cfg.hsync_front_porch = ST7262_HSYNC_FRONT_PORCH; // 8; + cfg.hsync_pulse_width = ST7262_HSYNC_PULSE_WIDTH; // 4; + cfg.hsync_back_porch = ST7262_HSYNC_BACK_PORCH; // 8; - cfg.vsync_polarity = ST7262_VSYNC_POLARITY; //0; - cfg.vsync_front_porch = ST7262_VSYNC_FRONT_PORCH; //8; - cfg.vsync_pulse_width = ST7262_VSYNC_PULSE_WIDTH; //4; - cfg.vsync_back_porch = ST7262_VSYNC_BACK_PORCH; //8; + cfg.vsync_polarity = ST7262_VSYNC_POLARITY; // 0; + cfg.vsync_front_porch = ST7262_VSYNC_FRONT_PORCH; // 8; + cfg.vsync_pulse_width = ST7262_VSYNC_PULSE_WIDTH; // 4; + cfg.vsync_back_porch = ST7262_VSYNC_BACK_PORCH; // 8; cfg.pclk_idle_high = 1; - cfg.pclk_active_neg = ST7262_PCLK_ACTIVE_NEG; //0; - //cfg.pclk_idle_high = 0; - //cfg.de_idle_high = 1; + cfg.pclk_active_neg = ST7262_PCLK_ACTIVE_NEG; // 0; + // cfg.pclk_idle_high = 0; + // cfg.de_idle_high = 1; #endif #ifdef SC7277_HSYNC_POLARITY cfg.hsync_polarity = SC7277_HSYNC_POLARITY; - cfg.hsync_front_porch = SC7277_HSYNC_FRONT_PORCH; //8; - cfg.hsync_pulse_width = SC7277_HSYNC_PULSE_WIDTH; //4; - cfg.hsync_back_porch = SC7277_HSYNC_BACK_PORCH; //8; + cfg.hsync_front_porch = SC7277_HSYNC_FRONT_PORCH; // 8; + cfg.hsync_pulse_width = SC7277_HSYNC_PULSE_WIDTH; // 4; + cfg.hsync_back_porch = SC7277_HSYNC_BACK_PORCH; // 8; - cfg.vsync_polarity = SC7277_VSYNC_POLARITY; //0; - cfg.vsync_front_porch = SC7277_VSYNC_FRONT_PORCH; //8; - cfg.vsync_pulse_width = SC7277_VSYNC_PULSE_WIDTH; //4; - cfg.vsync_back_porch = SC7277_VSYNC_BACK_PORCH; //8; + cfg.vsync_polarity = SC7277_VSYNC_POLARITY; // 0; + cfg.vsync_front_porch = SC7277_VSYNC_FRONT_PORCH; // 8; + cfg.vsync_pulse_width = SC7277_VSYNC_PULSE_WIDTH; // 4; + cfg.vsync_back_porch = SC7277_VSYNC_BACK_PORCH; // 8; cfg.pclk_idle_high = 1; - cfg.pclk_active_neg = SC7277_PCLK_ACTIVE_NEG; //0; - //cfg.pclk_idle_high = 0; - //cfg.de_idle_high = 1; + cfg.pclk_active_neg = SC7277_PCLK_ACTIVE_NEG; // 0; + // cfg.pclk_idle_high = 0; + // cfg.de_idle_high = 1; #endif _bus_instance.config(cfg); @@ -327,29 +327,29 @@ class LGFX : public lgfx::LGFX_Device { // Set the display panel control. auto cfg = _panel_instance.config(); // Gets a structure for display panel settings. - cfg.pin_cs = ILI9488_CS; // Pin number where CS is connected (-1 = disable) - cfg.pin_rst = -1; // Pin number where RST is connected (-1 = disable) - cfg.pin_busy = -1; // Pin number where BUSY is connected (-1 = disable) + cfg.pin_cs = ILI9488_CS; // Pin number where CS is connected (-1 = disable) + cfg.pin_rst = -1; // Pin number where RST is connected (-1 = disable) + cfg.pin_busy = -1; // Pin number where BUSY is connected (-1 = disable) // The following setting values ​​are general initial values ​​for each panel, so please comment out any // unknown items and try them. - cfg.memory_width = TFT_WIDTH; // Maximum width supported by the driver IC - cfg.memory_height = TFT_HEIGHT; // Maximum height supported by the driver IC - cfg.panel_width = TFT_WIDTH; // actual displayable width - cfg.panel_height = TFT_HEIGHT; // actual displayable height - cfg.offset_x = TFT_OFFSET_X; // Panel offset amount in X direction - cfg.offset_y = TFT_OFFSET_Y; // Panel offset amount in Y direction - cfg.offset_rotation = TFT_OFFSET_ROTATION; // Rotation direction value offset 0~7 (4~7 is mirrored) + cfg.memory_width = TFT_WIDTH; // Maximum width supported by the driver IC + cfg.memory_height = TFT_HEIGHT; // Maximum height supported by the driver IC + cfg.panel_width = TFT_WIDTH; // actual displayable width + cfg.panel_height = TFT_HEIGHT; // actual displayable height + cfg.offset_x = TFT_OFFSET_X; // Panel offset amount in X direction + cfg.offset_y = TFT_OFFSET_Y; // Panel offset amount in Y direction + cfg.offset_rotation = TFT_OFFSET_ROTATION; // Rotation direction value offset 0~7 (4~7 is mirrored) #ifdef TFT_DUMMY_READ_PIXELS - cfg.dummy_read_pixel = TFT_DUMMY_READ_PIXELS; // Number of bits for dummy read before pixel readout + cfg.dummy_read_pixel = TFT_DUMMY_READ_PIXELS; // Number of bits for dummy read before pixel readout #else - cfg.dummy_read_pixel = 9; // Number of bits for dummy read before pixel readout + cfg.dummy_read_pixel = 9; // Number of bits for dummy read before pixel readout #endif - cfg.dummy_read_bits = 1; // Number of bits for dummy read before non-pixel data read - cfg.readable = true; // Set to true if data can be read - cfg.invert = true; // Set to true if the light/darkness of the panel is reversed - cfg.rgb_order = false; // Set to true if the panel's red and blue are swapped + cfg.dummy_read_bits = 1; // Number of bits for dummy read before non-pixel data read + cfg.readable = true; // Set to true if data can be read + cfg.invert = true; // Set to true if the light/darkness of the panel is reversed + cfg.rgb_order = false; // Set to true if the panel's red and blue are swapped cfg.dlen_16bit = false; // Set to true for panels that transmit data length in 16-bit units with 16-bit parallel or SPI cfg.bus_shared = true; // If the bus is shared with the SD card, set to true (bus control with drawJpgFile etc.) @@ -367,7 +367,7 @@ class LGFX : public lgfx::LGFX_Device auto cfg = _light_instance.config(); // Gets a structure for backlight settings. cfg.pin_bl = ILI9488_BL; // Pin number to which the backlight is connected - cfg.invert = false; // true to invert the brightness of the backlight + cfg.invert = false; // true to invert the brightness of the backlight // cfg.freq = 44100; // PWM frequency of backlight // cfg.pwm_channel = 1; // PWM channel number to use @@ -387,7 +387,7 @@ class LGFX : public lgfx::LGFX_Device cfg.y_min = 0; cfg.y_max = TFT_WIDTH - 1; cfg.pin_int = SCREEN_TOUCH_INT; -#ifdef SCREEN_TOUCH_RST +#ifdef SCREEN_TOUCH_RST cfg.pin_rst = SCREEN_TOUCH_RST; #endif cfg.bus_shared = true; @@ -426,7 +426,7 @@ class LGFX : public lgfx::LGFX_Device lgfx::Bus_SPI _bus_instance; lgfx::Light_PWM _light_instance; #if HAS_TOUCHSCREEN -#ifdef T_WATCH_S3 +#if defined(T_WATCH_S3) || defined(ELECROW) lgfx::Touch_FT5x06 _touch_instance; #else lgfx::Touch_GT911 _touch_instance; @@ -468,22 +468,22 @@ class LGFX : public lgfx::LGFX_Device // The following setting values ​​are general initial values ​​for each panel, so please comment out any // unknown items and try them. - cfg.memory_width = TFT_WIDTH; // Maximum width supported by the driver IC - cfg.memory_height = TFT_HEIGHT; // Maximum height supported by the driver IC - cfg.panel_width = TFT_WIDTH; // actual displayable width - cfg.panel_height = TFT_HEIGHT; // actual displayable height - cfg.offset_x = TFT_OFFSET_X; // Panel offset amount in X direction - cfg.offset_y = TFT_OFFSET_Y; // Panel offset amount in Y direction - cfg.offset_rotation = TFT_OFFSET_ROTATION; // Rotation direction value offset 0~7 (4~7 is mirrored) + cfg.memory_width = TFT_WIDTH; // Maximum width supported by the driver IC + cfg.memory_height = TFT_HEIGHT; // Maximum height supported by the driver IC + cfg.panel_width = TFT_WIDTH; // actual displayable width + cfg.panel_height = TFT_HEIGHT; // actual displayable height + cfg.offset_x = TFT_OFFSET_X; // Panel offset amount in X direction + cfg.offset_y = TFT_OFFSET_Y; // Panel offset amount in Y direction + cfg.offset_rotation = TFT_OFFSET_ROTATION; // Rotation direction value offset 0~7 (4~7 is mirrored) #ifdef TFT_DUMMY_READ_PIXELS - cfg.dummy_read_pixel = TFT_DUMMY_READ_PIXELS; // Number of bits for dummy read before pixel readout + cfg.dummy_read_pixel = TFT_DUMMY_READ_PIXELS; // Number of bits for dummy read before pixel readout #else - cfg.dummy_read_pixel = 9; // Number of bits for dummy read before pixel readout + cfg.dummy_read_pixel = 9; // Number of bits for dummy read before pixel readout #endif - cfg.dummy_read_bits = 1; // Number of bits for dummy read before non-pixel data read - cfg.readable = true; // Set to true if data can be read - cfg.invert = true; // Set to true if the light/darkness of the panel is reversed - cfg.rgb_order = false; // Set to true if the panel's red and blue are swapped + cfg.dummy_read_bits = 1; // Number of bits for dummy read before non-pixel data read + cfg.readable = true; // Set to true if data can be read + cfg.invert = true; // Set to true if the light/darkness of the panel is reversed + cfg.rgb_order = false; // Set to true if the panel's red and blue are swapped cfg.dlen_16bit = false; // Set to true for panels that transmit data length in 16-bit units with 16-bit parallel or SPI cfg.bus_shared = true; // If the bus is shared with the SD card, set to true (bus control with drawJpgFile etc.) @@ -520,7 +520,7 @@ class LGFX : public lgfx::LGFX_Device cfg.y_min = 0; cfg.y_max = TFT_WIDTH - 1; cfg.pin_int = SCREEN_TOUCH_INT; -#ifdef SCREEN_TOUCH_RST +#ifdef SCREEN_TOUCH_RST cfg.pin_rst = SCREEN_TOUCH_RST; #endif cfg.bus_shared = true; @@ -946,7 +946,7 @@ static LGFX *tft = nullptr; #endif #if defined(ST7701_CS) || defined(ST7735_CS) || defined(ST7789_CS) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || \ - defined(RAK14014) || defined(HX8357_CS) || defined(ILI9488_CS) || defined (ST72xx_DE) || (ARCH_PORTDUINO && HAS_SCREEN != 0) + defined(RAK14014) || defined(HX8357_CS) || defined(ILI9488_CS) || defined(ST72xx_DE) || (ARCH_PORTDUINO && HAS_SCREEN != 0) #include "SPILock.h" #include "TFTDisplay.h" #include