From 06fc1eb5b8775dbc1e530a41eb3f8ade01e940fa Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 15 Nov 2024 22:33:29 +0100 Subject: [PATCH 1/4] HUB75: use last brightness on re-init avoids brightness flash when saving LED preferences --- wled00/bus_manager.cpp | 5 ++++- wled00/bus_manager.h | 1 + wled00/wled00.ino | 16 +++++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 4cd339a4..34c39f86 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -528,6 +528,7 @@ VirtualMatrixPanel* BusHub75Matrix::activeFourScanPanel = nullptr; HUB75_I2S_CFG BusHub75Matrix::activeMXconfig = HUB75_I2S_CFG(); uint8_t BusHub75Matrix::activeType = 0; uint8_t BusHub75Matrix::instanceCount = 0; +uint8_t BusHub75Matrix::last_bri = 0; // -------------------------- @@ -899,7 +900,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh USER_PRINTLN("MatrixPanel_I2S_DMA created"); // let's adjust default brightness //display->setBrightness8(25); // range is 0-255, 0 - 0%, 255 - 100% // [setBrightness()] Tried to set output brightness before begin() - _bri = 25; + _bri = (last_bri > 0) ? last_bri : 25; // try to restore persistent brightness value delay(24); // experimental DEBUG_PRINT(F("heap usage: ")); DEBUG_PRINTLN(int(lastHeap - ESP.getFreeHeap())); @@ -917,6 +918,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh USER_PRINT(F("heap usage: ")); USER_PRINTLN(int(lastHeap - ESP.getFreeHeap())); delay(18); // experiment - give the driver a moment (~ one full frame @ 60hz) to settle _valid = true; + display->setBrightness8(_bri); // range is 0-255, 0 - 0%, 255 - 100% // [setBrightness()] Tried to set output brightness before begin() display->clearScreen(); // initially clear the screen buffer USER_PRINTLN("MatrixPanel_I2S_DMA clear ok"); @@ -1057,6 +1059,7 @@ void BusHub75Matrix::setBrightness(uint8_t b, bool immediate) { MatrixPanel_I2S_DMA* display = BusHub75Matrix::activeDisplay; // if (_bri > 238) _bri=238; // not strictly needed. Enable this line if you see glitches at highest brightness. if ((_bri > 253) && (activeMXconfig.latch_blanking < 2)) _bri=253; // prevent glitches at highest brightness. + last_bri = _bri; if (display) display->setBrightness(_bri); } diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 9259bd1f..339b1ef8 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -411,6 +411,7 @@ class BusHub75Matrix : public Bus { static HUB75_I2S_CFG activeMXconfig; // last used mxconfig static uint8_t activeType; // last used type static uint8_t instanceCount; // active instances - 0 or 1 + static uint8_t last_bri; // last used brightness value (persists on driver delete) }; #endif diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 6f1f22d5..ff80af21 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -61,6 +61,11 @@ void esp_heap_trace_free_hook(void* ptr) unsigned long lastMillis = 0; //WLEDMM unsigned long loopCounter = 0; //WLEDMM +unsigned long lps = 0; // loops per second +unsigned long lps2 = 0; // lps without "show" + +unsigned long long showtime = 0; // time spent in "show" (micros) + void setup() __attribute__((used)); // needed for -flto void setup() { #ifdef WLED_DEBUG_HEAP @@ -73,13 +78,22 @@ void loop() __attribute__((used)); // needed for -flto void loop() { //WLEDMM show loops per second loopCounter++; - if (millis() - lastMillis >= 10000) { + //if (millis() - lastMillis >= 10000) { + if (millis() - lastMillis >= 8000) { long delta = millis() - lastMillis; if (delta > 0) { + lps = (loopCounter*1000U) / delta; //USER_PRINTF("%lu lps\n",(loopCounter*1000U) / delta); + if (delta > (showtime / 1000)) lps2 = (loopCounter*1000U) / (delta - (showtime / 1000)); + USER_PRINTF("%lu lps\t", lps); + USER_PRINTF("%u fps\t", strip.getFps()); + USER_PRINTF("%lu lps without show\t\t", lps2); + USER_PRINTF("frametime %d\t", int(strip.getFrameTime())); + USER_PRINTF("targetFPS %d\n", int(strip.getTargetFps())); } lastMillis = millis(); loopCounter = 0; + showtime = 0; } WLED::instance().loop(); From db1db330afa0b19a69596b3a2517ab03672008be Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 15 Nov 2024 23:33:57 +0100 Subject: [PATCH 2/4] HUB75: bugfix for 4-scan (virtual) panels chain module cols parameter must be chain_length --- wled00/bus_manager.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 34c39f86..57670b26 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -636,7 +636,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh mxconfig.mx_width = 64; mxconfig.mx_height = 64; break; - case 104: // untested + case 104: mxconfig.mx_width = 128; mxconfig.mx_height = 64; break; @@ -952,25 +952,25 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh switch(bc.type) { case 105: USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_32PX_HIGH - 32x32"); - if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 32, 32); + if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, mxconfig.chain_length, 32, 32); fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_32PX_HIGH); fourScanPanel->setRotation(0); break; case 106: USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_32PX_HIGH - 64x32"); - if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 64, 32); + if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, mxconfig.chain_length, 64, 32); fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_32PX_HIGH); fourScanPanel->setRotation(0); break; case 107: USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_64PX_HIGH"); - if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 64, 64); + if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, mxconfig.chain_length, 64, 64); fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_64PX_HIGH); fourScanPanel->setRotation(0); break; case 108: // untested USER_PRINTLN("MatrixPanel_I2S_DMA 128x64 FOUR_SCAN_64PX_HIGH"); - if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 128, 64); + if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, mxconfig.chain_length, 128, 64); fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_64PX_HIGH); fourScanPanel->setRotation(0); break; From 7167db4a22b94510bc372444d82a3de558a8d34b Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Sat, 16 Nov 2024 01:43:18 +0100 Subject: [PATCH 3/4] Polar Lights upgrade * stop flickering when rows > 56 * blur option added * allow to use palettes --- wled00/FX.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 9e62e00a..bdb350b1 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -5972,9 +5972,11 @@ uint16_t mode_2DPolarLights(void) { // By: Kostyantyn Matviyevskyy https const uint16_t cols = SEGMENT.virtualWidth(); const uint16_t rows = SEGMENT.virtualHeight(); const float maxRows = (rows <= 32) ? 32.0f : (rows <= 64) ? 64.0f : 128.0f; // WLEDMM safe up to 128x128 - const float minScale = (rows <= 32) ? 12.0f : (rows <= 64) ? 4.6f : 2.1f; // WLEDMM + const float minScale = (rows <= 32) ? 12.0f : (rows <= 64) ? 7.2f : 4.6f; // WLEDMM + const float maxCols = (cols <= 32) ? 32.0f : (cols <= 64) ? 64.0f : 128.0f; // WLEDMM safe up to 128x128 const CRGBPalette16 auroraPalette = {0x000000, 0x003300, 0x006600, 0x009900, 0x00cc00, 0x00ff00, 0x33ff00, 0x66ff00, 0x99ff00, 0xccff00, 0xffff00, 0xffcc00, 0xff9900, 0xff6600, 0xff3300, 0xff0000}; + const CRGBPalette16 &effectPalette = SEGENV.check1 ? SEGPALETTE : auroraPalette; if (SEGENV.call == 0) { SEGMENT.setUpLeds(); @@ -5982,7 +5984,7 @@ uint16_t mode_2DPolarLights(void) { // By: Kostyantyn Matviyevskyy https } float adjustHeight = mapf(rows, 8, maxRows, 28, minScale); // maybe use mapf() ??? // WLEDMM yes! - uint16_t adjScale = map2(cols, 8, 64, 310, 63); + uint16_t adjScale = map2(cols, 8, maxCols, 310, 63); // WLEDMM adjustHeight = max(min(adjustHeight, 28.0f), minScale); // WLEDMM bugfix for larger fixtures adjScale = max(min(adjScale, uint16_t(310)), uint16_t(63)); // WLEDMM @@ -6002,11 +6004,11 @@ uint16_t mode_2DPolarLights(void) { // By: Kostyantyn Matviyevskyy https } */ uint16_t _scale = map2(SEGMENT.intensity, 0, 255, 30, adjScale); - byte _speed = map2(SEGMENT.speed, 0, 255, 128, 16); + byte _speed = map2(SEGMENT.speed, 0, 255, 136, 20); //WLEDMM add SuperSync control uint16_t xStart, xEnd, yStart, yEnd; - if (SEGMENT.check1) { //Master (sync on needs to show the whole effect, children only their first panel) + if (SEGMENT.check2) { //Master (sync on needs to show the whole effect, children only their first panel) xStart = strip.panel[0].xOffset; xEnd = strip.panel[0].xOffset + strip.panel[0].width; yStart = strip.panel[0].yOffset; @@ -6024,16 +6026,17 @@ uint16_t mode_2DPolarLights(void) { // By: Kostyantyn Matviyevskyy https for (int x = xStart; x < xEnd; x++) { for (int y = yStart; y < yEnd; y++) { SEGENV.step++; - SEGMENT.setPixelColorXY(x, y, ColorFromPalette(auroraPalette, + SEGMENT.setPixelColorXY(x, y, ColorFromPalette(effectPalette, qsub8( inoise8((SEGENV.step%2) + x * _scale, y * 16 + SEGENV.step % 16, SEGENV.step / _speed), fabsf(rows_2 - (float)y) * adjustHeight))); // WLEDMM } } + if (SEGENV.check3) SEGMENT.blurRows(192); return FRAMETIME; } // mode_2DPolarLights() -static const char _data_FX_MODE_2DPOLARLIGHTS[] PROGMEM = "Polar Lights@!,Scale,,,,SuperSync;;;2"; +static const char _data_FX_MODE_2DPOLARLIGHTS[] PROGMEM = "Polar Lights@!,Scale,,,,Use Palette,SuperSync, Blur;;!;2"; ///////////////////////// From 52509bab0f0a05defd27f7e2dba3b6ca33c886d0 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:13:15 +0100 Subject: [PATCH 4/4] OTA update improved error messages The OTA update class can deliver an error message. old: "Please check your file and retry" new: "Could Not Activate The Firmware. (wrong board type?). Please check your file and retry!" --- wled00/wled_server.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wled00/wled_server.cpp b/wled00/wled_server.cpp index f3fe1c08..6bd577d7 100644 --- a/wled00/wled_server.cpp +++ b/wled00/wled_server.cpp @@ -329,7 +329,15 @@ void initServer() return; } if (Update.hasError() || otaLock) { +#ifdef ARDUINO_ARCH_ESP32 + if (Update.hasError()) { + String updErr = Update.getError() == UPDATE_ERROR_ACTIVATE ? String("Could Not Activate The Firmware. (wrong board type?)") : String(Update.errorString()); + serveMessage(request, 500, F("Update failed!"), updErr + String("
Please check your file and retry!"), 254); + } else + serveMessage(request, 500, F("Update failed!"), F("Please check your file and retry! (OTA may be locked)"), 254); +#else serveMessage(request, 500, F("Update failed!"), F("Please check your file and retry!"), 254); +#endif } else { serveMessage(request, 200, F("Update successful!"), F("Rebooting..."), 131); doReboot = true;