Sync bugfix (preset, playlist)

PIR sensor bugfix.
This commit is contained in:
Blaz Kristan 2022-01-08 23:53:55 +01:00
parent 7a4ed5a337
commit 7df4b8e8cc
3 changed files with 12 additions and 12 deletions

View File

@ -58,7 +58,6 @@ private:
byte prevPreset = 0; byte prevPreset = 0;
byte prevPlaylist = 0; byte prevPlaylist = 0;
bool savedState = false;
uint32_t offTimerStart = 0; // off timer start time uint32_t offTimerStart = 0; // off timer start time
byte NotifyUpdateMode = CALL_MODE_NO_NOTIFY; // notification mode for colorUpdated(): CALL_MODE_NO_NOTIFY or CALL_MODE_DIRECT_CHANGE byte NotifyUpdateMode = CALL_MODE_NO_NOTIFY; // notification mode for colorUpdated(): CALL_MODE_NO_NOTIFY or CALL_MODE_DIRECT_CHANGE
@ -77,6 +76,7 @@ private:
bool m_mqttOnly = false; // flag to send MQTT message only (assuming it is enabled) bool m_mqttOnly = false; // flag to send MQTT message only (assuming it is enabled)
// flag to enable triggering only if WLED is initially off (LEDs are not on, preventing running effect being overwritten by PIR) // flag to enable triggering only if WLED is initially off (LEDs are not on, preventing running effect being overwritten by PIR)
bool m_offOnly = false; bool m_offOnly = false;
bool m_offMode = offMode;
// strings to reduce flash memory usage (used more than twice) // strings to reduce flash memory usage (used more than twice)
static const char _name[]; static const char _name[];
@ -123,13 +123,15 @@ private:
PIRtriggered = switchOn; PIRtriggered = switchOn;
if (switchOn) { if (switchOn) {
if (m_onPreset) { if (m_onPreset) {
if (currentPlaylist>0) prevPlaylist = currentPlaylist; if (currentPlaylist>0 && !offMode) {
else if (currentPreset>0) prevPreset = currentPreset; prevPlaylist = currentPlaylist;
else { unloadPlaylist();
} else if (currentPreset>0 && !offMode) {
prevPreset = currentPreset;
} else {
saveTemporaryPreset(); saveTemporaryPreset();
savedState = true;
prevPlaylist = 0; prevPlaylist = 0;
prevPreset = 0; prevPreset = 255;
} }
applyPreset(m_onPreset, NotifyUpdateMode); applyPreset(m_onPreset, NotifyUpdateMode);
return; return;
@ -148,13 +150,10 @@ private:
prevPlaylist = 0; prevPlaylist = 0;
return; return;
} else if (prevPreset) { } else if (prevPreset) {
applyPreset(prevPreset, NotifyUpdateMode); if (prevPreset<255) applyPreset(prevPreset, NotifyUpdateMode);
else applyTemporaryPreset();
prevPreset = 0; prevPreset = 0;
return; return;
} else if (savedState) {
applyTemporaryPreset();
savedState = false;
return;
} }
// preset not assigned // preset not assigned
if (bri != 0) { if (bri != 0) {

View File

@ -63,6 +63,7 @@ void handlePresets()
if (!errorFlag && presetToApply < 255) currentPreset = presetToApply; if (!errorFlag && presetToApply < 255) currentPreset = presetToApply;
effectChanged = true; //force UDP notification
colorUpdated(callModeToApply); colorUpdated(callModeToApply);
updateInterfaces(callModeToApply); updateInterfaces(callModeToApply);

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2201081 #define VERSION 2201091
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG