mirror of https://github.com/arendst/Tasmota.git
Refactor SonoffRfBridge Webcode
This commit is contained in:
parent
9ed8fb717d
commit
4f20e4f698
|
@ -1252,24 +1252,6 @@ void HandleRoot(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // USE_TUYA_MCU
|
#endif // USE_TUYA_MCU
|
||||||
#ifdef USE_SONOFF_RF
|
|
||||||
if (SONOFF_BRIDGE == TasmotaGlobal.module_type) {
|
|
||||||
WSContentSend_P(HTTP_TABLE100);
|
|
||||||
WSContentSend_P(PSTR("<tr>"));
|
|
||||||
uint32_t idx = 0;
|
|
||||||
for (uint32_t i = 0; i < 4; i++) {
|
|
||||||
if (idx > 0) { WSContentSend_P(PSTR("</tr><tr>")); }
|
|
||||||
for (uint32_t j = 0; j < 4; j++) {
|
|
||||||
idx++;
|
|
||||||
snprintf_P(stemp, sizeof(stemp), PSTR("%d"), idx);
|
|
||||||
WSContentSend_P(PSTR("<td style='width:25%%'><button onclick='la(\"&k=%d\");'>%s</button></td>"), idx, // &k is related to WebGetArg("k", tmp, sizeof(tmp));
|
|
||||||
(strlen(SettingsText(SET_BUTTON1 + idx -1))) ? SettingsText(SET_BUTTON1 + idx -1) : stemp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
WSContentSend_P(PSTR("</tr></table>"));
|
|
||||||
}
|
|
||||||
#endif // USE_SONOFF_RF
|
|
||||||
|
|
||||||
#ifndef FIRMWARE_MINIMAL
|
#ifndef FIRMWARE_MINIMAL
|
||||||
XdrvCall(FUNC_WEB_ADD_MAIN_BUTTON);
|
XdrvCall(FUNC_WEB_ADD_MAIN_BUTTON);
|
||||||
XsnsCall(FUNC_WEB_ADD_MAIN_BUTTON);
|
XsnsCall(FUNC_WEB_ADD_MAIN_BUTTON);
|
||||||
|
@ -1405,13 +1387,6 @@ bool HandleRootStatusRefresh(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // USE_SHUTTER
|
#endif // USE_SHUTTER
|
||||||
#ifdef USE_SONOFF_RF
|
|
||||||
WebGetArg(PSTR("k"), tmp, sizeof(tmp)); // 1 - 16 Pre defined RF keys
|
|
||||||
if (strlen(tmp)) {
|
|
||||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_RFKEY "%s"), tmp);
|
|
||||||
ExecuteWebCommand(svalue);
|
|
||||||
}
|
|
||||||
#endif // USE_SONOFF_RF
|
|
||||||
#ifdef USE_ZIGBEE
|
#ifdef USE_ZIGBEE
|
||||||
WebGetArg(PSTR("zbj"), tmp, sizeof(tmp));
|
WebGetArg(PSTR("zbj"), tmp, sizeof(tmp));
|
||||||
if (strlen(tmp)) {
|
if (strlen(tmp)) {
|
||||||
|
|
|
@ -501,6 +501,36 @@ void CmndRfRaw(void)
|
||||||
ResponseCmndStateText(SnfBridge.receive_raw_flag);
|
ResponseCmndStateText(SnfBridge.receive_raw_flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_WEBSERVER
|
||||||
|
|
||||||
|
void SonoffBridgeAddFuctionButtons(void) {
|
||||||
|
WSContentSend_P(HTTP_TABLE100);
|
||||||
|
WSContentSend_P(PSTR("<tr>"));
|
||||||
|
char number[4];
|
||||||
|
uint32_t idx = 0;
|
||||||
|
for (uint32_t i = 0; i < 4; i++) {
|
||||||
|
if (idx > 0) { WSContentSend_P(PSTR("</tr><tr>")); }
|
||||||
|
for (uint32_t j = 0; j < 4; j++) {
|
||||||
|
idx++;
|
||||||
|
WSContentSend_P(PSTR("<td style='width:25%%'><button onclick='la(\"&k=%d\");'>%s</button></td>"), idx, // &k is related to WebGetArg("k", tmp, sizeof(tmp));
|
||||||
|
(strlen(SettingsText(SET_BUTTON1 + idx -1))) ? SettingsText(SET_BUTTON1 + idx -1) : itoa(idx, number, 10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WSContentSend_P(PSTR("</tr></table>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SonoffBridgeWebGetArg(void) {
|
||||||
|
char tmp[8]; // WebGetArg numbers only
|
||||||
|
WebGetArg(PSTR("k"), tmp, sizeof(tmp)); // 1 - 16 Pre defined RF keys
|
||||||
|
if (strlen(tmp)) {
|
||||||
|
char command[20];
|
||||||
|
snprintf_P(command, sizeof(command), PSTR(D_CMND_RFKEY "%s"), tmp);
|
||||||
|
ExecuteWebCommand(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // USE_WEBSERVER
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Interface
|
* Interface
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
@ -518,6 +548,14 @@ bool Xdrv06(uint8_t function)
|
||||||
case FUNC_COMMAND:
|
case FUNC_COMMAND:
|
||||||
result = DecodeCommand(kSonoffBridgeCommands, SonoffBridgeCommand);
|
result = DecodeCommand(kSonoffBridgeCommands, SonoffBridgeCommand);
|
||||||
break;
|
break;
|
||||||
|
#ifdef USE_WEBSERVER
|
||||||
|
case FUNC_WEB_ADD_MAIN_BUTTON:
|
||||||
|
SonoffBridgeAddFuctionButtons();
|
||||||
|
break;
|
||||||
|
case FUNC_WEB_GET_ARG:
|
||||||
|
SonoffBridgeWebGetArg();
|
||||||
|
break;
|
||||||
|
#endif // USE_WEBSERVER
|
||||||
case FUNC_INIT:
|
case FUNC_INIT:
|
||||||
SnfBridge.receive_raw_flag = 0;
|
SnfBridge.receive_raw_flag = 0;
|
||||||
SonoffBridgeSendCommand(0xA7); // Stop reading RF signals enabling iTead default RF handling
|
SonoffBridgeSendCommand(0xA7); // Stop reading RF signals enabling iTead default RF handling
|
||||||
|
|
|
@ -249,8 +249,6 @@ void LscMcModuleSelected(void) {
|
||||||
#ifdef USE_LSC_MCSL_GUI
|
#ifdef USE_LSC_MCSL_GUI
|
||||||
|
|
||||||
void LscMcAddFuctionButtons(void) {
|
void LscMcAddFuctionButtons(void) {
|
||||||
char number[4];
|
|
||||||
|
|
||||||
uint32_t rows = 1;
|
uint32_t rows = 1;
|
||||||
uint32_t cols = 8;
|
uint32_t cols = 8;
|
||||||
for (uint32_t i = 0; i < 8; i++) {
|
for (uint32_t i = 0; i < 8; i++) {
|
||||||
|
@ -262,6 +260,7 @@ void LscMcAddFuctionButtons(void) {
|
||||||
}
|
}
|
||||||
WSContentSend_P(HTTP_TABLE100);
|
WSContentSend_P(HTTP_TABLE100);
|
||||||
WSContentSend_P(PSTR("<tr>"));
|
WSContentSend_P(PSTR("<tr>"));
|
||||||
|
char number[4];
|
||||||
uint32_t idx = 0;
|
uint32_t idx = 0;
|
||||||
for (uint32_t i = 0; i < rows; i++) {
|
for (uint32_t i = 0; i < rows; i++) {
|
||||||
if (idx > 0) { WSContentSend_P(PSTR("</tr><tr>")); }
|
if (idx > 0) { WSContentSend_P(PSTR("</tr><tr>")); }
|
||||||
|
@ -278,10 +277,10 @@ void LscMcAddFuctionButtons(void) {
|
||||||
|
|
||||||
void LscMcWebGetArg(void) {
|
void LscMcWebGetArg(void) {
|
||||||
char tmp[8]; // WebGetArg numbers only
|
char tmp[8]; // WebGetArg numbers only
|
||||||
char command[20];
|
|
||||||
WebGetArg(PSTR("lsc"), tmp, sizeof(tmp)); // 0 - 7 functions
|
WebGetArg(PSTR("lsc"), tmp, sizeof(tmp)); // 0 - 7 functions
|
||||||
if (strlen(tmp)) {
|
if (strlen(tmp)) {
|
||||||
uint32_t function = atoi(tmp);
|
uint32_t function = atoi(tmp);
|
||||||
|
char command[20];
|
||||||
snprintf_P(command, sizeof(command), PSTR(D_CMND_DIMMER " %d"), (function * (100 / 8)) + ((100 / 8) / 2));
|
snprintf_P(command, sizeof(command), PSTR(D_CMND_DIMMER " %d"), (function * (100 / 8)) + ((100 / 8) / 2));
|
||||||
ExecuteWebCommand(command);
|
ExecuteWebCommand(command);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue