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();