diff --git a/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h b/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h index 19fcc2a9..ab29ea24 100644 --- a/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h +++ b/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h @@ -69,11 +69,16 @@ private: bool m_PIRenabled = true; // status of initialisation bool initDone = false; + // on and off presets + uint8_t m_onPreset = 0; + uint8_t m_offPreset = 0; // strings to reduce flash memory usage (used more than twice) static const char _name[]; static const char _switchOffDelay[]; static const char _enabled[]; + static const char _onPreset[]; + static const char _offPreset[]; /** * return or change if new PIR sensor state is available @@ -90,13 +95,14 @@ private: */ void switchStrip(bool switchOn) { - if (switchOn && bri == 0) - { + if (switchOn && m_onPreset) { + applyPreset(m_onPreset); + } else if (!switchOn && m_offPreset) { + applyPreset(m_offPreset); + } else if (switchOn && bri == 0) { bri = briLast; colorUpdated(NotifyUpdateMode); - } - else if (!switchOn && bri != 0) - { + } else if (!switchOn && bri != 0) { briLast = bri; bri = 0; colorUpdated(NotifyUpdateMode); @@ -341,6 +347,8 @@ public: top[FPSTR(_enabled)] = m_PIRenabled; top[FPSTR(_switchOffDelay)] = m_switchOffDelay / 1000; top["pin"] = PIRsensorPin; + top[FPSTR(_onPreset)] = m_onPreset; + top[FPSTR(_offPreset)] = m_offPreset; DEBUG_PRINTLN(F("PIR config saved.")); } @@ -374,6 +382,14 @@ public: m_switchOffDelay = (top[FPSTR(_switchOffDelay)].as() * 1000); } + if (top[FPSTR(_onPreset)] != nullptr) { + m_onPreset = max(0,min(250,top[FPSTR(_onPreset)].as())); + } + + if (top[FPSTR(_offPreset)] != nullptr) { + m_offPreset = max(0,min(250,top[FPSTR(_offPreset)].as())); + } + if (!initDone) { // reading config prior to setup() DEBUG_PRINTLN(F("PIR config loaded.")); @@ -437,3 +453,5 @@ void IRAM_ATTR PIRsensorSwitch::ISR_PIRstateChange() const char PIRsensorSwitch::_name[] PROGMEM = "PIRsensorSwitch"; const char PIRsensorSwitch::_enabled[] PROGMEM = "PIRenabled"; const char PIRsensorSwitch::_switchOffDelay[] PROGMEM = "PIRoffSec"; +const char PIRsensorSwitch::_onPreset[] PROGMEM = "on-preset"; +const char PIRsensorSwitch::_offPreset[] PROGMEM = "off-preset"; diff --git a/usermods/Temperature/usermod_temperature.h b/usermods/Temperature/usermod_temperature.h index 8c639ae5..298a8177 100644 --- a/usermods/Temperature/usermod_temperature.h +++ b/usermods/Temperature/usermod_temperature.h @@ -1,8 +1,6 @@ #pragma once #include "wled.h" - -//#include //DS18B20 #include "OneWire.h" //Pin defaults for QuinLed Dig-Uno if not overriden diff --git a/usermods/multi_relay/usermod_multi_relay.h b/usermods/multi_relay/usermod_multi_relay.h index 8d2861ba..7caff19f 100644 --- a/usermods/multi_relay/usermod_multi_relay.h +++ b/usermods/multi_relay/usermod_multi_relay.h @@ -281,7 +281,7 @@ class MultiRelay : public Usermod { * loop() is called continuously. Here you can check for events, read sensors, etc. */ void loop() { - if (!enabled) return; + if (!enabled || strip.isUpdating()) return; static unsigned long lastUpdate = 0; if (millis() - lastUpdate < 200) return; // update only 5 times/s diff --git a/wled00/data/settings_um.htm b/wled00/data/settings_um.htm index 215d7eb2..3c8ec7d6 100644 --- a/wled00/data/settings_um.htm +++ b/wled00/data/settings_um.htm @@ -99,8 +99,12 @@ urows += `

${k}

`; addField(k,'unknown',o); } - gId("um").innerHTML = urows; + if (urows==="") + urows = "No Usermods configuration found.
Press Save to initialize defaults."; + } else { + urows = "Usermods configuration not found.
Most likely no Usermods exist.
Press Save to initialize defaults."; } + gId("um").innerHTML = urows; }) .catch(function (error) { gId('lserr').style.display = "inline" diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 58d865cb..113ef758 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -395,7 +395,7 @@ type="submit">Save & Reboot)====="; // Autogenerated from wled00/data/settings_um.htm, do not edit!! const char PAGE_settings_um[] PROGMEM = R"=====(UI Settings%CSS%%SCSS%