mirror of
https://github.com/wled/WLED.git
synced 2025-07-25 11:46:34 +00:00
Minor changes in PIR usermod.
This commit is contained in:
parent
04aa22b510
commit
90516217e0
@ -250,50 +250,53 @@ public:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
uiDomString += "true";
|
uiDomString += "true";
|
||||||
sensorStateInfo = "Disabled !";
|
sensorStateInfo = "Disabled!";
|
||||||
}
|
}
|
||||||
uiDomString += "});return false;\">";
|
uiDomString += "});return false;\">";
|
||||||
uiDomString += sensorStateInfo;
|
uiDomString += sensorStateInfo;
|
||||||
uiDomString += "</button>";
|
uiDomString += "</button>";
|
||||||
infoArr.add(uiDomString); //value
|
infoArr.add(uiDomString); //value
|
||||||
|
|
||||||
//this code adds "u":{"⏲ switch off timer":uiDomString} to the info object
|
if (m_PIRenabled)
|
||||||
uiDomString = "<i class=\"icons\"></i> switch off timer<span style=\"display:block;padding-left:25px;\">\
|
{
|
||||||
|
//this code adds "u":{"⏲ switch off timer":uiDomString} to the info object
|
||||||
|
uiDomString = "<i class=\"icons\"></i> switch off timer<span style=\"display:block;padding-left:25px;\">\
|
||||||
after <input type=\"number\" min=\"1\" max=\"720\" value=\"";
|
after <input type=\"number\" min=\"1\" max=\"720\" value=\"";
|
||||||
uiDomString += (m_switchOffDelay / 60000);
|
uiDomString += (m_switchOffDelay / 60000);
|
||||||
uiDomString += "\" onchange=\"requestJson({PIRoffSec:parseInt(this.value)*60});\">min</span>";
|
uiDomString += "\" onchange=\"requestJson({PIRoffSec:parseInt(this.value)*60});\">min</span>";
|
||||||
infoArr = user.createNestedArray(uiDomString); //name
|
infoArr = user.createNestedArray(uiDomString); //name
|
||||||
|
|
||||||
// off timer
|
// off timer
|
||||||
if (m_offTimerStart > 0)
|
if (m_offTimerStart > 0)
|
||||||
{
|
|
||||||
uiDomString = "";
|
|
||||||
unsigned int offSeconds = (m_switchOffDelay - (millis() - m_offTimerStart)) / 1000;
|
|
||||||
if (offSeconds >= 3600)
|
|
||||||
{
|
{
|
||||||
uiDomString += (offSeconds / 3600);
|
uiDomString = "";
|
||||||
uiDomString += " hours ";
|
unsigned int offSeconds = (m_switchOffDelay - (millis() - m_offTimerStart)) / 1000;
|
||||||
offSeconds %= 3600;
|
if (offSeconds >= 3600)
|
||||||
|
{
|
||||||
|
uiDomString += (offSeconds / 3600);
|
||||||
|
uiDomString += " hours ";
|
||||||
|
offSeconds %= 3600;
|
||||||
|
}
|
||||||
|
if (offSeconds >= 60)
|
||||||
|
{
|
||||||
|
uiDomString += (offSeconds / 60);
|
||||||
|
offSeconds %= 60;
|
||||||
|
}
|
||||||
|
else if (uiDomString.length() > 0)
|
||||||
|
{
|
||||||
|
uiDomString += 0;
|
||||||
|
}
|
||||||
|
if (uiDomString.length() > 0)
|
||||||
|
{
|
||||||
|
uiDomString += " min ";
|
||||||
|
}
|
||||||
|
uiDomString += (offSeconds);
|
||||||
|
infoArr.add(uiDomString + " sec");
|
||||||
}
|
}
|
||||||
if (offSeconds >= 60)
|
else
|
||||||
{
|
{
|
||||||
uiDomString += (offSeconds / 60);
|
infoArr.add("inactive");
|
||||||
offSeconds %= 60;
|
|
||||||
}
|
}
|
||||||
else if (uiDomString.length() > 0)
|
|
||||||
{
|
|
||||||
uiDomString += 0;
|
|
||||||
}
|
|
||||||
if (uiDomString.length() > 0)
|
|
||||||
{
|
|
||||||
uiDomString += " min ";
|
|
||||||
}
|
|
||||||
uiDomString += (offSeconds);
|
|
||||||
infoArr.add(uiDomString + " sec");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
infoArr.add("inactive");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,9 +326,9 @@ after <input type=\"number\" min=\"1\" max=\"720\" value=\"";
|
|||||||
m_updateConfig = true;
|
m_updateConfig = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root[F("pin")] != nullptr)
|
if (root["pin"] != nullptr)
|
||||||
{
|
{
|
||||||
int8_t pin = (int)root[F("pin")];
|
int8_t pin = (int)root["pin"];
|
||||||
// check if pin is OK
|
// check if pin is OK
|
||||||
if (pin != PIRsensorPin && pin>=0 && pinManager.allocatePin(pin,false)) {
|
if (pin != PIRsensorPin && pin>=0 && pinManager.allocatePin(pin,false)) {
|
||||||
// deallocate old pin
|
// deallocate old pin
|
||||||
@ -379,8 +382,8 @@ after <input type=\"number\" min=\"1\" max=\"720\" value=\"";
|
|||||||
void readFromConfig(JsonObject &root)
|
void readFromConfig(JsonObject &root)
|
||||||
{
|
{
|
||||||
JsonObject top = root[F("PIRsensorSwitch")];
|
JsonObject top = root[F("PIRsensorSwitch")];
|
||||||
if (!top.isNull() && top[F("pin")] != nullptr) {
|
if (!top.isNull() && top["pin"] != nullptr) {
|
||||||
PIRsensorPin = (int)top[F("pin")];
|
PIRsensorPin = (int)top["pin"];
|
||||||
}
|
}
|
||||||
m_PIRenabled = (top[F("PIRenabled")] != nullptr ? top[F("PIRenabled")] : true);
|
m_PIRenabled = (top[F("PIRenabled")] != nullptr ? top[F("PIRenabled")] : true);
|
||||||
m_switchOffDelay = top[F("PIRoffSec")] | m_switchOffDelay;
|
m_switchOffDelay = top[F("PIRoffSec")] | m_switchOffDelay;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user