From a79067946656c600752d0de5a269df751459caa6 Mon Sep 17 00:00:00 2001 From: fvanroie Date: Tue, 18 Jul 2023 15:18:33 +0200 Subject: [PATCH] Add Elecrow ESP-Terminal SPI and RGB --- .github/workflows/build.yaml | 6 ++++-- src/drv/tft/tft_driver_lovyangfx.cpp | 28 ++++++++++++++++++---------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3ff2e45c..a3999b15 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -32,10 +32,10 @@ jobs: out: d1-r32-espduino32 - env: d1-r32-unoshield_ili9486_adc out: d1-r32-espduino32 - - out: waveshare - env: "esp32-one_ili9486 -e esp32-one_st7796" - out: dustinwatts env: "freetouchdeck_4MB -e freetouchdeck_8MB -e esp32-touchdown" + - out: elecrow + env: "esp-terminal-rgb_16MB -e esp-terminal-spi_16MB" - out: globalsecurity env: gs-t3e_16MB - out: lanbon @@ -52,6 +52,8 @@ jobs: env: "panlee-zw3d95ce01s-ar-4848_16MB -e panlee-zw3d95ce01s-ur-4848_16MB" - out: sunton env: "esp32-2432s028r_4MB -e esp32-3248s035c_4MB -e esp32-3248s035r_4MB -e sunton-4827s043c_16MB -e sunton-8048s043c_16MB -e sunton-8048s050c_16MB -e sunton-8048s070c_16MB" + - out: waveshare + env: "esp32-one_ili9486 -e esp32-one_st7796" - out: wireless-tag env: "wt32-sc01_4MB -e wt32-sc01_16MB -e wt-86-32-3zw1 -e wt32-sc01-plus_8MB -e wt32-sc01-plus_16MB" - out: yeacreate diff --git a/src/drv/tft/tft_driver_lovyangfx.cpp b/src/drv/tft/tft_driver_lovyangfx.cpp index 9469f603..d783a2d7 100644 --- a/src/drv/tft/tft_driver_lovyangfx.cpp +++ b/src/drv/tft/tft_driver_lovyangfx.cpp @@ -57,7 +57,7 @@ static uint32_t _read_panel_id(lgfx::Bus_SPI* bus, int32_t pin_cs, uint32_t cmd return res; } -#if defined(ESP32S2) || defined(ESP32S3) +#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) static lgfx::Bus_Parallel16* init_parallel_16_bus(Preferences* prefs, int8_t data_pins[], uint8_t num) { lgfx::Bus_Parallel16* bus = new lgfx::v1::Bus_Parallel16(); @@ -85,7 +85,7 @@ static lgfx::Bus_Parallel16* init_parallel_16_bus(Preferences* prefs, int8_t dat LOG_DEBUG(TAG_TFT, F("%s - %d"), __FILE__, __LINE__); return bus; } -#endif // ESP32S2 +#endif // ESP32S2/S3 static lgfx::Bus_Parallel8* init_parallel_8_bus(Preferences* prefs, int8_t data_pins[], uint8_t num) { @@ -223,9 +223,17 @@ static void configure_panel(lgfx::Panel_Device* panel, Preferences* prefs) #else cfg.rgb_order = prefs->getBool("rgb_order", false); // true if the red and blue of the panel are swapped #endif - cfg.dlen_16bit = prefs->getBool("dlen_16bit", false); // true for panels that send data length in 16-bit units - cfg.bus_shared = prefs->getBool("bus_shared", true); // true if the bus is shared with the SD card - // (bus control is performed with drawJpgFile etc.) + + bool dlen_16bit = false; +#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) + if(panel->getBus()) { + lgfx::v1::bus_type_t bus_type = panel->getBus()->busType(); + if(bus_type == lgfx::v1::bus_parallel16) dlen_16bit = true; + } +#endif + cfg.dlen_16bit = prefs->getBool("dlen_16bit", dlen_16bit); // true for panels that send data length in 16-bit units + cfg.bus_shared = prefs->getBool("bus_shared", true); // true if the bus is shared with the SD card + // (bus control is performed with drawJpgFile etc.) panel->config(cfg); } @@ -240,7 +248,7 @@ lgfx::IBus* _init_bus(Preferences* preferences) for(uint8_t i = 0; i < 16; i++) { snprintf(key, sizeof(key), "d%d", i + 1); data_pins[i] = preferences->getInt(key, data_pins[i]); - LOG_DEBUG(TAG_TFT, F("D%d: %d"), i + 1, data_pins[i]); + LOG_DEBUG(TAG_TFT, F("D%d: %d"), i, data_pins[i]); } LOG_DEBUG(TAG_TFT, F("%s - %d"), __FILE__, __LINE__); @@ -252,13 +260,13 @@ lgfx::IBus* _init_bus(Preferences* preferences) } LOG_DEBUG(TAG_TFT, F("%s - %d"), __FILE__, __LINE__); -#if defined(ESP32S2) +#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) if(is_16bit) { is_8bit = false; LOG_VERBOSE(TAG_TFT, F("16-bit TFT bus")); return init_parallel_16_bus(preferences, data_pins, 16); } else -#endif // ESP32S2 +#endif // ESP32S2/S3 if(is_8bit) { is_16bit = false; LOG_VERBOSE(TAG_TFT, F("8-bit TFT bus")); @@ -1012,7 +1020,7 @@ void LovyanGfx::show_info() tftPinInfo(F("TFT_D7"), cfg.pin_d7); } -#if defined(ESP32S2) || defined(ESP32S3) +#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) if(bus_type == lgfx::v1::bus_parallel16) { LOG_VERBOSE(TAG_TFT, F("Interface : Parallel 16bit")); auto bus = (lgfx::v1::Bus_Parallel16*)panel->getBus(); @@ -1144,7 +1152,7 @@ bool LovyanGfx::is_driver_pin(uint8_t pin) pin == cfg.pin_d7) return true; -#if defined(ESP32S2) || defined(ESP32S3) +#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) } else if(bus_type == lgfx::v1::bus_parallel16) { auto bus = (lgfx::v1::Bus_Parallel16*)panel->getBus(); auto cfg = bus->config(); // Get the structure for bus configuration.