Minor usermod optimisations.

This commit is contained in:
Blaz Kristan 2021-09-08 23:25:05 +02:00
parent 18ba394901
commit 4d6116ed40
2 changed files with 8 additions and 11 deletions

View File

@ -65,6 +65,7 @@ class AutoSaveUsermod : public Usermod {
month(localTime), day(localTime), month(localTime), day(localTime),
hour(localTime), minute(localTime), second(localTime)); hour(localTime), minute(localTime), second(localTime));
savePreset(autoSavePreset, true, presetNameBuffer); savePreset(autoSavePreset, true, presetNameBuffer);
cacheInvalidate++; // force reload of presets
} }
void inline displayOverlay() { void inline displayOverlay() {
@ -87,6 +88,12 @@ class AutoSaveUsermod : public Usermod {
display = (FourLineDisplayUsermod*) usermods.lookup(USERMOD_ID_FOUR_LINE_DISP); display = (FourLineDisplayUsermod*) usermods.lookup(USERMOD_ID_FOUR_LINE_DISP);
#endif #endif
initDone = true; initDone = true;
if (enabled && applyAutoSaveOnBoot) applyPreset(autoSavePreset);
knownBrightness = bri;
knownEffectSpeed = effectSpeed;
knownEffectIntensity = effectIntensity;
knownMode = strip.getMode();
knownPalette = strip.getSegment(0).palette;
} }
// gets called every time WiFi is (re-)connected. Initialize own network // gets called every time WiFi is (re-)connected. Initialize own network
@ -102,16 +109,6 @@ class AutoSaveUsermod : public Usermod {
unsigned long now = millis(); unsigned long now = millis();
uint8_t currentMode = strip.getMode(); uint8_t currentMode = strip.getMode();
uint8_t currentPalette = strip.getSegment(0).palette; uint8_t currentPalette = strip.getSegment(0).palette;
if (firstLoop) {
firstLoop = false;
if (applyAutoSaveOnBoot) applyPreset(autoSavePreset);
knownBrightness = bri;
knownEffectSpeed = effectSpeed;
knownEffectIntensity = effectIntensity;
knownMode = currentMode;
knownPalette = currentPalette;
return;
}
unsigned long wouldAutoSaveAfter = now + autoSaveAfterSec*1000; unsigned long wouldAutoSaveAfter = now + autoSaveAfterSec*1000;
if (knownBrightness != bri) { if (knownBrightness != bri) {

View File

@ -408,7 +408,7 @@ class FourLineDisplayUsermod : public Usermod {
center(line, getCols()-2); center(line, getCols()-2);
drawString(1, 0, line.c_str()); drawString(1, 0, line.c_str());
// Print `~` char to indicate that SSID is longer, than our display // Print `~` char to indicate that SSID is longer, than our display
if (knownSsid.length() > getCols()-1) { if (knownSsid.length() > (int)getCols()-1) {
drawString(getCols() - 1, 0, "~"); drawString(getCols() - 1, 0, "~");
} }