From 52861a6a5d2af151ee47c18bc915ad510f9cefdd Mon Sep 17 00:00:00 2001 From: LILYGO_L <13073925292@163.com> Date: Thu, 21 Nov 2024 14:21:53 +0800 Subject: [PATCH 1/5] The addition of support for T-Panel (verified). --- boards/esp32s3_flash_16MB.json | 43 ++++++ .../Arduino_RGB_Display_mod.h | 130 ++++++++++++++++++ src/drv/tft/tft_driver_arduinogfx.cpp | 5 +- src/drv/touch/touch_driver.h | 3 + src/drv/touch/touch_driver_cst3240.cpp | 72 ++++++++++ src/drv/touch/touch_driver_cst3240.h | 26 ++++ user_setups/esp32s3/_esp32s3.ini | 11 +- user_setups/esp32s3/lilygo-t-panel.ini | 43 ++++-- 8 files changed, 312 insertions(+), 21 deletions(-) create mode 100644 boards/esp32s3_flash_16MB.json create mode 100644 src/drv/touch/touch_driver_cst3240.cpp create mode 100644 src/drv/touch/touch_driver_cst3240.h diff --git a/boards/esp32s3_flash_16MB.json b/boards/esp32s3_flash_16MB.json new file mode 100644 index 000000000..2f4ff0227 --- /dev/null +++ b/boards/esp32s3_flash_16MB.json @@ -0,0 +1,43 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "ESP32-S3-FLASH-16MB", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 921600 + }, + "url": "null", + "vendor": "null" +} \ No newline at end of file diff --git a/lib/Arduino_RPi_DPI_RGBPanel_mod/Arduino_RGB_Display_mod.h b/lib/Arduino_RPi_DPI_RGBPanel_mod/Arduino_RGB_Display_mod.h index ae343534f..b9c78a6e9 100644 --- a/lib/Arduino_RPi_DPI_RGBPanel_mod/Arduino_RGB_Display_mod.h +++ b/lib/Arduino_RPi_DPI_RGBPanel_mod/Arduino_RGB_Display_mod.h @@ -265,6 +265,136 @@ static const uint8_t st7701_sensecap_indicator_init_operations[] = { DELAY, 120, }; +static const uint8_t st7701_t_panel_init_operations[] = { + + BEGIN_WRITE, + WRITE_COMMAND_8, 0xFF, + WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x13, + + WRITE_C8_D8, 0xEF, 0x08, + + WRITE_COMMAND_8, 0xFF, + WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x10, + + WRITE_C8_D16, 0xC0, 0x3B, 0x00, + WRITE_C8_D16, 0xC1, 0x0B, 0x02, + + WRITE_COMMAND_8, 0xC2, + WRITE_BYTES, 3, 0x30, 0x02, 0x37, + + WRITE_C8_D8, 0xCC, 0x10, + + WRITE_COMMAND_8, 0xB0, // Positive Voltage Gamma Control + WRITE_BYTES, 16, + 0x00, 0x0F, 0x16, 0x0E, + 0x11, 0x07, 0x09, 0x09, + 0x08, 0x23, 0x05, 0x11, + 0x0F, 0x28, 0x2D, 0x18, + + WRITE_COMMAND_8, 0xB1, // Negative Voltage Gamma Control + WRITE_BYTES, 16, + 0x00, 0x0F, 0x16, 0x0E, + 0x11, 0x07, 0x09, 0x08, + 0x09, 0x23, 0x05, 0x11, + 0x0F, 0x28, 0x2D, 0x18, + + WRITE_COMMAND_8, 0xFF, + WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x11, + + WRITE_C8_D8, 0xB0, 0x4D, + WRITE_C8_D8, 0xB1, 0x33, + WRITE_C8_D8, 0xB2, 0x87, + WRITE_C8_D8, 0xB5, 0x4B, + WRITE_C8_D8, 0xB7, 0x8C, + WRITE_C8_D8, 0xB8, 0x20, + WRITE_C8_D8, 0xC1, 0x78, + WRITE_C8_D8, 0xC2, 0x78, + WRITE_C8_D8, 0xD0, 0x88, + + WRITE_COMMAND_8, 0xE0, + WRITE_BYTES, 3, 0x00, 0x00, 0x02, + + WRITE_COMMAND_8, 0xE1, + WRITE_BYTES, 11, + 0x02, 0xF0, 0x00, 0x00, + 0x03, 0xF0, 0x00, 0x00, + 0x00, 0x44, 0x44, + + WRITE_COMMAND_8, 0xE2, + WRITE_BYTES, 12, + 0x10, 0x10, 0x40, 0x40, + 0xF2, 0xF0, 0x00, 0x00, + 0xF2, 0xF0, 0x00, 0x00, + + WRITE_COMMAND_8, 0xE3, + WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11, + + WRITE_C8_D16, 0xE4, 0x44, 0x44, + + WRITE_COMMAND_8, 0xE5, + WRITE_BYTES, 16, + 0x07, 0xEF, 0xF0, 0xF0, + 0x09, 0xF1, 0xF0, 0xF0, + 0x03, 0xF3, 0xF0, 0xF0, + 0x05, 0xED, 0xF0, 0xF0, + + WRITE_COMMAND_8, 0xE6, + WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11, + + WRITE_C8_D16, 0xE7, 0x44, 0x44, + + WRITE_COMMAND_8, 0xE8, + WRITE_BYTES, 16, + 0x08, 0xF0, 0xF0, 0xF0, + 0x0A, 0xF2, 0xF0, 0xF0, + 0x04, 0xF4, 0xF0, 0xF0, + 0x06, 0xEE, 0xF0, 0xF0, + + WRITE_COMMAND_8, 0xEB, + WRITE_BYTES, 7, + 0x00, 0x00, 0xE4, 0xE4, + 0x44, 0x88, 0x40, + + WRITE_C8_D16, 0xEC, 0x78, 0x00, + + WRITE_COMMAND_8, 0xED, + WRITE_BYTES, 16, + 0x20, 0xF9, 0x87, 0x76, + 0x65, 0x54, 0x4F, 0xFF, + 0xFF, 0xF4, 0x45, 0x56, + 0x67, 0x78, 0x9F, 0x02, + + WRITE_COMMAND_8, 0xEF, + WRITE_BYTES, 6, + 0x10, 0x0D, 0x04, 0x08, + 0x3F, 0x1F, + + // WRITE_C8_D8, 0xCD, 0x05,//Test + + WRITE_C8_D8, 0x3A, 0x55, + + WRITE_C8_D8, 0x36, 0x08, + + WRITE_COMMAND_8, 0x11, + + // WRITE_COMMAND_8, 0xFF,//Test + // WRITE_BYTES, 5, + // 0x77, 0x01, 0x00, 0x00, + // 0x12, + + // WRITE_C8_D8, 0xD1, 0x81,//Test + // WRITE_C8_D8, 0xD2, 0x08,//Test + + WRITE_COMMAND_8, 0x29, // Display On + + // WRITE_C8_D8, 0x35, 0x00,//Test + // WRITE_C8_D8, 0xCE, 0x04,//Test + + // WRITE_COMMAND_8, 0xF2,//Test + // WRITE_BYTES, 4, + // 0xF0, 0xA3, 0xA3, 0x71, + + END_WRITE}; class Arduino_RGB_Display_Mod : public Arduino_GFX{ public: diff --git a/src/drv/tft/tft_driver_arduinogfx.cpp b/src/drv/tft/tft_driver_arduinogfx.cpp index 70406e723..8826cef85 100644 --- a/src/drv/tft/tft_driver_arduinogfx.cpp +++ b/src/drv/tft/tft_driver_arduinogfx.cpp @@ -37,8 +37,9 @@ void ArduinoGfx::init(int w, int h) ); #elif(TFT_WIDTH == 480) && (TFT_HEIGHT == 480) && defined(LILYGO_T_PANEL) + Wire.begin(17, 18); Arduino_DataBus* bus = new Arduino_XL9535SWSPI(17 /* SDA */, 18 /* SCL */, -1 /* XL PWD */, 17 /* XL CS */, - 15 /* XL SCK */, 16 /* XL MOSI */); + 15 /* XL SCK */, 16 /* XL MOSI */,&Wire); Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( -1 /* DE */, TFT_VSYNC /* VSYNC */, TFT_HSYNC /* HSYNC */, TFT_PCLK /* PCLK */, TFT_B0 /* B0 */, TFT_B1 /* B1 */, TFT_B2 /* B2 */, TFT_B3 /* B3 */, TFT_B4 /* B4 */, @@ -50,7 +51,7 @@ void ArduinoGfx::init(int w, int h) 0 /* de_idle_high*/, 0 /* pclk_idle_high */); tft = new Arduino_RGB_Display(TFT_WIDTH /* width */, TFT_HEIGHT /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */, - bus, -1 /* RST */, st7701_sensecap_indicator_init_operations, sizeof(st7701_sensecap_indicator_init_operations)); + bus, -1 /* RST */, st7701_t_panel_init_operations, sizeof(st7701_t_panel_init_operations)); #elif(TFT_WIDTH == 480) && (TFT_HEIGHT == 480) && defined(LILYGO_T_RGB) Wire.begin(8 /* SDA */, 48 /* SCL */, 800000L /* speed */); diff --git a/src/drv/touch/touch_driver.h b/src/drv/touch/touch_driver.h index 054e8cada..f3e2ccfda 100644 --- a/src/drv/touch/touch_driver.h +++ b/src/drv/touch/touch_driver.h @@ -90,6 +90,9 @@ class BaseTouch { #elif defined(LGFX_USE_V1) #warning Building for LovyanGfx Touch #include "touch_driver_lovyangfx.h" +#elif TOUCH_DRIVER == 0x3240 +#warning Building for CST3240 +#include "touch_driver_cst3240.h" #else #warning Building for Generic Touch using dev::BaseTouch; diff --git a/src/drv/touch/touch_driver_cst3240.cpp b/src/drv/touch/touch_driver_cst3240.cpp new file mode 100644 index 000000000..3c6cbec86 --- /dev/null +++ b/src/drv/touch/touch_driver_cst3240.cpp @@ -0,0 +1,72 @@ +/* MIT License - Copyright (c) 2019-2024 Francis Van Roie + For full license information read the LICENSE file in the project folder */ + +#if defined(ARDUINO) && (TOUCH_DRIVER == 0x3240) && !defined(HASP_USE_LGFX_TOUCH) +#include +#include "ArduinoLog.h" +#include "hasp_conf.h" +#include "touch_driver_cst3240.h" + +#include +#include "TouchLib.h" + +#include "touch_driver.h" // base class +#include "touch_helper.h" // i2c scanner + +#include "../../hasp/hasp.h" // for hasp_sleep_state +extern uint8_t hasp_sleep_state; + +TouchLib touch(Wire, TOUCH_SDA, TOUCH_SCL, I2C_TOUCH_ADDRESS); + +namespace dev { + +IRAM_ATTR bool TouchCst3240::read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) +{ + touch.read(); + TP_Point t = touch.getPoint(0); + + if((touch.getPointNum() == 1) && (t.pressure > 0) && (t.state != 0)) { + + if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle + +#ifdef TOUCH_WIDTH + data->point.x = map(t.x, 0, TOUCH_WIDTH - 1, 0, TFT_WIDTH - 1); +#else + data->point.x = t.x; +#endif + +#ifdef TOUCH_HEIGHT + data->point.y = map(t.y, 0, TOUCH_HEIGHT - 1, 0, TFT_HEIGHT - 1); +#else + data->point.y = t.y; +#endif + + data->state = LV_INDEV_STATE_PR; + hasp_set_sleep_offset(0); // Reset the offset + + } else { + data->state = LV_INDEV_STATE_REL; + } + + /*Return `false` because we are not buffering and no more data to read*/ + return false; +} + +void TouchCst3240::init(int w, int h) +{ + Wire.begin(TOUCH_SDA, TOUCH_SCL, (uint32_t)I2C_TOUCH_FREQUENCY); + if(touch.init() == true) { + LOG_INFO(TAG_DRVR, "CST3240 %s (480x480)", D_SERVICE_STARTED); + } else { + LOG_WARNING(TAG_DRVR, "CST3240 %s", D_SERVICE_START_FAILED); + } + + Wire.begin(TOUCH_SDA, TOUCH_SCL, (uint32_t)I2C_TOUCH_FREQUENCY); + touch_scan(Wire); // The address could change during begin, so scan afterwards +} + +} // namespace dev + +dev::TouchCst3240 haspTouch; + +#endif // ARDUINO diff --git a/src/drv/touch/touch_driver_cst3240.h b/src/drv/touch/touch_driver_cst3240.h new file mode 100644 index 000000000..776e29a9b --- /dev/null +++ b/src/drv/touch/touch_driver_cst3240.h @@ -0,0 +1,26 @@ +/* MIT License - Copyright (c) 2019-2024 Francis Van Roie + For full license information read the LICENSE file in the project folder */ + +#ifndef HASP_CST3240_TOUCH_DRIVER_H +#define HASP_CST3240_TOUCH_DRIVER_H + +#ifdef ARDUINO +#include "lvgl.h" +#include "touch_driver.h" + +namespace dev { + +class TouchCst3240 : public BaseTouch { + public: + IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data); + void init(int w, int h); +}; + +} // namespace dev + +using dev::TouchCst3240; +extern dev::TouchCst3240 haspTouch; + +#endif // ARDUINO + +#endif // HASP_CST3240_TOUCH_DRIVER_H diff --git a/user_setups/esp32s3/_esp32s3.ini b/user_setups/esp32s3/_esp32s3.ini index 71ad202d7..9ede46419 100644 --- a/user_setups/esp32s3/_esp32s3.ini +++ b/user_setups/esp32s3/_esp32s3.ini @@ -5,11 +5,11 @@ board_build.mcu = esp32s3 ps_ram = -DBOARD_HAS_PSRAM - -D HASP_USE_FREETYPE=1 - -D LV_USE_FREETYPE=1 + -D HASP_USE_FREETYPE=0 + -D LV_USE_FREETYPE=0 no_ps_ram = - -D HASP_USE_FREETYPE=1 - -D LV_USE_FREETYPE=1 + -D HASP_USE_FREETYPE=0 + -D LV_USE_FREETYPE=0 ; -- The Arduino ESP32 v2.0.2 with 3 available flash sizes: [arduino_esp32s3_v2] @@ -18,4 +18,5 @@ framework = arduino ; platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.05.01/platform-espressif32.zip ; platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.08.01/platform-espressif32.zip ; platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32.zip -platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32.zip \ No newline at end of file +; platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32.zip +platform = espressif32 @6.5.0 \ No newline at end of file diff --git a/user_setups/esp32s3/lilygo-t-panel.ini b/user_setups/esp32s3/lilygo-t-panel.ini index 54d5f6006..8260f8c08 100644 --- a/user_setups/esp32s3/lilygo-t-panel.ini +++ b/user_setups/esp32s3/lilygo-t-panel.ini @@ -8,8 +8,13 @@ [lilygo-t-panel] extends = arduino_esp32s3_v2 -board = esp32-s3-devkitc-1 -board_build.arduino.memory_type = qio_opi +board = esp32s3_flash_16MB + +; board_build.memory_type = qio_opi ;Enable internal PSRAM +board_build.memory_type = qio_qspi ;Enable external PSRAM + +board_upload.flash_size = 16MB +board_build.partitions = default_16MB.csv build_flags = -D HASP_MODEL="Lilygo T-Panel v1.2" @@ -17,8 +22,16 @@ build_flags = ${esp32s3.ps_ram} -DLILYGO_T_PANEL -D LILYGO_T_PANEL=1 - ;-DARDUINO_USB_CDC_ON_BOOT - ;-DUSE_USB_CDC_CONSOLE + + -Wall ;all errors that everybody could agree on + -Wextra ;somebody agree on + ; -Werror ;Think of "Warning" as "Error". + ; -D CORE_DEBUG_LEVEL=1 ;Debug level 0-5 + -D BOARD_HAS_PSRAM ;Enable external PSRAM + -D ARDUINO_USB_MODE=1 + -D ARDUINO_USB_CDC_ON_BOOT=0 ;1 is to use the USB port as a serial port + -D ARDUINO_RUNNING_CORE=1 ; Arduino Runs On Core (setup, loop) + -D ARDUINO_EVENT_RUNNING_CORE=1 ; Events Run On Core ;region -- ArduinoGFX build options ------------------------ -D HASP_USE_ARDUINOGFX=1 @@ -49,27 +62,29 @@ build_flags = -D TFT_BCKL=14 ; Touch Settings + -D TOUCH_MODULES_CST_MUTUAL + -D TOUCH_DRIVER=0x3240 -D TOUCH_WIDTH=480 -D TOUCH_HEIGHT=480 -D TOUCH_SDA=17 -D TOUCH_SCL=18 -D TOUCH_INT=21 - -D TOUCH_RST=4 + -D TOUCH_RST=-1 -D TOUCH_CS=-1 - -D TOUCH_DRIVER=0x3240 - ; -D TOUCH_IRQ= - ; -D I2C_TOUCH_FREQUENCY= - ; -D I2C_TOUCH_ADDRESS= + -D TOUCH_IRQ=TOUCH_INT + -D I2C_TOUCH_FREQUENCY=400000UL + -D I2C_TOUCH_ADDRESS=0x5A ; -D I2C_TOUCH_PORT= + -D LV_DISP_DEF_REFR_PERIOD=10 + ;endregion lib_deps = ${arduino_esp32s3_v2.lib_deps} -; moononournation/GFX Library for Arduino@1.4.0 ; Update needs modification of custom PCA class ; ${ft6336.lib_deps} -; ; git+https://github.com/admarschoonen/TouchLib.git - ; moononournation/GFX Library for Arduino@1.4.0 ; + git+https://github.com/mmMicky/TouchLib.git + moononournation/GFX Library for Arduino@1.4.0 [env:lilygo-t-panel_16MB] extends = lilygo-t-panel, flash_16mb -monitor_port = COM8 -upload_port = COM8 +; monitor_port = COM8 +; upload_port = COM8 From 81d35626aed92486fefa968323b724bb6049c8c3 Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:38:45 +0100 Subject: [PATCH 2/5] Update _esp32s3.ini --- user_setups/esp32s3/_esp32s3.ini | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/user_setups/esp32s3/_esp32s3.ini b/user_setups/esp32s3/_esp32s3.ini index 9ede46419..0a1e6c7d4 100644 --- a/user_setups/esp32s3/_esp32s3.ini +++ b/user_setups/esp32s3/_esp32s3.ini @@ -5,11 +5,11 @@ board_build.mcu = esp32s3 ps_ram = -DBOARD_HAS_PSRAM - -D HASP_USE_FREETYPE=0 - -D LV_USE_FREETYPE=0 + -D HASP_USE_FREETYPE=1 + -D LV_USE_FREETYPE=1 no_ps_ram = - -D HASP_USE_FREETYPE=0 - -D LV_USE_FREETYPE=0 + -D HASP_USE_FREETYPE=1 + -D LV_USE_FREETYPE=1 ; -- The Arduino ESP32 v2.0.2 with 3 available flash sizes: [arduino_esp32s3_v2] @@ -18,5 +18,5 @@ framework = arduino ; platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.05.01/platform-espressif32.zip ; platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.08.01/platform-espressif32.zip ; platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32.zip -; platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32.zip -platform = espressif32 @6.5.0 \ No newline at end of file +platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32.zip +; platform = espressif32 @6.5.0 From 932805d3bd0ed5da75dcaaf72fc4dd7c1398170f Mon Sep 17 00:00:00 2001 From: marsman7 Date: Tue, 3 Dec 2024 21:37:06 +0100 Subject: [PATCH 3/5] Fix compiling errors when HASP_USE_CUSTOM set to zero --- src/custom/my_custom_fan_template.cpp | 2 +- src/custom/my_custom_template.cpp | 2 +- src/custom/my_custom_template.h | 2 +- src/hasp/hasp_dispatch.cpp | 4 ++-- src/hasp/hasp_task.cpp | 4 ++-- src/hasplib.h | 2 +- src/main.cpp | 8 ++++---- src/mqtt/hasp_mqtt_esp.cpp | 2 +- src/mqtt/hasp_mqtt_paho_async.cpp | 2 +- src/mqtt/hasp_mqtt_paho_single.cpp | 2 +- src/mqtt/hasp_mqtt_pubsubclient.cpp | 2 +- src/sys/gpio/hasp_gpio.cpp | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/custom/my_custom_fan_template.cpp b/src/custom/my_custom_fan_template.cpp index a87752428..5de68952c 100644 --- a/src/custom/my_custom_fan_template.cpp +++ b/src/custom/my_custom_fan_template.cpp @@ -13,7 +13,7 @@ #include "hasplib.h" -#if defined(HASP_USE_CUSTOM) && false // <-- set this to true in your code +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 && false // <-- set this to true in your code #include "hasp_debug.h" diff --git a/src/custom/my_custom_template.cpp b/src/custom/my_custom_template.cpp index 358bbd0f5..e32ea4f65 100644 --- a/src/custom/my_custom_template.cpp +++ b/src/custom/my_custom_template.cpp @@ -6,7 +6,7 @@ #include "hasplib.h" -#if defined(HASP_USE_CUSTOM) && false // <-- set this to true in your code +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 && false // <-- set this to true in your code #include "hasp_debug.h" diff --git a/src/custom/my_custom_template.h b/src/custom/my_custom_template.h index 3e25c0311..5f156e858 100644 --- a/src/custom/my_custom_template.h +++ b/src/custom/my_custom_template.h @@ -9,7 +9,7 @@ #define HASP_CUSTOM_H #include "hasplib.h" -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 /* This function is called at boot */ void custom_setup(); diff --git a/src/hasp/hasp_dispatch.cpp b/src/hasp/hasp_dispatch.cpp index 33cffc77b..c8988f851 100644 --- a/src/hasp/hasp_dispatch.cpp +++ b/src/hasp/hasp_dispatch.cpp @@ -452,7 +452,7 @@ void dispatch_topic_payload(const char* topic, const char* payload, bool update, } #endif -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 if(topic == strstr_P(topic, PSTR(MQTT_TOPIC_CUSTOM "/"))) { // startsWith custom topic += 7u; custom_topic_payload(topic, (char*)payload, source); @@ -1295,7 +1295,7 @@ void dispatch_send_sensordata(const char*, const char*, uint8_t source) haspDevice.get_sensors(doc); -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 custom_get_sensors(doc); #endif diff --git a/src/hasp/hasp_task.cpp b/src/hasp/hasp_task.cpp index 272285d77..09650380e 100644 --- a/src/hasp/hasp_task.cpp +++ b/src/hasp/hasp_task.cpp @@ -32,7 +32,7 @@ void task_every_second_cb(lv_task_t* task) telnetEverySecond(); #endif -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 custom_every_second(); #endif // debugEverySecond(); @@ -53,7 +53,7 @@ void task_every_second_cb(lv_task_t* task) break; case 3: -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 custom_every_5seconds(); #endif break; diff --git a/src/hasplib.h b/src/hasplib.h index d4b578ad0..0c621f123 100644 --- a/src/hasplib.h +++ b/src/hasplib.h @@ -70,6 +70,6 @@ #endif #endif -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 #include "custom/my_custom.h" #endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index c68c2bf48..4d428db4b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -136,7 +136,7 @@ void setup() slaveSetup(); #endif -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 custom_setup(); #endif @@ -195,7 +195,7 @@ IRAM_ATTR void loop() consoleLoop(); #endif -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 custom_loop(); #endif @@ -222,7 +222,7 @@ IRAM_ATTR void loop() telnetEverySecond(); #endif -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 custom_every_second(); #endif // debugEverySecond(); @@ -243,7 +243,7 @@ IRAM_ATTR void loop() // gpioEvery5Seconds(); #endif -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 custom_every_5seconds(); #endif break; diff --git a/src/mqtt/hasp_mqtt_esp.cpp b/src/mqtt/hasp_mqtt_esp.cpp index f19f3c5d4..7d076d15f 100644 --- a/src/mqtt/hasp_mqtt_esp.cpp +++ b/src/mqtt/hasp_mqtt_esp.cpp @@ -371,7 +371,7 @@ void onMqttConnect(esp_mqtt_client_handle_t client) // mqttSubscribeTo(mqttGroupTopic + subtopic); // mqttSubscribeTo(mqttNodeTopic + subtopic); -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 String subtopic = F(MQTT_TOPIC_CUSTOM "/#"); mqttSubscribeTo(mqttGroupCommandTopic + subtopic); mqttSubscribeTo(mqttNodeCommandTopic + subtopic); diff --git a/src/mqtt/hasp_mqtt_paho_async.cpp b/src/mqtt/hasp_mqtt_paho_async.cpp index a75bb699a..176d6bc46 100644 --- a/src/mqtt/hasp_mqtt_paho_async.cpp +++ b/src/mqtt/hasp_mqtt_paho_async.cpp @@ -328,7 +328,7 @@ static void onConnect(void* context, MQTTAsync_successData* response) topic = mqttNodeTopic + "config/#"; mqtt_subscribe(mqtt_client, topic.c_str()); -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 topic = mqttGroupTopic + MQTT_TOPIC_CUSTOM "/#"; mqtt_subscribe(mqtt_client, topic.c_str()); diff --git a/src/mqtt/hasp_mqtt_paho_single.cpp b/src/mqtt/hasp_mqtt_paho_single.cpp index 2d1565b33..010320d7d 100644 --- a/src/mqtt/hasp_mqtt_paho_single.cpp +++ b/src/mqtt/hasp_mqtt_paho_single.cpp @@ -269,7 +269,7 @@ static void onConnect(void* context) topic = mqttNodeTopic + "config/#"; mqtt_subscribe(mqtt_client, topic.c_str()); -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 topic = mqttGroupTopic + MQTT_TOPIC_CUSTOM "/#"; mqtt_subscribe(mqtt_client, topic.c_str()); diff --git a/src/mqtt/hasp_mqtt_pubsubclient.cpp b/src/mqtt/hasp_mqtt_pubsubclient.cpp index 84e2a2b59..e72e468fc 100644 --- a/src/mqtt/hasp_mqtt_pubsubclient.cpp +++ b/src/mqtt/hasp_mqtt_pubsubclient.cpp @@ -311,7 +311,7 @@ void mqttStart() snprintf_P(topic, sizeof(topic), PSTR("%s" MQTT_TOPIC_CONFIG "/#"), mqttNodeTopic); mqttSubscribeTo(topic); -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 snprintf_P(topic, sizeof(topic), PSTR("%s" MQTT_TOPIC_CUSTOM "/#"), mqttGroupTopic); mqttSubscribeTo(topic); snprintf_P(topic, sizeof(topic), PSTR("%s" MQTT_TOPIC_CUSTOM "/#"), mqttNodeTopic); diff --git a/src/sys/gpio/hasp_gpio.cpp b/src/sys/gpio/hasp_gpio.cpp index 52b60a966..ec083dcd0 100644 --- a/src/sys/gpio/hasp_gpio.cpp +++ b/src/sys/gpio/hasp_gpio.cpp @@ -776,7 +776,7 @@ bool gpioIsSystemPin(uint8_t gpio) return true; } -#if defined(HASP_USE_CUSTOM) +#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 if(custom_pin_in_use(gpio)) { LOG_DEBUG(TAG_GPIO, F(D_BULLET D_GPIO_PIN " %d => Custom"), gpio); return true; From c89d10dd902907b4d2ee2965dd41728696d22792 Mon Sep 17 00:00:00 2001 From: Lincoln Lavoie Date: Thu, 5 Dec 2024 23:08:22 -0500 Subject: [PATCH 4/5] Updated settings for the Lanbon L9 * Fixed the TFT driver, bad reference to gfx object. * Added setting for GFX parallel driver speed. * Corrected touch drive to FT6336. --- src/drv/tft/tft_driver_arduinogfx.cpp | 6 +++--- user_setups/esp32s3/lanbon_l9.ini | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/drv/tft/tft_driver_arduinogfx.cpp b/src/drv/tft/tft_driver_arduinogfx.cpp index 8826cef85..71a52a969 100644 --- a/src/drv/tft/tft_driver_arduinogfx.cpp +++ b/src/drv/tft/tft_driver_arduinogfx.cpp @@ -26,10 +26,10 @@ void ArduinoGfx::init(int w, int h) LOG_TRACE(TAG_TFT, F(D_SERVICE_STARTING)); #if(TFT_WIDTH == 170) && (TFT_HEIGHT == 320) - Arduino_DataBus *bus = new Arduino_ESP32PAR8Q( + Arduino_DataBus *bus = new Arduino_ESP32LCD8( TFT_DC, TFT_CS, TFT_WR, TFT_RD, TFT_D0, TFT_D1, TFT_D2, TFT_D3, TFT_D4, TFT_D5, TFT_D6, TFT_D7); - Arduino_GFX *gfx = new Arduino_ST7789(bus, + tft = new Arduino_ST7789(bus, TFT_RST /* RST */, TFT_ROTATION /* rotation */, true /* IPS */, TFT_WIDTH /* width */, TFT_HEIGHT /* height */, 35 /* col offset 1 */, 0 /* row offset 1 */, @@ -142,7 +142,7 @@ void ArduinoGfx::init(int w, int h) /* TFT init */ LOG_DEBUG(TAG_TFT, F("%s - %d"), __FILE__, __LINE__); - tft->begin(GFX_NOT_DEFINED); + tft->begin(SPI_FREQUENCY); LOG_DEBUG(TAG_TFT, F("%s - %d"), __FILE__, __LINE__); // tft.setSwapBytes(true); /* set endianness */ LOG_INFO(TAG_TFT, F(D_SERVICE_STARTED)); diff --git a/user_setups/esp32s3/lanbon_l9.ini b/user_setups/esp32s3/lanbon_l9.ini index 9dfb06161..216dfcf8c 100644 --- a/user_setups/esp32s3/lanbon_l9.ini +++ b/user_setups/esp32s3/lanbon_l9.ini @@ -26,6 +26,7 @@ build_flags = ;-D TFT_INVERSION_ON ;-D TFT_RGB_ORDER=0 ; Colour order Blue-Green-Red ;-D INVERT_COLORS=1 ; for inverted colors + -D SPI_FREQUENCY=16000000 -D TFT_RST=-1 -D TFT_CS=21 @@ -44,13 +45,13 @@ build_flags = ; Touch Setttings -D TOUCH_WIDTH=170 -D TOUCH_HEIGHT=320 - -D TOUCH_DRIVER=0x911 + -D TOUCH_DRIVER=0x6336 -D TOUCH_SCL=0 -D TOUCH_SDA=35 -D TOUCH_IRQ=-1 -D TOUCH_RST=-1 - -D I2C_TOUCH_ADDRESS=0x5d ; or 0x14 - -D I2C_TOUCH_FREQUENCY=400000 + -D I2C_TOUCH_ADDRESS=0x38 + -D I2C_TOUCH_FREQUENCY=100000 ;endregion ;region -- Library options ------------------------------- From 113b6838f2c3c6fa49babf03a3536ec1e5c698cb Mon Sep 17 00:00:00 2001 From: Lincoln Lavoie Date: Fri, 6 Dec 2024 16:01:00 -0500 Subject: [PATCH 5/5] Working setup for Lanbon L9 * Changed to Arduino_ESP32PAR8 bus driver. * Fixed touch driver options, added missing port settings. * Increased frequency of i2c to 400kHz. --- src/drv/tft/tft_driver_arduinogfx.cpp | 2 +- user_setups/esp32s3/lanbon_l9.ini | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/drv/tft/tft_driver_arduinogfx.cpp b/src/drv/tft/tft_driver_arduinogfx.cpp index 71a52a969..2e377c39b 100644 --- a/src/drv/tft/tft_driver_arduinogfx.cpp +++ b/src/drv/tft/tft_driver_arduinogfx.cpp @@ -26,7 +26,7 @@ void ArduinoGfx::init(int w, int h) LOG_TRACE(TAG_TFT, F(D_SERVICE_STARTING)); #if(TFT_WIDTH == 170) && (TFT_HEIGHT == 320) - Arduino_DataBus *bus = new Arduino_ESP32LCD8( + Arduino_DataBus *bus = new Arduino_ESP32PAR8( TFT_DC, TFT_CS, TFT_WR, TFT_RD, TFT_D0, TFT_D1, TFT_D2, TFT_D3, TFT_D4, TFT_D5, TFT_D6, TFT_D7); tft = new Arduino_ST7789(bus, diff --git a/user_setups/esp32s3/lanbon_l9.ini b/user_setups/esp32s3/lanbon_l9.ini index 216dfcf8c..b4ead53aa 100644 --- a/user_setups/esp32s3/lanbon_l9.ini +++ b/user_setups/esp32s3/lanbon_l9.ini @@ -51,7 +51,8 @@ build_flags = -D TOUCH_IRQ=-1 -D TOUCH_RST=-1 -D I2C_TOUCH_ADDRESS=0x38 - -D I2C_TOUCH_FREQUENCY=100000 + -D I2C_TOUCH_PORT=1 + -D I2C_TOUCH_FREQUENCY=400000 ;endregion ;region -- Library options ------------------------------- @@ -61,6 +62,7 @@ lib_deps = ${arduino_esp32s3_v2.lib_deps} ${arduinogfx.lib_deps} ${goodix.lib_deps} + ${ft6336.lib_deps} lib_ignore = ${env.lib_ignore}