mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 11:46:31 +00:00
Update xdrv_27_shutter.ino
This commit is contained in:
parent
c98164a400
commit
d2472ef56f
@ -1378,27 +1378,25 @@ void CmndShutterMode(void)
|
|||||||
|
|
||||||
void CmndShutterRelay(void)
|
void CmndShutterRelay(void)
|
||||||
{
|
{
|
||||||
if (!XdrvMailbox.usridx && !XdrvMailbox.data_len) {
|
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 64) && (XdrvMailbox.index <= MAX_SHUTTERS)) {
|
||||||
// {"ShutterRelay1":"1","ShutterRelay2":"3","ShutterRelay3":"5"}
|
Settings->shutter_startrelay[XdrvMailbox.index -1] = XdrvMailbox.payload;
|
||||||
Response_P(PSTR("{"));
|
if (XdrvMailbox.payload > 0) {
|
||||||
for (uint32_t i = 0; i < TasmotaGlobal.shutters_present; i++) {
|
ShutterGlobal.RelayShutterMask |= 3 << (XdrvMailbox.payload - 1);
|
||||||
ResponseAppend_P(PSTR("%s\"" D_PRFX_SHUTTER D_CMND_SHUTTER_RELAY "%d\":\"%d\""), (i)?",":"", i+1,Settings->shutter_startrelay[i]);
|
} else {
|
||||||
|
ShutterGlobal.RelayShutterMask ^= 3 << (Settings->shutter_startrelay[XdrvMailbox.index -1] - 1);
|
||||||
}
|
}
|
||||||
ResponseAppend_P(PSTR("}"));
|
Settings->shutter_startrelay[XdrvMailbox.index -1] = XdrvMailbox.payload;
|
||||||
} else if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_SHUTTERS)) {
|
ShutterInit();
|
||||||
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 64)) {
|
// if payload is 0 to disable the relay there must be a reboot. Otherwhise does not work
|
||||||
Settings->shutter_startrelay[XdrvMailbox.index -1] = XdrvMailbox.payload;
|
|
||||||
if (XdrvMailbox.payload > 0) {
|
|
||||||
ShutterGlobal.RelayShutterMask |= 3 << (XdrvMailbox.payload - 1);
|
|
||||||
} else {
|
|
||||||
ShutterGlobal.RelayShutterMask ^= 3 << (Settings->shutter_startrelay[XdrvMailbox.index -1] - 1);
|
|
||||||
}
|
|
||||||
Settings->shutter_startrelay[XdrvMailbox.index -1] = XdrvMailbox.payload;
|
|
||||||
ShutterInit();
|
|
||||||
// if payload is 0 to disable the relay there must be a reboot. Otherwhise does not work
|
|
||||||
}
|
|
||||||
ResponseCmndIdxNumber(Settings->shutter_startrelay[XdrvMailbox.index -1]);
|
|
||||||
}
|
}
|
||||||
|
uint32_t start = (!XdrvMailbox.usridx && !XdrvMailbox.data_len)?0:XdrvMailbox.index -1;
|
||||||
|
uint32_t end = (!XdrvMailbox.usridx && !XdrvMailbox.data_len)?TasmotaGlobal.shutters_present:XdrvMailbox.index;
|
||||||
|
// {"ShutterRelay1":"1","ShutterRelay2":"3","ShutterRelay3":"5"}
|
||||||
|
Response_P(PSTR("{"));
|
||||||
|
for (uint32_t i = start; i < end; i++) {
|
||||||
|
ResponseAppend_P(PSTR("%s\"" D_PRFX_SHUTTER D_CMND_SHUTTER_RELAY "%d\":\"%d\""), (i)?",":"", i+1,Settings->shutter_startrelay[i]);
|
||||||
|
}
|
||||||
|
ResponseAppend_P(PSTR("}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmndShutterButton(void)
|
void CmndShutterButton(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user