From ecd46f2f06724935db2d8d6034a56fbefde6be27 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Sep 2024 20:29:43 +0100 Subject: [PATCH] Swap to new way to have dynamic LED types list --- platformio.ini | 3 ++- wled00/bus_manager.cpp | 28 +++++++++++++++++++++------- wled00/bus_manager.h | 3 +++ wled00/xml.cpp | 3 --- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/platformio.ini b/platformio.ini index ecb118c1..40493545 100644 --- a/platformio.ini +++ b/platformio.ini @@ -525,7 +525,8 @@ upload_speed = 921600 platform = ${esp32_idf_V4.platform} platform_packages = ${esp32_idf_V4.platform_packages} build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags_esp32_V4} -D WLED_RELEASE_NAME=ESP32_hub75 +build_flags = ${common.build_flags} + -D WLED_RELEASE_NAME=ESP32_hub75 -D WLED_ENABLE_HUB75MATRIX -D NO_GFX lib_deps = ${esp32_idf_V4.lib_deps} https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA.git @ 3.0.10 diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index d2a65b6e..9f0de745 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -810,7 +810,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh mxconfig.chain_length = max((u_int8_t) 1, min(bc.pins[0], (u_int8_t) 4)); // prevent bad data preventing boot due to low memory if(mxconfig.mx_width >= 64 && (bc.pins[0] > 1)) { - DEBUG_PRINTF("WARNING, only single panel can be used of 64 pixel boards due to memory") + DEBUG_PRINTLN("WARNING, only single panel can be used of 64 pixel boards due to memory") mxconfig.chain_length = 1; } @@ -820,7 +820,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh // https://www.adafruit.com/product/5778 - DEBUG_PRINTF("MatrixPanel_I2S_DMA - Matrix Portal S3 config"); + DEBUG_PRINTLN("MatrixPanel_I2S_DMA - Matrix Portal S3 config"); mxconfig.gpio.r1 = 42; mxconfig.gpio.g1 = 41; @@ -841,7 +841,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh #elif defined(ESP32_FORUM_PINOUT) // Common format for boards designed for SmartMatrix - USER_PRINTLN("MatrixPanel_I2S_DMA - ESP32_FORUM_PINOUT"); + DEBUG_PRINTLN("MatrixPanel_I2S_DMA - ESP32_FORUM_PINOUT"); /* ESP32 with SmartMatrix's default pinout - ESP32_FORUM_PINOUT @@ -869,7 +869,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh mxconfig.gpio.e = 12; #else - USER_PRINTLN("MatrixPanel_I2S_DMA - Default pins"); + DEBUG_PRINTLN("MatrixPanel_I2S_DMA - Default pins"); /* https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA?tab=readme-ov-file @@ -925,20 +925,20 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh // display->setLatBlanking(4); - DEBUG_PRINTF("MatrixPanel_I2S_DMA created"); + DEBUG_PRINTLN("MatrixPanel_I2S_DMA created"); // let's adjust default brightness display->setBrightness8(25); // range is 0-255, 0 - 0%, 255 - 100% // Allocate memory and start DMA display if( not display->begin() ) { - DEBUG_PRINTF("****** MatrixPanel_I2S_DMA !KABOOM! I2S memory allocation failed ***********"); + DEBUG_PRINTLN("****** MatrixPanel_I2S_DMA !KABOOM! I2S memory allocation failed ***********"); return; } else { _valid = true; } - DEBUG_PRINTF("MatrixPanel_I2S_DMA started"); + DEBUG_PRINTLN("MatrixPanel_I2S_DMA started"); } void BusHub75Matrix::setPixelColor(uint16_t pix, uint32_t c) { @@ -974,6 +974,16 @@ void BusHub75Matrix::deallocatePins() { pinManager.deallocatePin(mxconfig.gpio.e, PinOwner::HUB75); } + +std::vector BusHub75Matrix::getLEDTypes() { + return { + {TYPE_HUB75MATRIX + 1, "H", PSTR("HUB75 32x32")}, + {TYPE_HUB75MATRIX + 2, "H", PSTR("HUB75 64x32")}, + {TYPE_HUB75MATRIX + 3, "H", PSTR("HUB75 64x64")}, + }; +} + + #endif // *************************************************************************** @@ -1042,6 +1052,10 @@ String BusManager::getLEDTypesJSONString(void) { json += LEDTypesToJson(BusPwm::getLEDTypes()); json += LEDTypesToJson(BusNetwork::getLEDTypes()); //json += LEDTypesToJson(BusVirtual::getLEDTypes()); + #ifdef WLED_ENABLE_HUB75MATRIX + json += LEDTypesToJson(BusHub75Matrix::getLEDTypes()); + #endif + json.setCharAt(json.length()-1, ']'); // replace last comma with bracket return json; } diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index df11cf4b..9bff1667 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -143,6 +143,7 @@ class Bus { static constexpr bool isOnOff(uint8_t type) { return (type == TYPE_ONOFF); } static constexpr bool isPWM(uint8_t type) { return (type >= TYPE_ANALOG_MIN && type <= TYPE_ANALOG_MAX); } static constexpr bool isVirtual(uint8_t type) { return (type >= TYPE_VIRTUAL_MIN && type <= TYPE_VIRTUAL_MAX); } + static constexpr bool isHub75(uint8_t type) { return (type >= TYPE_HUB75MATRIX); } static constexpr bool is16bit(uint8_t type) { return type == TYPE_UCS8903 || type == TYPE_UCS8904 || type == TYPE_SM16825; } static constexpr int numPWMPins(uint8_t type) { return (type - 40); } @@ -349,6 +350,8 @@ class BusHub75Matrix : public Bus { cleanup(); } + static std::vector getLEDTypes(void); + private: MatrixPanel_I2S_DMA *display = nullptr; HUB75_I2S_CFG mxconfig; diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 037354ca..22d21d77 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -784,9 +784,6 @@ void getSettingsJS(byte subPage, char* dest) #else oappend(SET_F("gId(\"somp\").remove(1);")); // remove 2D option from dropdown #endif - #ifndef WLED_ENABLE_HUB75MATRIX - oappend(SET_F("hideHub75();")); // hide HUB75 LED types - #endif } }