From e066b502c3bf339a0ea4fb0e4dc3e02bf8d67e4e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 8 Sep 2024 13:33:34 +0100 Subject: [PATCH] hub75 - remove hard coded panel sizes --- platformio.ini | 4 +++- wled00/bus_manager.cpp | 25 +++++++++---------------- wled00/bus_manager.h | 2 +- wled00/data/settings_leds.htm | 14 ++++++++++---- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/platformio.ini b/platformio.ini index 40493545..120ffe99 100644 --- a/platformio.ini +++ b/platformio.ini @@ -519,6 +519,7 @@ build_flags = ${common.build_flags} ${esp32s2.build_flags} -D WLED_RELEASE_NAME= lib_deps = ${esp32s2.lib_deps} ${esp32.AR_lib_deps} +;; TODO - move to sample ini [env:esp32dev_hub75] board = esp32dev upload_speed = 921600 @@ -528,8 +529,9 @@ build_unflags = ${common.build_unflags} build_flags = ${common.build_flags} -D WLED_RELEASE_NAME=ESP32_hub75 -D WLED_ENABLE_HUB75MATRIX -D NO_GFX + -D WLED_DEBUG lib_deps = ${esp32_idf_V4.lib_deps} - https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA.git @ 3.0.10 + https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA.git#3.0.11 monitor_filters = esp32_exception_decoder board_build.partitions = ${esp32.default_partitions} diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 0117c2aa..a4d1b499 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -790,31 +790,24 @@ void BusNetwork::cleanup(void) { BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { - mxconfig.double_buff = false; // <------------- Turn on double buffer + mxconfig.double_buff = true; // <------------- Turn on double buffer switch(bc.type) { - case 101: - mxconfig.mx_width = 32; - mxconfig.mx_height = 32; - break; - case 102: - mxconfig.mx_width = 64; - mxconfig.mx_height = 32; - break; - case 103: - mxconfig.mx_width = 64; - mxconfig.mx_height = 64; + case TYPE_HUB75MATRIX_HS: + mxconfig.mx_width = bc.pins[0]; + mxconfig.mx_height = bc.pins[1]; break; } - 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 + mxconfig.chain_length = max((u_int8_t) 1, min(bc.pins[2], (u_int8_t) 4)); // prevent bad data preventing boot due to low memory - if(mxconfig.mx_width >= 64 && (bc.pins[0] > 1)) { + if(mxconfig.mx_height >= 64 && (bc.pins[2] > 1)) { DEBUG_PRINTLN("WARNING, only single panel can be used of 64 pixel boards due to memory") mxconfig.chain_length = 1; } // mxconfig.driver = HUB75_I2S_CFG::SHIFTREG; + mxconfig.clkphase = bc.reversed; #if defined(ARDUINO_ADAFRUIT_MATRIXPORTAL_ESP32S3) // MatrixPortal ESP32-S3 @@ -977,8 +970,8 @@ void BusHub75Matrix::deallocatePins() { std::vector BusHub75Matrix::getLEDTypes() { return { - {TYPE_HUB75MATRIX_HS, "H", PSTR("HUB75 - Half Scan")}, - // {TYPE_HUB75MATRIX_QS, "H", PSTR("HUB75 - Quarter Scan")}, + {TYPE_HUB75MATRIX_HS, "H", PSTR("HUB75 (Half Scan)")}, + // {TYPE_HUB75MATRIX_QS, "H", PSTR("HUB75 (Quarter Scan)")}, }; } diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 9bff1667..97e6caff 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -143,7 +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 isHub75(uint8_t type) { return (type >= TYPE_HUB75MATRIX_MIN && type <= TYPE_HUB75MATRIX_MAX); } 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); } diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 80962398..a2f938aa 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -248,14 +248,14 @@ p0d = "Config:" break; case 'H': // HUB75 - p0d = "Chin Length:" + p0d = "Panel size (width x height):" break; } gId("p0d"+n).innerText = p0d; gId("p1d"+n).innerText = p1d; gId("off"+n).innerText = off; // secondary pins show/hide (type string length is equivalent to number of pins used; except for network and on/off) - let pins = Math.max(gT(t).t.length,1) + 3*isNet(t); // fixes network pins to 4 + let pins = Math.max(gT(t).t.length,1) + 3*isNet(t) + 1*isHub75(t); // fixes network pins to 4 for (let p=1; p<5; p++) { var LK = d.Sf["L"+p+n]; if (!LK) continue; @@ -283,12 +283,12 @@ } gId("rf"+n).onclick = (t == 31) ? (()=>{return false}) : (()=>{}); // prevent change for TM1814 gRGBW |= hasW(t); // RGBW checkbox - gId("co"+n).style.display = (isVir(t) || isAna(t)) ? "none":"inline"; // hide color order for PWM + gId("co"+n).style.display = (isVir(t) || isAna(t) || isHub75(t)) ? "none":"inline"; // hide color order for PWM gId("dig"+n+"w").style.display = (isDig(t) && hasW(t)) ? "inline":"none"; // show swap channels dropdown gId("dig"+n+"w").querySelector("[data-opt=CCT]").disabled = !hasCCT(t); // disable WW/CW swapping if (!(isDig(t) && hasW(t))) d.Sf["WO"+n].value = 0; // reset swapping gId("dig"+n+"c").style.display = (isAna(t) || isHub75(t)) ? "none":"inline"; // hide count for analog - gId("dig"+n+"r").style.display = (isVir(t) || isHub75(t)) ? "none":"inline"; // hide reversed for virtual + gId("dig"+n+"r").style.display = (isVir(t)) ? "none":"inline"; // hide reversed for virtual gId("dig"+n+"s").style.display = (isVir(t) || isAna(t) || isHub75(t)) ? "none":"inline"; // hide skip 1st for virtual & analog gId("dig"+n+"f").style.display = (isDig(t) || (isPWM(t) && maxL>2048)) ? "inline":"none"; // hide refresh (PWM hijacks reffresh for dithering on ESP32) gId("dig"+n+"a").style.display = (hasW(t)) ? "inline":"none"; // auto calculate white @@ -339,6 +339,12 @@ LC.min = 0; LC.style.color="#fff"; return; // do not check conflicts + } + else if (isHub75(t)) { + LC.max = 128; + LC.min = 16; + LC.style.color="#fff"; + return; // do not check conflicts } else { LC.max = d.max_gpio; LC.min = -1;