From ad402adf7a199661400a80f36c4ef9d4a00bca9e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 8 Sep 2024 19:58:37 +0100 Subject: [PATCH] Hub75 - Misc fixes - WiP --- platformio.ini | 3 ++- wled00/bus_manager.cpp | 33 +++++++++++++++------------------ wled00/bus_manager.h | 5 ++++- wled00/data/settings_leds.htm | 17 +++++++++++------ 4 files changed, 32 insertions(+), 26 deletions(-) diff --git a/platformio.ini b/platformio.ini index 120ffe99..e5cf681e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -528,7 +528,8 @@ platform_packages = ${esp32_idf_V4.platform_packages} 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_ENABLE_HUB75MATRIX -D NO_GFX -D NO_CIE1931 + -D ESP32_FORUM_PINOUT -D WLED_DEBUG lib_deps = ${esp32_idf_V4.lib_deps} https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA.git#3.0.11 diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 4d6f93c0..14688d82 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -821,22 +821,22 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh _valid = false; mxconfig.double_buff = false; // default to off, known to cause issue with some effects but needs more memory - // mxconfig.double_buff = true; // <------------- Turn on double buffer // mxconfig.driver = HUB75_I2S_CFG::ICN2038S; // experimental - use specific shift register driver //mxconfig.latch_blanking = 3; // mxconfig.i2sspeed = HUB75_I2S_CFG::HZ_10M; // experimental - 5MHZ should be enugh, but colours looks slightly better at 10MHz //mxconfig.min_refresh_rate = 90; //mxconfig.min_refresh_rate = 120; + mxconfig.clkphase = bc.reversed; fourScanPanel = nullptr; if(bc.type == TYPE_HUB75MATRIX_HS) { - mxconfig.mx_width = bc.pins[0]; - mxconfig.mx_height = bc.pins[1]; + mxconfig.mx_width = min((u_int8_t) 64, bc.pins[0]); + mxconfig.mx_height = 32; // TODO - bad value bc.pins[1]; } else if(bc.type == TYPE_HUB75MATRIX_QS) { - mxconfig.mx_width = bc.pins[0] * 2; - mxconfig.mx_height = bc.pins[1] / 2; + mxconfig.mx_width = min((u_int8_t) 64, bc.pins[0]) * 2; + mxconfig.mx_height = min((u_int8_t) 64, bc.pins[1]) / 2; fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, bc.pins[0], bc.pins[1]); fourScanPanel->setRotation(0); switch(bc.pins[1]) { @@ -860,15 +860,13 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh } - 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 + mxconfig.chain_length = 1; //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_height >= 64 && (mxconfig.chain_length > 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; // HUB75_I2S_CFG::i2s_pins _pins={R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN, A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, LAT_PIN, OE_PIN, CLK_PIN}; @@ -918,6 +916,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh display = new MatrixPanel_I2S_DMA(mxconfig); this->_len = (display->width() * display->height()); + DEBUG_PRINTF("Length: %u\n", _len); // TODO: try and swap _pins to a array so we can use allocateMultiplePins pinManager.allocatePin(mxconfig.gpio.r1, true, PinOwner::HUB75); @@ -1006,8 +1005,8 @@ void __attribute__((hot)) BusHub75Matrix::setPixelColor(uint16_t pix, uint32_t c } } else { - if ((c == BLACK) && (getBitFromArray(_ledsDirty, pix) == false)) return; // ignore black if pixel is already black - setBitInArray(_ledsDirty, pix, c != BLACK); // dirty = true means "color is not BLACK" + if ((c == IS_BLACK) && (getBitFromArray(_ledsDirty, pix) == false)) return; // ignore black if pixel is already black + setBitInArray(_ledsDirty, pix, c != IS_BLACK); // dirty = true means "color is not BLACK" #ifndef NO_CIE1931 c = unGamma24(c); // to use the driver linear brightness feature, we first need to undo WLED gamma correction @@ -1017,25 +1016,23 @@ void __attribute__((hot)) BusHub75Matrix::setPixelColor(uint16_t pix, uint32_t c uint8_t b = B(c); if(fourScanPanel != nullptr) { - int width = _panelWidth; - int x = pix % width; - int y = pix / width; + int x = pix % _panelWidth; + int y = pix / _panelWidth; fourScanPanel->drawPixelRGB888(int16_t(x), int16_t(y), r, g, b); } else { - int width = _panelWidth; - int x = pix % width; - int y = pix / width; + int x = pix % _panelWidth; + int y = pix / _panelWidth; display->drawPixelRGB888(int16_t(x), int16_t(y), r, g, b); } } } uint32_t BusHub75Matrix::getPixelColor(uint16_t pix) const { - if (!_valid || pix >= _len) return BLACK; + if (!_valid || pix >= _len) return IS_BLACK; if (_ledBuffer) return uint32_t(_ledBuffer[pix].scale8(_bri)) & 0x00FFFFFF; // scale8() is needed to mimic NeoPixelBus, which returns scaled-down colours else - return getBitFromArray(_ledsDirty, pix) ? DARKGREY: BLACK; // just a hack - we only know if the pixel is black or not + return getBitFromArray(_ledsDirty, pix) ? IS_DARKGREY: IS_BLACK; // just a hack - we only know if the pixel is black or not } void BusHub75Matrix::setBrightness(uint8_t b, bool immediate) { diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 37bfc25b..67f2c6bf 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -351,7 +351,10 @@ class BusHub75Matrix : public Bus { HUB75_I2S_CFG mxconfig; unsigned _panelWidth = 0; CRGB *_ledBuffer = nullptr; - byte *_ledsDirty = nullptr; + byte *_ledsDirty = nullptr; + // workaround for missing constants on include path for non-MM + uint32_t IS_BLACK = 0x000000; + uint32_t IS_DARKGREY = 0x333333; }; #endif diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 33be8006..0de80604 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -82,6 +82,9 @@ let nm = LC.name.substring(0,2); let n = LC.name.substring(2); let t = parseInt(d.Sf["LT"+n].value, 10); // LED type SELECT + if(isHub75(t)) { + return; + } // ignore IP address if (nm=="L0" || nm=="L1" || nm=="L2" || nm=="L3") { if (t>=80) return; @@ -345,14 +348,16 @@ } } if (isHub75(t) && (nm=="L0" || nm=="L1")) { - LC.max = 16; - LC.min = 128; - LC.style.color="#fff"; - return; // do not check conflicts + // Matrix width and height + LC.max = 128; + LC.min = 16; + LC.style.color="#fff"; + return; // do not check conflicts } else if (isHub75(t) && nm=="L2") { - LC.max = 1; - LC.min = 4; + // Chain length aka Panel Count + LC.max = 4; + LC.min = 1; LC.style.color="#fff"; return; // do not check conflicts }