mirror of https://github.com/arendst/Tasmota.git
Merge pull request #7464 from to-scho/hotfix/shutterbutton_webbuttons
Fix labeling of web buttons for shutters
This commit is contained in:
commit
49607b9747
|
@ -502,6 +502,8 @@
|
||||||
#define D_CMND_SHUTTER_CLOSE "Close"
|
#define D_CMND_SHUTTER_CLOSE "Close"
|
||||||
#define D_CMND_SHUTTER_UP "Up"
|
#define D_CMND_SHUTTER_UP "Up"
|
||||||
#define D_CMND_SHUTTER_DOWN "Down"
|
#define D_CMND_SHUTTER_DOWN "Down"
|
||||||
|
#define D_CMND_SHUTTER_TOGGLEUP "ToggleUp"
|
||||||
|
#define D_CMND_SHUTTER_TOGGLEDOWN "ToggleDown"
|
||||||
#define D_CMND_SHUTTER_STOP "Stop"
|
#define D_CMND_SHUTTER_STOP "Stop"
|
||||||
#define D_CMND_SHUTTER_POSITION "Position"
|
#define D_CMND_SHUTTER_POSITION "Position"
|
||||||
#define D_CMND_SHUTTER_OPENTIME "OpenDuration"
|
#define D_CMND_SHUTTER_OPENTIME "OpenDuration"
|
||||||
|
|
|
@ -1120,20 +1120,12 @@ void HandleRoot(void)
|
||||||
for (uint32_t idx = 1; idx <= devices_present; idx++) {
|
for (uint32_t idx = 1; idx <= devices_present; idx++) {
|
||||||
bool set_button = ((idx <= MAX_BUTTON_TEXT) && strlen(SettingsText(SET_BUTTON1 + idx -1)));
|
bool set_button = ((idx <= MAX_BUTTON_TEXT) && strlen(SettingsText(SET_BUTTON1 + idx -1)));
|
||||||
#ifdef USE_SHUTTER
|
#ifdef USE_SHUTTER
|
||||||
if (Settings.flag3.shutter_mode) { // SetOption80 - Enable shutter support
|
int32_t ShutterWebButton;
|
||||||
bool shutter_used = false;
|
if (ShutterWebButton = IsShutterWebButton(idx)) {
|
||||||
for (uint32_t i = 0; i < MAX_SHUTTERS; i++) {
|
WSContentSend_P(HTTP_DEVICE_CONTROL, 100 / devices_present, idx,
|
||||||
if (Settings.shutter_startrelay[i] == (((idx -1) & 0xFFFFFFFE) +1)) {
|
(set_button) ? SettingsText(SET_BUTTON1 + idx -1) : (ShutterWebButton>0) ? "▲" : "▼",
|
||||||
shutter_used = true;
|
"");
|
||||||
break;
|
continue;
|
||||||
}
|
|
||||||
}
|
|
||||||
if (shutter_used) {
|
|
||||||
WSContentSend_P(HTTP_DEVICE_CONTROL, 100 / devices_present, idx,
|
|
||||||
(set_button) ? SettingsText(SET_BUTTON1 + idx -1) : (idx % 2) ? "▲" : "▼",
|
|
||||||
"");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif // USE_SHUTTER
|
#endif // USE_SHUTTER
|
||||||
snprintf_P(stemp, sizeof(stemp), PSTR(" %d"), idx);
|
snprintf_P(stemp, sizeof(stemp), PSTR(" %d"), idx);
|
||||||
|
@ -1216,7 +1208,18 @@ bool HandleRootStatusRefresh(void)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#endif // USE_SONOFF_IFAN
|
#endif // USE_SONOFF_IFAN
|
||||||
ExecuteCommandPower(device, POWER_TOGGLE, SRC_IGNORE);
|
#ifdef USE_SHUTTER
|
||||||
|
int32_t ShutterWebButton;
|
||||||
|
if (ShutterWebButton = IsShutterWebButton(device)) {
|
||||||
|
snprintf_P(svalue, sizeof(svalue), PSTR("ShutterPosition%d %s"), abs(ShutterWebButton), (ShutterWebButton>0) ? PSTR(D_CMND_SHUTTER_TOGGLEUP) : PSTR(D_CMND_SHUTTER_TOGGLEDOWN));
|
||||||
|
AddLog_P2(LOG_LEVEL_INFO, PSTR("SHT: WebButton %d, %s"), ShutterWebButton, svalue);
|
||||||
|
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||||
|
} else {
|
||||||
|
#endif // USE_SHUTTER
|
||||||
|
ExecuteCommandPower(device, POWER_TOGGLE, SRC_IGNORE);
|
||||||
|
#ifdef USE_SHUTTER
|
||||||
|
}
|
||||||
|
#endif // USE_SHUTTER
|
||||||
#ifdef USE_SONOFF_IFAN
|
#ifdef USE_SONOFF_IFAN
|
||||||
}
|
}
|
||||||
#endif // USE_SONOFF_IFAN
|
#endif // USE_SONOFF_IFAN
|
||||||
|
@ -1301,6 +1304,22 @@ bool HandleRootStatusRefresh(void)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_SHUTTER
|
||||||
|
int32_t IsShutterWebButton(uint32_t idx) {
|
||||||
|
/* 0: Not a shutter, 1..4: shutter up idx, -1..-4: shutter down idx */
|
||||||
|
int32_t ShutterWebButton = 0;
|
||||||
|
if (Settings.flag3.shutter_mode) { // SetOption80 - Enable shutter support
|
||||||
|
for (uint32_t i = 0; i < MAX_SHUTTERS; i++) {
|
||||||
|
if (Settings.shutter_startrelay[i] && ((Settings.shutter_startrelay[i] == idx) || (Settings.shutter_startrelay[i] == (idx-1)))) {
|
||||||
|
ShutterWebButton = (Settings.shutter_startrelay[i] == idx) ? (i+1): (-1-i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ShutterWebButton;
|
||||||
|
}
|
||||||
|
#endif // USE_SHUTTER
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef FIRMWARE_MINIMAL
|
#ifndef FIRMWARE_MINIMAL
|
||||||
|
|
|
@ -667,15 +667,15 @@ void CmndShutterPosition(void)
|
||||||
// value 0 with data_len > 0 can mean Open
|
// value 0 with data_len > 0 can mean Open
|
||||||
if ((XdrvMailbox.data_len > 1) && (XdrvMailbox.payload <= 0)) {
|
if ((XdrvMailbox.data_len > 1) && (XdrvMailbox.payload <= 0)) {
|
||||||
//UpperCase(XdrvMailbox.data, XdrvMailbox.data);
|
//UpperCase(XdrvMailbox.data, XdrvMailbox.data);
|
||||||
if (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_UP) || !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_OPEN)) {
|
if (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_UP) || !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_OPEN) || ((Shutter.direction[index]==0) && !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_TOGGLEUP))) {
|
||||||
CmndShutterOpen();
|
CmndShutterOpen();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_DOWN) || !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_CLOSE)) {
|
if (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_DOWN) || !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_CLOSE) || ((Shutter.direction[index]==0) && !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_TOGGLEDOWN))) {
|
||||||
CmndShutterClose();
|
CmndShutterClose();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOP)) {
|
if (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_STOP) || ((Shutter.direction[index]) && (!strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_TOGGLEUP) || !strcasecmp(XdrvMailbox.data,D_CMND_SHUTTER_TOGGLEDOWN)))) {
|
||||||
XdrvMailbox.payload = -99;
|
XdrvMailbox.payload = -99;
|
||||||
CmndShutterStop();
|
CmndShutterStop();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue