From e2aad4783d5d86466f841832f8abff2fa4ef3479 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 24 Feb 2024 17:27:20 +0000 Subject: [PATCH] Allow chain of 1-4 panels - subject to memory --- wled00/bus_manager.cpp | 42 +++++++++++++++++++++-------------- wled00/bus_manager.h | 5 ++++- wled00/data/settings_leds.htm | 9 +------- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 9d71bf41..64a104fc 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -466,6 +466,8 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh mxconfig.double_buff = false; // <------------- Turn on double buffer + 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 + fourScanPanel = nullptr; switch(bc.type) { @@ -566,24 +568,11 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh #endif - USER_PRINTLN("MatrixPanel_I2S_DMA config"); + USER_PRINTF("MatrixPanel_I2S_DMA config - %ux%u length: %u\n", mxconfig.mx_width, mxconfig.mx_height, mxconfig.chain_length); // OK, now we can create our matrix object display = new MatrixPanel_I2S_DMA(mxconfig); - switch(bc.type) { - case 105: - USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_16PX_HIGH"); - fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 32, 32); - fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_16PX_HIGH); - break; - case 106: - USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_32PX_HIGH"); - fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 64, 64); - fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_32PX_HIGH); - break; - } - this->_len = (display->width() * display->height()); pinManager.allocatePin(mxconfig.gpio.r1, true, PinOwner::HUB75); @@ -611,11 +600,28 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh // Allocate memory and start DMA display if( not display->begin() ) { - USER_PRINTLN("****** !KABOOM! I2S memory allocation failed ***********"); + USER_PRINTLN("****** MatrixPanel_I2S_DMA !KABOOM! I2S memory allocation failed ***********"); + return; } else { _valid = true; } + + switch(bc.type) { + case 105: + USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_32PX_HIGH"); + fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 32, 32); + fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_32PX_HIGH); + fourScanPanel->setRotation(0); + break; + case 106: + USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_64PX_HIGH"); + fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 64, 64); + fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_64PX_HIGH); + fourScanPanel->setRotation(0); + break; + } + USER_PRINTLN("MatrixPanel_I2S_DMA started"); } @@ -624,12 +630,14 @@ void BusHub75Matrix::setPixelColor(uint16_t pix, uint32_t c) { r = R(c); g = G(c); b = B(c); - x = pix % mxconfig.mx_width; - y = floor(pix / mxconfig.mx_width); if(fourScanPanel != nullptr) { + x = pix % fourScanPanel->width(); + y = floor(pix / fourScanPanel->width()); fourScanPanel->drawPixelRGB888(x, y, r, g, b); } else { + x = pix % display->width(); + y = floor(pix / display->width()); display->drawPixelRGB888(x, y, r, g, b); } } diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 01e8a3e4..7b134986 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -350,7 +350,10 @@ class BusHub75Matrix : public Bus { void setBrightness(uint8_t b, bool immediate); - uint8_t getPins(uint8_t* pinArray) { return 1; } // Fake value due to keep finaliseInit happy + uint8_t getPins(uint8_t* pinArray) { + pinArray[0] = mxconfig.chain_length; + return 1; + } // Fake value due to keep finaliseInit happy void deallocatePins(); diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index d5c8ae19..d1d4676e 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -177,19 +177,12 @@ if (s[i].name.substring(0,2)=="LT") { var n = s[i].name.substring(2); var t = parseInt(s[i].value,10); - gId("p0d"+n).innerHTML = (t>=80 && t<96) ? "IP address:" : (t > 49) ? "Data GPIO:" : (t > 41) ? "GPIOs:" : "GPIO:"; + gId("p0d"+n).innerHTML = (t >= 100 && t < 110) ? "Chain Length:" : (t>=80 && t<96) ? "IP address:" : (t > 49) ? "Data GPIO:" : (t > 41) ? "GPIOs:" : "GPIO:"; gId("p1d"+n).innerHTML = (t> 49 && t<64) ? "Clk GPIO:" : ""; var LK = d.getElementsByName("L1"+n)[0]; // clock pin memu += getMem(t, n); // calc memory - if(t >= 100 && t < 110) { - var LK = d.getElementsByName("L00")[0]; // data pin - LK.style.display = "none"; - LK.required = false; - LK.value=""; - } - // enumerate pins for (p=1; p<5; p++) { var LK = d.getElementsByName("L"+p+n)[0]; // secondary pins