From 3623afa721c642d98dc0aae6a978a207a7d10fdd Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 12 Apr 2021 23:32:54 +0200 Subject: [PATCH] Minor tweaks. --- usermods/usermod_v2_auto_save/usermod_v2_auto_save.h | 2 +- .../usermod_v2_four_line_display.h | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/usermods/usermod_v2_auto_save/usermod_v2_auto_save.h b/usermods/usermod_v2_auto_save/usermod_v2_auto_save.h index 9f3fddd9..9413140f 100644 --- a/usermods/usermod_v2_auto_save/usermod_v2_auto_save.h +++ b/usermods/usermod_v2_auto_save/usermod_v2_auto_save.h @@ -104,7 +104,7 @@ class AutoSaveUsermod : public Usermod { * Da loop. */ void loop() { - if (!autoSaveAfterSec || !bri) return; // setting 0 as autosave seconds disables autosave as does 0 brightness + if (!autoSaveAfterSec) return; // setting 0 as autosave seconds disables autosave unsigned long now = millis(); uint8_t currentMode = strip.getMode(); diff --git a/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h b/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h index b8a80c21..19fac2c6 100644 --- a/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h +++ b/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h @@ -630,6 +630,8 @@ class FourLineDisplayUsermod : public Usermod { */ void readFromJsonState(JsonObject& root) { if (!initDone) return; // prevent crash on boot applyPreset() + + bool needsRedraw = false; DisplayType newType = type; int8_t newScl = sclPin; int8_t newSda = sdaPin; @@ -643,6 +645,7 @@ class FourLineDisplayUsermod : public Usermod { if (root[F("4LineDisplay_contrast")] != nullptr) { contrast = min(255,max(1,(int)root[F("4LineDisplay_contrast")])); setContrast(contrast); + needsRedraw |= true; } if (root[F("4LineDisplay_refreshRate")] != nullptr) refreshRate = min(60,max(1,(int)root[F("4LineDisplay_refreshRate")]))*1000; if (root[F("4LineDisplay_screenTimeOut")] != nullptr) screenTimeout = min(900,max(0,(int)root[F("4LineDisplay_screenTimeOut")]))*1000; @@ -650,6 +653,7 @@ class FourLineDisplayUsermod : public Usermod { String str = root[F("4LineDisplay_flip")]; // checkbox -> off or on flip = (bool)(str!="off"); // off is guaranteed to be present setFlipMode(flip); + needsRedraw |= true; } if (root[F("4LineDisplay_sleepMode")] != nullptr) { String str = root[F("4LineDisplay_sleepMode")]; // checkbox -> off or on @@ -659,6 +663,7 @@ class FourLineDisplayUsermod : public Usermod { String str = root[F("4LineDisplay_clockMode")]; // checkbox -> off or on clockMode = (bool)(str!="off"); // off is guaranteed to be present setLineThreeType(clockMode ? FLD_LINE_3_MODE : FLD_LINE_3_BRIGHTNESS); + needsRedraw |= true; } if (sclPin!=newScl || sdaPin!=newSda || type!=newType) { @@ -675,8 +680,9 @@ class FourLineDisplayUsermod : public Usermod { type = newType; lineHeight = type==SH1106 ? 2 : 1; setup(); + needRedraw |= true; } - if (!wakeDisplay()) redraw(true); + if (needsRedraw && !wakeDisplay()) redraw(true); } /*