HUB75: use last brightness on re-init

avoids brightness flash when saving LED preferences
This commit is contained in:
Frank
2024-11-15 22:33:29 +01:00
parent d6dedd025d
commit 06fc1eb5b8
3 changed files with 20 additions and 2 deletions

View File

@@ -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);
}

View File

@@ -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

View File

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