From 1466dde60fab5e81dc9a47abdf6d29406badf347 Mon Sep 17 00:00:00 2001 From: spiff72 Date: Tue, 24 Dec 2024 00:19:35 -0500 Subject: [PATCH 1/5] Updated to fix compilation errors, adapt to some of the new WLED details, and force an older version of dependent library TFT_eSPI. --- usermods/TTGO-T-Display/README.md | 38 ++++---------- .../TTGO-T-Display/platformio_override.ini | 51 +++++++++++++++++-- usermods/TTGO-T-Display/usermod.cpp | 51 ++++++++++++------- 3 files changed, 89 insertions(+), 51 deletions(-) diff --git a/usermods/TTGO-T-Display/README.md b/usermods/TTGO-T-Display/README.md index 439f9832dd..d999748879 100644 --- a/usermods/TTGO-T-Display/README.md +++ b/usermods/TTGO-T-Display/README.md @@ -15,6 +15,8 @@ I have designed a 3D printed case around this board and an ["ElectroCookie"](htt Based on a rework of the ssd1306_i2c_oled_u8g2 usermod from the WLED repo. +In December 2024, I made some changes to fix compilation errors, and modified the platformio_override.ini file to include ALL changes needed (no more need to edit the origiginal "stock" platformio.ini file). I am also forcing an older version of the TFT_eSPI library. + ## Hardware ![Hardware](assets/ttgo_hardware1.png) ![Hardware](assets/ttgo-tdisplay-enclosure1a.png) @@ -37,38 +39,18 @@ Functionality checked with: * As with all usermods, copy the usermod.cpp file from the TTGO-T-Display usermod folder to the wled00 folder (replacing the default usermod.cpp file). ## Platformio Requirements -### Platformio.ini changes -Under the root folder of the project, in the `platformio.ini` file, uncomment the `TFT_eSPI` line within the [common] section, under `lib_deps`: -```ini -# platformio.ini -... -[common] -... -lib_deps = - ... - #For use of the TTGO T-Display ESP32 Module with integrated TFT display uncomment the following line - #TFT_eSPI -... -``` -In the `platformio.ini` file, you must change the environment setup to build for just the esp32dev platform as follows: +### Platformio_override.ini (added) +Copy the `platformio_override.ini` file which is contained in the `usermods/TTGO-T-Display/` folder into the root of your project folder. This file contains an override that remaps the button pin of WLED to use the on-board button to the right of the USB-C connector (when viewed with the port oriented downward - see hardware photo). -Comment out the line described below: -```ini -# Release binaries -; default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, esp32dev, esp32_eth, esp32s2_saola, esp32c3 -``` -and uncomment the following line in the 'Single binaries' section: -```ini -default_envs = esp32dev -``` -Save the `platformio.ini` file. Once saved, the required library files should be automatically downloaded for modifications in a later step. +### Platformio.ini changes +This file isn't actually changed, but it is helpful to save the file in the VS Code application. This should trigger the download of the library dependencies. -### Platformio_overrides.ini (added) -Copy the `platformio_overrides.ini` file which is contained in the `usermods/TTGO-T-Display/` folder into the root of your project folder. This file contains an override that remaps the button pin of WLED to use the on-board button to the right of the USB-C connector (when viewed with the port oriented downward - see hardware photo). +### Change to the WLED_T-Display environment +This should appear as an option in the bottom toolbar. ### TFT_eSPI Library Adjustments (board selection) -You need to modify a file in the `TFT_eSPI` library to select the correct board. If you followed the directions to modify and save the `platformio.ini` file above, the `User_Setup_Select.h` file can be found in the `/.pio/libdeps/esp32dev/TFT_eSPI_ID1559` folder. +You need to modify a file in the `TFT_eSPI` library to select the correct board. If you followed the directions to modify and save the `platformio.ini` file above, the `User_Setup_Select.h` file can be found in the `/.pio/libdeps/WLED_T-Display/TFT_eSPI` folder. Modify the `User_Setup_Select.h` file as follows: * Comment out the following line (which is the 'default' setup file): @@ -87,5 +69,7 @@ xtensa-esp32-elf-g++: fatal error: no input files ``` try building again. Sometimes this happens on the first build attempt and subsequent attempts build correctly. +Once the compilation is done and loaded onto the TTGO T-Display module, you may need to complete the initial setup of WLED via the AP interface, configure the WiFi settings, let it restart and then go to the LED preferences option in the WLED web interface. The Data GPIO pin needs to be set to pin 2 (or whatever pin you used), and then reboot WLED on the device. This should get the display working. I am unable to get the overrides to change the initial pin setting of 16 (which conflicts with the display). + ## Arduino IDE - UNTESTED diff --git a/usermods/TTGO-T-Display/platformio_override.ini b/usermods/TTGO-T-Display/platformio_override.ini index 7e42d9a54a..5142875336 100644 --- a/usermods/TTGO-T-Display/platformio_override.ini +++ b/usermods/TTGO-T-Display/platformio_override.ini @@ -1,8 +1,49 @@ -[env:esp32dev] -build_flags = ${common.build_flags_esp32} -; PIN defines - uncomment and change, if needed: -; -D LEDPIN=2 - -D BTNPIN=35 +# Example PlatformIO Project Configuration Override +# ------------------------------------------------------------------------------ +# Copy to platformio_override.ini to activate overrides +# ------------------------------------------------------------------------------ +# Please visit documentation: https://docs.platformio.org/page/projectconf.html + +[platformio] +#default_envs = WLED_tasmota_1M # define as many as you need +default_envs = WLED_T-Display # define as many as you need +#---------- +# SAMPLE +#---------- +[env:WLED_T-Display] + +board = esp32dev +upload_speed = 921600 +monitor_speed = 115200 +platform = ${esp32.platform} +platform_packages = ${esp32.platform_packages} +build_unflags = ${common.build_unflags} +build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\"ESP32\" + ${esp32.AR_build_flags} ; -D IRPIN=4 ; -D RLYPIN=12 ; -D RLYMDE=1 +; -D WLED_DISABLE_BROWNOUT_DET +;PIN defines - uncomment and change, if needed: + -D DATA_PINS=2 +;or use this for multiple outputs + ;-D DATA_PINS=1,3 + -D BTNPIN=35 +; -D IRPIN=4 +; -D RLYPIN=12 +; -D RLYMDE=1 +; -D RLYODRAIN=0 +; -D LED_BUILTIN=2 # GPIO of built-in LED +lib_deps = ${esp32.lib_deps} + #For use of the TTGO T-Display ESP32 Module with integrated TFT display uncomment the following line + TFT_eSPI @ 2.5.33 + ;https://github.com/Bodmer/TFT_eSPI/archive/refs/tags/2.1.4.zip + ;https://github.com/Bodmer/TFT_eSPI/archive/refs/tags/2.1.9.zip + kosme/arduinoFFT @ 2.0.1 +monitor_filters = esp32_exception_decoder +board_build.partitions = ${esp32.default_partitions} + +; # additional build flags for audioreactive +; AR_build_flags = -D USERMOD_AUDIOREACTIVE +; -D sqrt_internal=sqrtf ;; -fsingle-precision-constant ;; forces ArduinoFFT to use float math (2x faster) +; AR_lib_deps = kosme/arduinoFFT @ 2.0.1 diff --git a/usermods/TTGO-T-Display/usermod.cpp b/usermods/TTGO-T-Display/usermod.cpp index cbba07771d..5916a3da97 100644 --- a/usermods/TTGO-T-Display/usermod.cpp +++ b/usermods/TTGO-T-Display/usermod.cpp @@ -21,27 +21,28 @@ //Use userVar0 and userVar1 (API calls &U0=,&U1=, uint16_t) #include "wled.h" -#include #include +#include #include "WiFi.h" #include -#ifndef TFT_DISPOFF -#define TFT_DISPOFF 0x28 -#endif +// #ifndef TFT_DISPOFF +// #define TFT_DISPOFF 0x28 +// #endif -#ifndef TFT_SLPIN -#define TFT_SLPIN 0x10 -#endif +// #ifndef TFT_SLPIN +// #define TFT_SLPIN 0x10 +// #endif -#define TFT_MOSI 19 -#define TFT_SCLK 18 -#define TFT_CS 5 -#define TFT_DC 16 -#define TFT_RST 23 +// #define TFT_MOSI 19 +// #define TFT_SCLK 18 +// #define TFT_CS 5 +// #define TFT_DC 16 +// #define TFT_RST 23 -#define TFT_BL 4 // Display backlight control pin -#define ADC_EN 14 // Used for enabling battery voltage measurements - not used in this program +//#define TFT_BL 4 // Display backlight control pin +//#define ADC_EN 14 // Used for enabling battery voltage measurements - not used in this program +//#define WLED_WATCHDOG_TIMEOUT 3 TFT_eSPI tft = TFT_eSPI(135, 240); // Invoke custom library @@ -53,11 +54,14 @@ void userSetup() { tft.setRotation(3); //Rotation here is set up for the text to be readable with the port on the left. Use 1 to flip. tft.fillScreen(TFT_BLACK); tft.setTextSize(2); + //tft.setTextSize(1); tft.setTextColor(TFT_WHITE); tft.setCursor(1, 10); tft.setTextDatum(MC_DATUM); tft.setTextSize(3); + //tft.setTextSize(1); tft.print("Loading..."); + Serial.println("Loading..."); if (TFT_BL > 0) { // TFT_BL has been set in the TFT_eSPI library in the User Setup file TTGO_T_Display.h pinMode(TFT_BL, OUTPUT); // Set backlight pin to output mode @@ -83,7 +87,7 @@ uint8_t knownMode = 0; uint8_t knownPalette = 0; uint8_t tftcharwidth = 19; // Number of chars that fit on screen with text size set to 2 -long lastUpdate = 0; +long lastUpdate_mod = 0; long lastRedraw = 0; bool displayTurnedOff = false; // How often we are redrawing screen @@ -92,10 +96,10 @@ bool displayTurnedOff = false; void userLoop() { // Check if we time interval for redrawing passes. - if (millis() - lastUpdate < USER_LOOP_REFRESH_RATE_MS) { + if (millis() - lastUpdate_mod < USER_LOOP_REFRESH_RATE_MS) { return; } - lastUpdate = millis(); + lastUpdate_mod = millis(); // Turn off display after 5 minutes with no change. if(!displayTurnedOff && millis() - lastRedraw > 5*60*1000) { @@ -140,6 +144,7 @@ void userLoop() { knownPalette = strip.getMainSegment().palette; tft.fillScreen(TFT_BLACK); + //tft.setTextColor(TFT_WHITE); tft.setTextSize(2); // First row with Wifi name tft.setCursor(1, 1); @@ -156,7 +161,7 @@ void userLoop() { // tft.print(apPass); // else // tft.print(knownIp); - + Serial.println("Print known AP"); if (apActive) { tft.print("AP IP: "); tft.print(knownIp); @@ -165,6 +170,7 @@ void userLoop() { tft.print(apPass); } else { + Serial.println("Print IP"); tft.print("IP: "); tft.print(knownIp); tft.setCursor(1,46); @@ -180,16 +186,23 @@ void userLoop() { char lineBuffer[tftcharwidth+1]; extractModeName(knownMode, JSON_mode_names, lineBuffer, tftcharwidth); tft.print(lineBuffer); + Serial.println("Print mode name"); // Fourth row with palette name tft.setCursor(1, 90); extractModeName(knownPalette, JSON_palette_names, lineBuffer, tftcharwidth); tft.print(lineBuffer); + Serial.println("Print palette"); // Fifth row with estimated mA usage tft.setCursor(1, 112); // Print estimated milliamp usage (must specify the LED type in LED prefs for this to be a reasonable estimate). - tft.print(strip.currentMilliamps); + //tft.print(strip.currentMilliamps); + tft.print(BusManager::currentMilliamps()); + Serial.print(BusManager::currentMilliamps()); + Serial.println(" mA (estimated)"); + //tft.print("test "); tft.print("mA (estimated)"); + Serial.println("Print estimated current"); } From 79f3ef97b7da75f42603389a237a2b93b2e89133 Mon Sep 17 00:00:00 2001 From: spiff72 Date: Tue, 24 Dec 2024 01:22:51 -0500 Subject: [PATCH 2/5] fixed forced version number of TFT_eSPI in platformio_override.ini --- usermods/TTGO-T-Display/platformio_override.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usermods/TTGO-T-Display/platformio_override.ini b/usermods/TTGO-T-Display/platformio_override.ini index 5142875336..2a9f62d5e6 100644 --- a/usermods/TTGO-T-Display/platformio_override.ini +++ b/usermods/TTGO-T-Display/platformio_override.ini @@ -36,8 +36,8 @@ build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\" ; -D LED_BUILTIN=2 # GPIO of built-in LED lib_deps = ${esp32.lib_deps} #For use of the TTGO T-Display ESP32 Module with integrated TFT display uncomment the following line - TFT_eSPI @ 2.5.33 - ;https://github.com/Bodmer/TFT_eSPI/archive/refs/tags/2.1.4.zip + ;TFT_eSPI @ 2.5.33 + https://github.com/Bodmer/TFT_eSPI/archive/refs/tags/2.1.4.zip ;https://github.com/Bodmer/TFT_eSPI/archive/refs/tags/2.1.9.zip kosme/arduinoFFT @ 2.0.1 monitor_filters = esp32_exception_decoder From 2646165dab81697a4b02c578f81af0793fe42315 Mon Sep 17 00:00:00 2001 From: spiff72 Date: Tue, 24 Dec 2024 13:04:38 -0500 Subject: [PATCH 3/5] Update platformio_override.ini Revised WLED_RELEASE_NAME to "WLED_T-Display" --- usermods/TTGO-T-Display/platformio_override.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usermods/TTGO-T-Display/platformio_override.ini b/usermods/TTGO-T-Display/platformio_override.ini index 2a9f62d5e6..6db9f276fa 100644 --- a/usermods/TTGO-T-Display/platformio_override.ini +++ b/usermods/TTGO-T-Display/platformio_override.ini @@ -18,7 +18,7 @@ monitor_speed = 115200 platform = ${esp32.platform} platform_packages = ${esp32.platform_packages} build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\"ESP32\" +build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\"WLED_T-Display\" ${esp32.AR_build_flags} ; -D IRPIN=4 ; -D RLYPIN=12 From 3325b0b50d007da69da9b589a42e9b7e5d346b1f Mon Sep 17 00:00:00 2001 From: spiff72 Date: Sat, 4 Jan 2025 22:29:18 -0500 Subject: [PATCH 4/5] adjustments based on feedback --- .../TTGO-T-Display/platformio_override.ini | 25 ++++++++++++------- usermods/TTGO-T-Display/usermod.cpp | 18 ++++++------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/usermods/TTGO-T-Display/platformio_override.ini b/usermods/TTGO-T-Display/platformio_override.ini index 6db9f276fa..8b1b28ee2f 100644 --- a/usermods/TTGO-T-Display/platformio_override.ini +++ b/usermods/TTGO-T-Display/platformio_override.ini @@ -23,17 +23,17 @@ build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\" ; -D IRPIN=4 ; -D RLYPIN=12 ; -D RLYMDE=1 -; -D WLED_DISABLE_BROWNOUT_DET +; -D WLED_DISABLE_BROWNOUT_DET ;PIN defines - uncomment and change, if needed: -D DATA_PINS=2 ;or use this for multiple outputs - ;-D DATA_PINS=1,3 +; -D DATA_PINS=1,3 -D BTNPIN=35 -; -D IRPIN=4 -; -D RLYPIN=12 -; -D RLYMDE=1 -; -D RLYODRAIN=0 -; -D LED_BUILTIN=2 # GPIO of built-in LED +; -D IRPIN=4 +; -D RLYPIN=12 +; -D RLYMDE=1 +; -D RLYODRAIN=0 +; -D LED_BUILTIN=2 # GPIO of built-in LED lib_deps = ${esp32.lib_deps} #For use of the TTGO T-Display ESP32 Module with integrated TFT display uncomment the following line ;TFT_eSPI @ 2.5.33 @@ -44,6 +44,13 @@ monitor_filters = esp32_exception_decoder board_build.partitions = ${esp32.default_partitions} ; # additional build flags for audioreactive -; AR_build_flags = -D USERMOD_AUDIOREACTIVE -; -D sqrt_internal=sqrtf ;; -fsingle-precision-constant ;; forces ArduinoFFT to use float math (2x faster) +; Use Audioreactive usermod and configure I2S microphone +; ${esp32.AR_build_flags} ;; default flags required to properly configure ArduinoFFT +; ;; don't forget to add ArduinoFFT to your libs_deps: ${esp32.AR_lib_deps} +; -D AUDIOPIN=-1 +; -D DMTYPE=1 # 0-analog/disabled, 1-I2S generic, 2-ES7243, 3-SPH0645, 4-I2S+mclk, 5-I2S PDM +; -D I2S_SDPIN=36 +; -D I2S_WSPIN=23 +; -D I2S_CKPIN=19 +; ${esp32.AR_lib_deps} ;; needed for USERMOD_AUDIOREACTIVE ; AR_lib_deps = kosme/arduinoFFT @ 2.0.1 diff --git a/usermods/TTGO-T-Display/usermod.cpp b/usermods/TTGO-T-Display/usermod.cpp index 5916a3da97..ed06b4e987 100644 --- a/usermods/TTGO-T-Display/usermod.cpp +++ b/usermods/TTGO-T-Display/usermod.cpp @@ -49,7 +49,7 @@ TFT_eSPI tft = TFT_eSPI(135, 240); // Invoke custom library //gets called once at boot. Do all initialization that doesn't depend on network here void userSetup() { Serial.begin(115200); - Serial.println("Start"); + DEBUG_PRINTLN("Start"); tft.init(); tft.setRotation(3); //Rotation here is set up for the text to be readable with the port on the left. Use 1 to flip. tft.fillScreen(TFT_BLACK); @@ -61,7 +61,7 @@ void userSetup() { tft.setTextSize(3); //tft.setTextSize(1); tft.print("Loading..."); - Serial.println("Loading..."); + DEBUG_PRINTLN("Loading..."); if (TFT_BL > 0) { // TFT_BL has been set in the TFT_eSPI library in the User Setup file TTGO_T_Display.h pinMode(TFT_BL, OUTPUT); // Set backlight pin to output mode @@ -161,7 +161,7 @@ void userLoop() { // tft.print(apPass); // else // tft.print(knownIp); - Serial.println("Print known AP"); + DEBUG_PRINTLN("Print known AP"); if (apActive) { tft.print("AP IP: "); tft.print(knownIp); @@ -170,7 +170,7 @@ void userLoop() { tft.print(apPass); } else { - Serial.println("Print IP"); + DEBUG_PRINTLN("Print IP"); tft.print("IP: "); tft.print(knownIp); tft.setCursor(1,46); @@ -186,23 +186,23 @@ void userLoop() { char lineBuffer[tftcharwidth+1]; extractModeName(knownMode, JSON_mode_names, lineBuffer, tftcharwidth); tft.print(lineBuffer); - Serial.println("Print mode name"); + DEBUG_PRINTLN("Print mode name"); // Fourth row with palette name tft.setCursor(1, 90); extractModeName(knownPalette, JSON_palette_names, lineBuffer, tftcharwidth); tft.print(lineBuffer); - Serial.println("Print palette"); + DEBUG_PRINTLN("Print palette"); // Fifth row with estimated mA usage tft.setCursor(1, 112); // Print estimated milliamp usage (must specify the LED type in LED prefs for this to be a reasonable estimate). //tft.print(strip.currentMilliamps); tft.print(BusManager::currentMilliamps()); - Serial.print(BusManager::currentMilliamps()); - Serial.println(" mA (estimated)"); + DEBUG_PRINTLN(BusManager::currentMilliamps()); + DEBUG_PRINTLN(" mA (estimated)"); //tft.print("test "); tft.print("mA (estimated)"); - Serial.println("Print estimated current"); + DEBUG_PRINTLN("Print estimated current"); } From 98215f5640f888146701f889d15903f6f9f4e57a Mon Sep 17 00:00:00 2001 From: spiff72 Date: Sun, 5 Jan 2025 00:33:45 -0500 Subject: [PATCH 5/5] Updated readme file and tweaked indents on the platformio_override.ini file. --- usermods/TTGO-T-Display/README.md | 4 ++-- usermods/TTGO-T-Display/platformio_override.ini | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/usermods/TTGO-T-Display/README.md b/usermods/TTGO-T-Display/README.md index d999748879..84aed5eabd 100644 --- a/usermods/TTGO-T-Display/README.md +++ b/usermods/TTGO-T-Display/README.md @@ -44,7 +44,7 @@ Functionality checked with: Copy the `platformio_override.ini` file which is contained in the `usermods/TTGO-T-Display/` folder into the root of your project folder. This file contains an override that remaps the button pin of WLED to use the on-board button to the right of the USB-C connector (when viewed with the port oriented downward - see hardware photo). ### Platformio.ini changes -This file isn't actually changed, but it is helpful to save the file in the VS Code application. This should trigger the download of the library dependencies. +Once the platformio_override.ini file has been copied as described above, the platformio.ini file isn't actually changed, but it is helpful to save the platformio.ini file in the VS Code application. This should trigger the download of the library dependencies. ### Change to the WLED_T-Display environment This should appear as an option in the bottom toolbar. @@ -69,7 +69,7 @@ xtensa-esp32-elf-g++: fatal error: no input files ``` try building again. Sometimes this happens on the first build attempt and subsequent attempts build correctly. -Once the compilation is done and loaded onto the TTGO T-Display module, you may need to complete the initial setup of WLED via the AP interface, configure the WiFi settings, let it restart and then go to the LED preferences option in the WLED web interface. The Data GPIO pin needs to be set to pin 2 (or whatever pin you used), and then reboot WLED on the device. This should get the display working. I am unable to get the overrides to change the initial pin setting of 16 (which conflicts with the display). +Once the compilation is done and loaded onto the TTGO T-Display module, the display should show "Loading...", and then it will show the IP of the WLED access point. ## Arduino IDE - UNTESTED diff --git a/usermods/TTGO-T-Display/platformio_override.ini b/usermods/TTGO-T-Display/platformio_override.ini index 8b1b28ee2f..9f2597cb7b 100644 --- a/usermods/TTGO-T-Display/platformio_override.ini +++ b/usermods/TTGO-T-Display/platformio_override.ini @@ -27,7 +27,7 @@ build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\" ;PIN defines - uncomment and change, if needed: -D DATA_PINS=2 ;or use this for multiple outputs -; -D DATA_PINS=1,3 +; -D DATA_PINS=1,3 -D BTNPIN=35 ; -D IRPIN=4 ; -D RLYPIN=12