From 1e5b246871b1b034f1e93c4c5d3f4a9863f1b597 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Thu, 3 Oct 2024 00:19:18 +0200 Subject: [PATCH] small fixes very minor changes: * HUB75 bus don't leave _len uninitialized, handle display == nullptr before using display members * __attribute__((pure)) was in the wrong location * wled00.ino: made lps (loops-per-second) calculation a bit more accurate --- wled00/FX.h | 4 ++-- wled00/bus_manager.cpp | 6 ++++++ wled00/wled00.ino | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/wled00/FX.h b/wled00/FX.h index 04eabe70..19175985 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -945,9 +945,9 @@ class WS2812FX { // 96 bytes milliampsPerLed, cctBlending, getActiveSegmentsNum(void) const, - getFirstSelectedSegId(void) __attribute__((pure)), + __attribute__((pure)) getFirstSelectedSegId(void), getLastActiveSegmentId(void) const, - getActiveSegsLightCapabilities(bool selectedOnly = false) __attribute__((pure)), + __attribute__((pure)) getActiveSegsLightCapabilities(bool selectedOnly = false), setPixelSegment(uint8_t n); inline uint8_t getBrightness(void) const { return _brightness; } diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index cb3d8fac..82e2c015 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -527,6 +527,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh _valid = false; fourScanPanel = nullptr; + _len = 0; mxconfig.double_buff = false; // Use our own memory-optimised buffer rather than the driver's own double-buffer @@ -744,6 +745,11 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh // OK, now we can create our matrix object display = new MatrixPanel_I2S_DMA(mxconfig); + if (display == nullptr) { + USER_PRINTLN("****** MatrixPanel_I2S_DMA !KABOOM! driver allocation failed ***********"); + USER_PRINT(F("heap usage: ")); USER_PRINTLN(lastHeap - ESP.getFreeHeap()); + return; + } this->_len = (display->width() * display->height()); diff --git a/wled00/wled00.ino b/wled00/wled00.ino index b19441a2..6f1f22d5 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -74,7 +74,10 @@ void loop() { //WLEDMM show loops per second loopCounter++; if (millis() - lastMillis >= 10000) { - //USER_PRINTF("%lu lps\n",loopCounter/10); + long delta = millis() - lastMillis; + if (delta > 0) { + //USER_PRINTF("%lu lps\n",(loopCounter*1000U) / delta); + } lastMillis = millis(); loopCounter = 0; }