From 544446d35eed493ae5b9a99cd85a04059e14dd97 Mon Sep 17 00:00:00 2001 From: Ewoud Date: Sun, 8 Jan 2023 13:51:27 +0100 Subject: [PATCH] Further pin improvements platformio - create _all entries (wip) - set FLD_PIN_SCL to -1 (use global) 4ld - one bug fix and errorMessage improvements const.h - comments wled.h - do not use the I2CSDAPIN vars but HW_PIN_SDA instead --- platformio.ini | 70 +++++++++++++++++-- .../usermod_v2_four_line_display_ALT.h | 6 +- wled00/cfg.cpp | 4 +- wled00/const.h | 12 ++-- wled00/set.cpp | 4 +- wled00/wled.h | 22 +++--- 6 files changed, 87 insertions(+), 31 deletions(-) diff --git a/platformio.ini b/platformio.ini index ead68d13..b5a47920 100644 --- a/platformio.ini +++ b/platformio.ini @@ -42,7 +42,9 @@ default_envs = esp32_4MB_min esp32_4MB_max ; recommended default + ; esp32_4MB_all esp32_16MB_max + ; esp32_16MB_all esp8266_4MB_min esp32_4MB_PSRAM_max esp32S3_8MB_max @@ -53,6 +55,7 @@ default_envs = wemos_shield_esp32_16MB_max wemos_shield_esp32_16MB_ICS4343x_max wemos_shield_esp32_16MB_SPM1423_max + ; wemos_shield_esp32_16MB_SPM1423_all wemos_shield_esp32_16MB_LineIn_max esp32_pico_4MB_max esp32s2_tinyUF2_PSRAM_max @@ -620,10 +623,9 @@ build_flags_min = lib_deps_min = https://github.com/kosme/arduinoFFT#develop @ 1.9.2 ; used for USERMOD_AUDIOREACTIVE -; monitor_filters = esp32_exception_decoder ; used to show crash details build_flags_max = - -D WLED_MAX_USERMODS=14 ; default only 4-6 + ; -D WLED_MAX_USERMODS=14 ; default only 4-6 ;; -D ARDUINO_USB_CDC_ON_BOOT=0 ; needed for arduino-esp32 >=2.0.4 ewowi to softhack: move to build_flags_min? - We need a different solution -D WLED_USE_MY_CONFIG ; include custom my_config.h ewowi to softhack: redundant as also in build_flags_min? -D USERMOD_DALLASTEMPERATURE @@ -652,13 +654,15 @@ lib_deps_V4_max = claws/BH1750 @^1.2.0 ; used for USERMOD_BH1750 build_flags_all = + -D WLED_MAX_USERMODS=16 ; default only 4-6 -D USERMOD_RTC ;; experimental - -D USERMOD_SENSORSTOMQTT ;; experimental + ; -D USERMOD_SENSORSTOMQTT ;; experimental + -D USERMOD_ANALOG_CLOCK lib_deps_all = - adafruit/Adafruit BMP280 Library @ 2.1.0 ;; experimental for usermod USERMOD_SENSORSTOMQTT - adafruit/Adafruit CCS811 Library @ 1.0.4 ;; experimental for usermod USERMOD_SENSORSTOMQTT - adafruit/Adafruit Si7021 Library @ 1.4.0 ;; experimental for usermod USERMOD_SENSORSTOMQTT + ; adafruit/Adafruit BMP280 Library @ 2.1.0 ;; experimental for usermod USERMOD_SENSORSTOMQTT + ; adafruit/Adafruit CCS811 Library @ 1.0.4 ;; experimental for usermod USERMOD_SENSORSTOMQTT + ; adafruit/Adafruit Si7021 Library @ 1.4.0 ;; experimental for usermod USERMOD_SENSORSTOMQTT ; end of common @@ -676,6 +680,7 @@ lib_deps = ${esp32.lib_deps} ${common_mm.lib_deps_min} board_build.partitions = ${esp32.default_partitions} board_build.f_flash = 80000000L ; use full 80MHz speed for flash (default = 40Mhz) board_build.flash_mode = dio ; (dio = dual i/o; more compatible than qio = quad i/o) +monitor_filters = esp32_exception_decoder ; used to show crash details ;common default for all max environments [esp32_4MB_max_base] @@ -685,6 +690,13 @@ lib_deps = ${esp32_4MB_min_base.lib_deps} ${common_mm.lib_deps_max} board_build.partitions = ${esp32_4MB_min_base.board_build.partitions} ; board_build.partitions = tools/WLED_ESP32-wrover_4MB.csv +[esp32_4MB_all_base] +extends = esp32_4MB_min_base +build_flags = ${esp32_4MB_min_base.build_flags} ${common_mm.build_flags_max} ${common_mm.build_flags_all} +lib_deps = ${esp32_4MB_min_base.lib_deps} ${common_mm.lib_deps_max} ${common_mm.lib_deps_all} +board_build.partitions = ${esp32_4MB_min_base.board_build.partitions} +; board_build.partitions = tools/WLED_ESP32-wrover_4MB.csv + ;common default for all V4 min environments [esp32_4MB_V4_min_base] board = esp32dev @@ -699,6 +711,7 @@ board_build.partitions = ${esp32.default_partitions} board_build.f_flash = 80000000L ; use full 80MHz speed for flash (default = 40Mhz) board_build.flash_mode = dio ; (dio = dual i/o; more compatible than qio = quad i/o) ;lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation +; monitor_filters = esp32_exception_decoder ; used to show crash details [esp32_4MB_V4_max_base] extends = esp32_4MB_V4_min_base @@ -746,6 +759,13 @@ build_flags = ${esp32_4MB_max_base.build_flags} ; RAM: [== ] 24.4% (used 79804 bytes from 327680 bytes) ; Flash: [========= ] 88.7% (used 1394813 bytes from 1572864 bytes) +[env:esp32_4MB_all] +extends = esp32_4MB_all_base +build_flags = ${esp32_4MB_all_base.build_flags} + -D WLED_RELEASE_NAME=esp32_4MB_all + ; RAM: [== ] 24.4% (used 79804 bytes from 327680 bytes) + ; Flash: [========= ] 88.7% (used 1394813 bytes from 1572864 bytes) + [env:esp32_16MB_max] extends = esp32_4MB_max_base build_flags = ${esp32_4MB_max_base.build_flags} @@ -756,6 +776,16 @@ board_build.partitions = ${Board_ESP32_16MB.board_build.partitions} ; Flash: [======= ] 67.0% (used 1405701 bytes from 2097152 bytes) ;lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation +[env:esp32_16MB_all] +extends = esp32_4MB_all_base +build_flags = ${esp32_4MB_all_base.build_flags} + -D WLED_RELEASE_NAME=esp32_16MB_all +board = ${Board_ESP32_16MB.board} +board_build.partitions = ${Board_ESP32_16MB.board_build.partitions} + ; RAM: [== ] 24.4% (used 79916 bytes from 327680 bytes) + ; Flash: [======= ] 67.0% (used 1405701 bytes from 2097152 bytes) +;lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation + [env:esp8266_4MB_min] extends = env:d1_mini upload_speed = 460800 ;115200 @@ -971,7 +1001,22 @@ build_flags = ${esp32_4MB_max_base.build_flags} -D IRPIN=18 -D AUDIOPIN=-1 -D TEMPERATURE_PIN=23 - -D FLD_PIN_SCL=22 -D FLD_PIN_SDA=21 + -D FLD_PIN_SCL=-1 -D FLD_PIN_SDA=-1 ; use global! + -D HW_PIN_SCL=22 -D HW_PIN_SDA=21 + -D ENCODER_DT_PIN=35 -D ENCODER_CLK_PIN=5 -D ENCODER_SW_PIN=39 ;WLEDMM spec by @SERG74: use 35 and 39 instead of 18 and 19 (conflicts) + ; -D WLED_USE_MY_CONFIG + +[wemos_shield_esp32_4MB_all_base] +extends = esp32_4MB_all_base +build_flags = ${esp32_4MB_all_base.build_flags} + -D ABL_MILLIAMPS_DEFAULT=9500 ; Wemos max 10A + -D LEDPIN=16 + -D RLYPIN=19 + -D BTNPIN=17 + -D IRPIN=18 + -D AUDIOPIN=-1 + -D TEMPERATURE_PIN=23 + -D FLD_PIN_SCL=-1 -D FLD_PIN_SDA=-1 ; use global! -D HW_PIN_SCL=22 -D HW_PIN_SDA=21 -D ENCODER_DT_PIN=35 -D ENCODER_CLK_PIN=5 -D ENCODER_SW_PIN=39 ;WLEDMM spec by @SERG74: use 35 and 39 instead of 18 and 19 (conflicts) ; -D WLED_USE_MY_CONFIG @@ -1028,6 +1073,17 @@ board = ${Board_ESP32_16MB.board} board_build.partitions = ${Board_ESP32_16MB.board_build.partitions} ; RAM: [== ] 24.4% (used 79820 bytes from 327680 bytes) ; Flash: [========= ] 88.6% (used 1393421 bytes from 1572864 bytes) +monitor_filters = esp32_exception_decoder ; used to show crash details + +[env:wemos_shield_esp32_16MB_SPM1423_all] +extends = wemos_shield_esp32_4MB_all_base +build_flags = ${wemos_shield_esp32_4MB_all_base.build_flags} ${Shield_SPM1423.build_flags} + -D WLED_RELEASE_NAME=wemos_shield_esp32_16MB_SPM1423_all +board = ${Board_ESP32_16MB.board} +board_build.partitions = ${Board_ESP32_16MB.board_build.partitions} +; RAM: [== ] 24.4% (used 79820 bytes from 327680 bytes) +; Flash: [========= ] 88.6% (used 1393421 bytes from 1572864 bytes) +monitor_filters = esp32_exception_decoder ; used to show crash details [env:wemos_shield_esp32_16MB_LineIn_max] extends = wemos_shield_esp32_4MB_max_base diff --git a/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h b/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h index ec03ff34..a3258c22 100644 --- a/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h +++ b/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h @@ -112,7 +112,7 @@ class FourLineDisplayUsermod : public Usermod { bool initDone = false; volatile bool drawing = false; - char errorMessage[100] = "No errors"; //WLEDMM: show error in um settings if occurred + char errorMessage[100] = ""; //WLEDMM: show error in um settings if occurred // HW interface & configuration U8X8 *u8x8 = nullptr; // pointer to U8X8 display object @@ -231,7 +231,7 @@ class FourLineDisplayUsermod : public Usermod { u8x8->draw2x2Glyph(col, row, glyph); } uint8_t getCols() { - if (type==NONE || !enabled) return 0; + if (!typeOK || !enabled) return 0; return u8x8->getCols(); } void clear() { @@ -1075,7 +1075,7 @@ class FourLineDisplayUsermod : public Usermod { //WLEDMM add errorMessage to um settings if (strcmp(errorMessage, "") != 0) { - oappend(SET_F("addInfo('errorMessage', 0, 'error: ")); oappend(SET_F(errorMessage)); oappend("!');"); + oappend(SET_F("addInfo('errorMessage', 0, 'error: ")); oappend(SET_F(errorMessage)); oappend("! Correct and reboot');"); } } diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 23f3dcea..33ce8392 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -311,7 +311,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { #endif Wire.begin(); } else { - Serial.printf("pinmgr not success i2c %d %d\n", i2c_sda, i2c_scl); + Serial.printf("pinmgr not success for global i2c %d %d\n", i2c_sda, i2c_scl); } JsonArray hw_if_spi = hw[F("if")][F("spi-pin")]; CJSON(spi_mosi, hw_if_spi[0]); @@ -325,7 +325,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { SPI.begin(); #endif } else { - Serial.printf("pinmgr not success spi %d %d %d\n", spi_mosi, spi_miso, spi_sclk); + Serial.printf("pinmgr not success for global spi %d %d %d\n", spi_mosi, spi_miso, spi_sclk); } //int hw_status_pin = hw[F("status")]["pin"]; // -1 diff --git a/wled00/const.h b/wled00/const.h index 60109438..10c7db24 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -433,10 +433,10 @@ #endif // defaults for 1st I2C on ESP32 (Wire global) #ifndef HW_PIN_SCL - #define HW_PIN_SCL SCL + #define HW_PIN_SCL SCL //WLEDMM to check if -1 is better #endif #ifndef HW_PIN_SDA - #define HW_PIN_SDA SDA + #define HW_PIN_SDA SDA //WLEDMM to check if -1 is better #endif // HW_PIN_SCLKSPI & HW_PIN_MOSISPI & HW_PIN_MISOSPI are used for information in usermods settings page and usermods themselves @@ -444,7 +444,7 @@ #if defined(SPISCLKPIN) && !defined(HW_PIN_CLOCKSPI) #define HW_PIN_CLOCKSPI SPISCLKPIN #endif -#if defined(SPIMOSIPIN) && !defined(HW_PIN_MOSISPI) +#if defined(SPIMOSIPIN) && !defined(HW_PIN_MOSISPI) //WLEDMM not HW_PIN_DATASPI??? #define HW_PIN_MOSISPI SPIMOSIPIN #endif #if defined(SPIMISOPIN) && !defined(HW_PIN_MISOSPI) @@ -462,13 +462,13 @@ #endif // defaults for VSPI on ESP32 (SPI global, SPI.cpp) as HSPI is used by WLED (bus_wrapper.h) #ifndef HW_PIN_CLOCKSPI - #define HW_PIN_CLOCKSPI SCK + #define HW_PIN_CLOCKSPI SCK //WLEDMM to check if -1 is better #endif #ifndef HW_PIN_DATASPI - #define HW_PIN_DATASPI MOSI + #define HW_PIN_DATASPI MOSI //WLEDMM to check if -1 is better #endif #ifndef HW_PIN_MISOSPI - #define HW_PIN_MISOSPI MISO + #define HW_PIN_MISOSPI MISO //WLEDMM to check if -1 is better #endif // WLEDMM: IRAM_ATTR for 8266 causes error: section `.text1' will not fit in region `iram1_0_seg' diff --git a/wled00/set.cpp b/wled00/set.cpp index 02cc7651..db35b853 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -549,7 +549,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) DEBUG_PRINTLN(F("Could not allocate I2C pins.")); uint8_t i2c[2] = { static_cast(i2c_scl), static_cast(i2c_sda) }; pinManager.deallocateMultiplePins(i2c, 2, PinOwner::HW_I2C); // just in case deallocation of old pins - Serial.printf("pinmgr not success i2c %d %d\n", i2c_sda, i2c_scl); + Serial.printf("pinmgr not success for global i2c %d %d\n", i2c_sda, i2c_scl); } #ifdef ESP8266 @@ -575,7 +575,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) DEBUG_PRINTLN(F("Could not allocate SPI pins.")); uint8_t spi[3] = { static_cast(spi_mosi), static_cast(spi_miso), static_cast(spi_sclk) }; pinManager.deallocateMultiplePins(spi, 3, PinOwner::HW_SPI); // just in case deallocation of old pins - Serial.printf("pinmgr not success spi %d %d %d\n", spi_mosi, spi_miso, spi_sclk); + Serial.printf("pinmgr not success for global spi %d %d %d\n", spi_mosi, spi_miso, spi_sclk); } JsonObject um = doc.createNestedObject("um"); diff --git a/wled00/wled.h b/wled00/wled.h index d4ac360f..ff061985 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2301081 +#define VERSION 2301082 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG @@ -679,35 +679,35 @@ WLED_GLOBAL uint16_t ledMaps _INIT(0); // bitfield representation of available l WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager()); // global I2C SDA pin (used for usermods) -#ifndef I2CSDAPIN +#ifndef HW_PIN_SDA //WLEDMM not I2CSDAPIN WLED_GLOBAL int8_t i2c_sda _INIT(-1); #else -WLED_GLOBAL int8_t i2c_sda _INIT(I2CSDAPIN); +WLED_GLOBAL int8_t i2c_sda _INIT(HW_PIN_SDA); #endif // global I2C SCL pin (used for usermods) -#ifndef I2CSCLPIN +#ifndef HW_PIN_SCL //WLEDMM not I2CSCLPIN WLED_GLOBAL int8_t i2c_scl _INIT(-1); #else -WLED_GLOBAL int8_t i2c_scl _INIT(I2CSCLPIN); +WLED_GLOBAL int8_t i2c_scl _INIT(HW_PIN_SCL); #endif // global SPI DATA/MOSI pin (used for usermods) -#ifndef SPIMOSIPIN +#ifndef HW_PIN_MOSISPI // WLEDMM not SPIMOSIPIN, what about HW_PIN_DATASPI ???? WLED_GLOBAL int8_t spi_mosi _INIT(-1); #else -WLED_GLOBAL int8_t spi_mosi _INIT(SPIMOSIPIN); +WLED_GLOBAL int8_t spi_mosi _INIT(HW_PIN_MOSISPI); #endif // global SPI DATA/MISO pin (used for usermods) -#ifndef SPIMISOPIN +#ifndef HW_PIN_MISOSPI //WLEDMM not SPIMISOPIN WLED_GLOBAL int8_t spi_miso _INIT(-1); #else -WLED_GLOBAL int8_t spi_miso _INIT(SPIMISOPIN); +WLED_GLOBAL int8_t spi_miso _INIT(HW_PIN_MISOSPI); #endif // global SPI CLOCK/SCLK pin (used for usermods) -#ifndef SPISCLKPIN +#ifndef HW_PIN_CLOCKSPI //WLEDMM not SPISCLKPIN WLED_GLOBAL int8_t spi_sclk _INIT(-1); #else -WLED_GLOBAL int8_t spi_sclk _INIT(SPISCLKPIN); +WLED_GLOBAL int8_t spi_sclk _INIT(HW_PIN_CLOCKSPI); #endif // global ArduinoJson buffer