HUB75: use last brightness on re-init
avoids brightness flash when saving LED preferences
This commit is contained in:
@@ -528,6 +528,7 @@ VirtualMatrixPanel* BusHub75Matrix::activeFourScanPanel = nullptr;
|
|||||||
HUB75_I2S_CFG BusHub75Matrix::activeMXconfig = HUB75_I2S_CFG();
|
HUB75_I2S_CFG BusHub75Matrix::activeMXconfig = HUB75_I2S_CFG();
|
||||||
uint8_t BusHub75Matrix::activeType = 0;
|
uint8_t BusHub75Matrix::activeType = 0;
|
||||||
uint8_t BusHub75Matrix::instanceCount = 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");
|
USER_PRINTLN("MatrixPanel_I2S_DMA created");
|
||||||
// let's adjust default brightness
|
// let's adjust default brightness
|
||||||
//display->setBrightness8(25); // range is 0-255, 0 - 0%, 255 - 100% // [setBrightness()] Tried to set output brightness before begin()
|
//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
|
delay(24); // experimental
|
||||||
DEBUG_PRINT(F("heap usage: ")); DEBUG_PRINTLN(int(lastHeap - ESP.getFreeHeap()));
|
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()));
|
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
|
delay(18); // experiment - give the driver a moment (~ one full frame @ 60hz) to settle
|
||||||
_valid = true;
|
_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
|
display->clearScreen(); // initially clear the screen buffer
|
||||||
USER_PRINTLN("MatrixPanel_I2S_DMA clear ok");
|
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;
|
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 > 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.
|
if ((_bri > 253) && (activeMXconfig.latch_blanking < 2)) _bri=253; // prevent glitches at highest brightness.
|
||||||
|
last_bri = _bri;
|
||||||
if (display) display->setBrightness(_bri);
|
if (display) display->setBrightness(_bri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -411,6 +411,7 @@ class BusHub75Matrix : public Bus {
|
|||||||
static HUB75_I2S_CFG activeMXconfig; // last used mxconfig
|
static HUB75_I2S_CFG activeMXconfig; // last used mxconfig
|
||||||
static uint8_t activeType; // last used type
|
static uint8_t activeType; // last used type
|
||||||
static uint8_t instanceCount; // active instances - 0 or 1
|
static uint8_t instanceCount; // active instances - 0 or 1
|
||||||
|
static uint8_t last_bri; // last used brightness value (persists on driver delete)
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,11 @@ void esp_heap_trace_free_hook(void* ptr)
|
|||||||
unsigned long lastMillis = 0; //WLEDMM
|
unsigned long lastMillis = 0; //WLEDMM
|
||||||
unsigned long loopCounter = 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() __attribute__((used)); // needed for -flto
|
||||||
void setup() {
|
void setup() {
|
||||||
#ifdef WLED_DEBUG_HEAP
|
#ifdef WLED_DEBUG_HEAP
|
||||||
@@ -73,13 +78,22 @@ void loop() __attribute__((used)); // needed for -flto
|
|||||||
void loop() {
|
void loop() {
|
||||||
//WLEDMM show loops per second
|
//WLEDMM show loops per second
|
||||||
loopCounter++;
|
loopCounter++;
|
||||||
if (millis() - lastMillis >= 10000) {
|
//if (millis() - lastMillis >= 10000) {
|
||||||
|
if (millis() - lastMillis >= 8000) {
|
||||||
long delta = millis() - lastMillis;
|
long delta = millis() - lastMillis;
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
|
lps = (loopCounter*1000U) / delta;
|
||||||
//USER_PRINTF("%lu lps\n",(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();
|
lastMillis = millis();
|
||||||
loopCounter = 0;
|
loopCounter = 0;
|
||||||
|
showtime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WLED::instance().loop();
|
WLED::instance().loop();
|
||||||
|
|||||||
Reference in New Issue
Block a user