Let SignalRGB keep the clock awake at night
New "Wake at night" setting (prmExt.wledWakeAtNight, web UI only): while WLED frames arrive, the night schedule is ignored and the clock runs as by day. Night mode returns as soon as the frames time out. The manual night toggle, radar and HA Tubes switch still win. The field uses the former padding byte of prmExt; MAGIC_VALUE_EXT is now 0x5702 and 0x5701 settings are migrated, so existing SignalRGB settings are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7d5cd3bf8d
commit
6b1d20acde
5 files changed
+48
-16
No files matched your search
@@ -446,13 +446,18 @@ struct {
|
||||
// Adding them to `prm` would change its layout, and the MAGIC_VALUE check would then factory-reset
|
||||
// the clock (WiFi settings included). If the magic value doesn't match (first boot after the update),
|
||||
// loadEEPROM() sets these defaults and leaves `prm` alone.
|
||||
#define MAGIC_VALUE_EXT 0x5701
|
||||
// 0x5701 had no wledWakeAtNight; it sat in what was the padding byte, so the other fields kept their place and
|
||||
// loadEEPROM() takes them over.
|
||||
#define MAGIC_VALUE_EXT 0x5702
|
||||
#define MAGIC_VALUE_EXT_5701 0x5701
|
||||
struct {
|
||||
boolean wledEnable = false; //SignalRGB/WLED realtime control of the backlight (wled.ino)
|
||||
boolean wledDarkWithTubes = true; //WLED frames stay dark while the tubes/backlight are off
|
||||
boolean wledUseBrightness = true; //WLED frames are scaled by the RGB brightness (and auto dim)
|
||||
boolean wledWakeAtNight = false; //while WLED frames arrive, the night schedule is ignored (evalShutoffTime())
|
||||
uint16_t magic = MAGIC_VALUE_EXT;
|
||||
} prmExt;
|
||||
static_assert(offsetof(decltype(prmExt), magic) == 4, "prmExt layout changed: MAGIC_VALUE_EXT_5701 migration no longer fits");
|
||||
|
||||
#define EEPROM_SIZE (sizeof(prm) + sizeof(prmExt)) //no extra reserved space for future growth: a change to either struct needs its own magic value bumped
|
||||
|
||||
@@ -1415,6 +1420,10 @@ void handleConfigChanged(AsyncWebServerRequest *request) {
|
||||
else if (key == "wledUseBrightness") {
|
||||
prmExt.wledUseBrightness = (value == "true");
|
||||
}
|
||||
else if (key == "wledWakeAtNight") {
|
||||
prmExt.wledWakeAtNight = (value == "true");
|
||||
evalShutoffTime(); //takes effect now, not at the next second
|
||||
}
|
||||
#endif
|
||||
else if (key == "wifiSsid") {
|
||||
value.toCharArray(prm.wifiSsid,sizeof(prm.wifiSsid));
|
||||
@@ -1653,6 +1662,7 @@ if (useTemp > 1)
|
||||
doc["wledEnable"] = prmExt.wledEnable;
|
||||
doc["wledDarkWithTubes"] = prmExt.wledDarkWithTubes;
|
||||
doc["wledUseBrightness"] = prmExt.wledUseBrightness;
|
||||
doc["wledWakeAtNight"] = prmExt.wledWakeAtNight;
|
||||
#endif
|
||||
doc["wifiMode"] = prm.wifiMode;
|
||||
doc["wifiSsid"] = prm.wifiSsid;
|
||||
@@ -2126,6 +2136,10 @@ void loadEEPROM() {
|
||||
EEPROM.get(EEPROM_addr, prm);
|
||||
DPRINT(" version:"); DPRINTLN(prm.magic);
|
||||
EEPROM.get(EEPROM_addr + sizeof(prm), prmExt);
|
||||
if (prmExt.magic == MAGIC_VALUE_EXT_5701) { //older layout: keep its settings, the new one starts off
|
||||
prmExt.wledWakeAtNight = false;
|
||||
prmExt.magic = MAGIC_VALUE_EXT;
|
||||
}
|
||||
if (prmExt.magic != MAGIC_VALUE_EXT) resetPrmExt();
|
||||
}
|
||||
|
||||
@@ -2134,6 +2148,7 @@ void resetPrmExt() {
|
||||
prmExt.wledEnable = false;
|
||||
prmExt.wledDarkWithTubes = true;
|
||||
prmExt.wledUseBrightness = true;
|
||||
prmExt.wledWakeAtNight = false;
|
||||
prmExt.magic = MAGIC_VALUE_EXT;
|
||||
}
|
||||
|
||||
@@ -2931,7 +2946,7 @@ void evalShutoffTime(void) { // Determine whether tubes should be turned to NI
|
||||
static bool prevShutoffState = true;
|
||||
if ( (((mn_off < mn_on) && (mn >= mn_off) && (mn < mn_on))) || // Nighttime
|
||||
((mn_off > mn_on) && ((mn >= mn_off) || (mn < mn_on)))) {
|
||||
if (!manualOverride) displayON = false;
|
||||
if (!manualOverride) displayON = wledWakesNight(); //SignalRGB frames can keep day mode (wled.ino)
|
||||
if (prevShutoffState == true) manualOverride = false;
|
||||
prevShutoffState = false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user