From 5fcca363f814fb00b0c7b248c5d0bff1f92ee666 Mon Sep 17 00:00:00 2001 From: norbert-walter Date: Thu, 19 Mar 2026 17:34:10 +0100 Subject: [PATCH] Modify TFT display initialisiation --- lib/obp60task/OBP60Extensions.h | 54 +++++++++++++++++++++++++++++---- lib/obp60task/platformio.ini | 4 +-- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/lib/obp60task/OBP60Extensions.h b/lib/obp60task/OBP60Extensions.h index 1dc130f..9e2bc99 100644 --- a/lib/obp60task/OBP60Extensions.h +++ b/lib/obp60task/OBP60Extensions.h @@ -94,16 +94,13 @@ class LGFX : public lgfx::LGFX_Device { public: lgfx::Bus_SPI _bus_instance; + #ifdef TFT_320x480_ST7796 LGFX(void) { { auto cfg = _bus_instance.config(); cfg.spi_host = SPI2_HOST; cfg.spi_mode = 0; - #if defined(TFT_320x480_ILI9488) - cfg.freq_write = 40000000; - #else - cfg.freq_write = 80000000; - #endif + cfg.freq_write = 80000000; // High speed ST7796 cfg.freq_read = 16000000; cfg.pin_sclk = OBP_SPI_CLK; cfg.pin_mosi = OBP_SPI_DIN; @@ -121,7 +118,7 @@ public: cfg.panel_height = 480; // Native hight resolution cfg.offset_x = 0; // No panel offset: full framebuffer mapping cfg.offset_y = 0; // No panel offset: full framebuffer mapping - cfg.offset_rotation = 3; // Rotate display content conter clock wise 90 deg + cfg.offset_rotation = 3; // Rotate display content conter clock wise 90 deg ST7796 cfg.dummy_read_pixel = 8; cfg.dummy_read_bits = 1; cfg.memory_width = 320; @@ -139,6 +136,51 @@ public: // Match Adafruit GFX cursor semantics: y coordinate is text baseline. setTextDatum(textdatum_t::baseline_left); } + #endif + + #ifdef TFT_320x480_ILI9488 + LGFX(void) { + { + auto cfg = _bus_instance.config(); + cfg.spi_host = SPI2_HOST; + cfg.spi_mode = 0; + cfg.freq_write = 40000000; // Slow speed ILI9488 + cfg.freq_read = 16000000; + cfg.pin_sclk = OBP_SPI_CLK; + cfg.pin_mosi = OBP_SPI_DIN; + cfg.pin_miso = -1; + cfg.pin_dc = OBP_SPI_DC; + _bus_instance.config(cfg); + _panel_instance.setBus(&_bus_instance); + } + { + auto cfg = _panel_instance.config(); + cfg.pin_cs = OBP_SPI_CS; + cfg.pin_rst = OBP_SPI_RST; + cfg.pin_busy = -1; + cfg.panel_width = 320; // Native width resolution + cfg.panel_height = 480; // Native hight resolution + cfg.offset_x = 0; // No panel offset: full framebuffer mapping + cfg.offset_y = 0; // No panel offset: full framebuffer mapping + cfg.offset_rotation = 1; // Rotate display content clock wise 90 deg ILI9488 + cfg.dummy_read_pixel = 8; + cfg.dummy_read_bits = 1; + cfg.memory_width = 320; + cfg.memory_height = 480; + // cfg.pwm_control not available in this LovyanGFX version + cfg.invert = false; + cfg.rgb_order = false; + cfg.dlen_16bit = false; + cfg.bus_shared = true; + _panel_instance.config(cfg); + } + // No dedicated TFT PWM backlight pin configured on this board. + // Keep backlight handling outside LovyanGFX to avoid LEDC init on invalid GPIO. + setPanel(&_panel_instance); + // Match Adafruit GFX cursor semantics: y coordinate is text baseline. + setTextDatum(textdatum_t::baseline_left); + } + #endif // compatibility helpers -------------------------------------------------- using lgfx::LGFX_Device::setFont; diff --git a/lib/obp60task/platformio.ini b/lib/obp60task/platformio.ini index 031e68c..8e0aaab 100644 --- a/lib/obp60task/platformio.ini +++ b/lib/obp60task/platformio.ini @@ -56,8 +56,8 @@ build_flags= # -D HARDWARE_V20 #OBP60 hardware revision V2.0 -D HARDWARE_V21 #OBP60 hardware revision V2.1 -D TFT_DISPLAY #Enable TFT LCD display path (instead of E-Ink) - -D TFT_320x480_ST7796 #TFT panel type: ST7796 (320x480) -# -D TFT_320x480_ILI9488 #TFT panel type: ILI9488 (320x480), use instead of ST7796 +# -D TFT_320x480_ST7796 #TFT panel type: ST7796 (320x480, 80 MHz), best performance + -D TFT_320x480_ILI9488 #TFT panel type: ILI9488 (320x480, 40 MHz), lower performance -D OBP_TFT_ENABLE_SCALING=1 #TFT scaling on/off (1=scale to max Y=320, 0=no scaling) -D OBP_TFT_SCALE_ANTIALIAS=1 #Antialiasing for TFT scaling (1=on, 0=off) # -D ENABLE_PATCHES #enable patching of gateway code