mirror of
https://github.com/arendst/Tasmota.git
synced 2025-08-09 19:07:43 +00:00
Refactor WebSensor
Refactor WebSensor
This commit is contained in:
parent
9746489380
commit
c61f2cc5ec
@ -324,6 +324,7 @@
|
||||
#define D_CMND_WEBREFRESH "WebRefresh"
|
||||
#define D_CMND_WEBSEND "WebSend"
|
||||
#define D_CMND_WEBCOLOR "WebColor"
|
||||
#define D_CMND_WEBSENSOR "WebSensor"
|
||||
#define D_CMND_EMULATION "Emulation"
|
||||
|
||||
// Commands xdrv_03_energy.ino
|
||||
|
@ -30,7 +30,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
|
||||
#ifdef USE_I2C
|
||||
D_CMND_I2CSCAN "|"
|
||||
#endif
|
||||
D_CMND_SENSOR "|" D_CMND_DRIVER "|WebSensor";
|
||||
D_CMND_SENSOR "|" D_CMND_DRIVER;
|
||||
|
||||
void (* const TasmotaCommand[])(void) PROGMEM = {
|
||||
&CmndBacklog, &CmndDelay, &CmndPower, &CmndStatus, &CmndState, &CmndSleep, &CmndUpgrade, &CmndUpgrade, &CmndOtaUrl,
|
||||
@ -45,7 +45,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = {
|
||||
#ifdef USE_I2C
|
||||
&CmndI2cScan,
|
||||
#endif
|
||||
&CmndSensor, &CmndDriver, &CmndWebSensor };
|
||||
&CmndSensor, &CmndDriver };
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
@ -662,16 +662,6 @@ void CmndSetoption(void)
|
||||
}
|
||||
}
|
||||
|
||||
void CmndWebSensor(void)
|
||||
{
|
||||
if (XdrvMailbox.index < MAX_XSNS_DRIVERS) {
|
||||
if (XdrvMailbox.payload >= 0) {
|
||||
bitWrite(Settings.sensors[XdrvMailbox.index / 32], XdrvMailbox.index % 32, XdrvMailbox.payload &1);
|
||||
}
|
||||
ResponseCmndIdxChar(GetStateText(bitRead(Settings.sensors[XdrvMailbox.index / 32], XdrvMailbox.index % 32)));
|
||||
}
|
||||
}
|
||||
|
||||
void CmndTemperatureResolution(void)
|
||||
{
|
||||
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 3)) {
|
||||
|
@ -2460,13 +2460,13 @@ const char kWebCommands[] PROGMEM = "|" // No prefix
|
||||
#ifdef USE_EMULATION
|
||||
D_CMND_EMULATION "|"
|
||||
#endif
|
||||
D_CMND_WEBSERVER "|" D_CMND_WEBPASSWORD "|" D_CMND_WEBLOG "|" D_CMND_WEBREFRESH "|" D_CMND_WEBSEND "|" D_CMND_WEBCOLOR ;
|
||||
D_CMND_WEBSERVER "|" D_CMND_WEBPASSWORD "|" D_CMND_WEBLOG "|" D_CMND_WEBREFRESH "|" D_CMND_WEBSEND "|" D_CMND_WEBCOLOR "|" D_CMND_WEBSENSOR;
|
||||
|
||||
void (* const WebCommand[])(void) PROGMEM = {
|
||||
#ifdef USE_EMULATION
|
||||
&CmndEmulation,
|
||||
#endif
|
||||
&CmndWebServer, &CmndWebPassword, &CmndWeblog, &CmndWebRefresh, &CmndWebSend, &CmndWebColor };
|
||||
&CmndWebServer, &CmndWebPassword, &CmndWeblog, &CmndWebRefresh, &CmndWebSend, &CmndWebColor, &CmndWebSensor };
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Commands
|
||||
@ -2563,6 +2563,16 @@ void CmndWebColor(void)
|
||||
ResponseAppend_P(PSTR("]}"));
|
||||
}
|
||||
|
||||
void CmndWebSensor(void)
|
||||
{
|
||||
if (XdrvMailbox.index < MAX_XSNS_DRIVERS) {
|
||||
if (XdrvMailbox.payload >= 0) {
|
||||
bitWrite(Settings.sensors[XdrvMailbox.index / 32], XdrvMailbox.index % 32, XdrvMailbox.payload &1);
|
||||
}
|
||||
ResponseCmndIdxChar(GetStateText(bitRead(Settings.sensors[XdrvMailbox.index / 32], XdrvMailbox.index % 32)));
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
\*********************************************************************************************/
|
||||
|
@ -813,6 +813,8 @@ const uint8_t kXsnsList[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
||||
bool XsnsEnabled(uint32_t sns_index)
|
||||
{
|
||||
if (sns_index < sizeof(kXsnsList)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user