mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 21:26:43 +00:00
Fix light bug
This commit is contained in:
parent
6299927121
commit
94cf2c18aa
@ -11,7 +11,6 @@
|
|||||||
LV_FONT_DECLARE(unscii_8_icon);
|
LV_FONT_DECLARE(unscii_8_icon);
|
||||||
extern lv_font_t * haspFonts[8];
|
extern lv_font_t * haspFonts[8];
|
||||||
|
|
||||||
static bool is_true(const char * s);
|
|
||||||
static inline bool only_digits(const char * s);
|
static inline bool only_digits(const char * s);
|
||||||
|
|
||||||
/* 16-bit hashing function http://www.cse.yorku.ca/~oz/hash.html */
|
/* 16-bit hashing function http://www.cse.yorku.ca/~oz/hash.html */
|
||||||
@ -909,12 +908,6 @@ void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char
|
|||||||
/* **************************
|
/* **************************
|
||||||
* Static Inline functions
|
* Static Inline functions
|
||||||
* **************************/
|
* **************************/
|
||||||
static bool is_true(const char * s)
|
|
||||||
{
|
|
||||||
return (!strcasecmp_P(s, PSTR("true")) || !strcasecmp_P(s, PSTR("on")) || !strcasecmp_P(s, PSTR("yes")) ||
|
|
||||||
!strcmp_P(s, PSTR("1")));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool only_digits(const char * s)
|
static inline bool only_digits(const char * s)
|
||||||
{
|
{
|
||||||
size_t digits = 0;
|
size_t digits = 0;
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
#include "hasp_hal.h"
|
#include "hasp_hal.h"
|
||||||
#include "hasp.h"
|
#include "hasp.h"
|
||||||
|
|
||||||
inline bool isON(const char * payload)
|
bool is_true(const char * s)
|
||||||
{
|
{
|
||||||
return strcasecmp_P(payload, PSTR("ON")) == 0;
|
return (!strcasecmp_P(s, PSTR("true")) || !strcasecmp_P(s, PSTR("on")) || !strcasecmp_P(s, PSTR("yes")) ||
|
||||||
|
!strcmp_P(s, PSTR("1")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispatchSetup()
|
void dispatchSetup()
|
||||||
@ -71,7 +72,7 @@ void dispatchGpioOutput(String strTopic, const char * payload)
|
|||||||
String strTemp((char *)0);
|
String strTemp((char *)0);
|
||||||
strTemp.reserve(128);
|
strTemp.reserve(128);
|
||||||
strTemp = strTopic.substring(7, strTopic.length());
|
strTemp = strTopic.substring(7, strTopic.length());
|
||||||
dispatchGpioOutput(strTemp.toInt(), isON(payload));
|
dispatchGpioOutput(strTemp.toInt(), is_true(payload));
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispatchParseJson(char * payload)
|
void dispatchParseJson(char * payload)
|
||||||
@ -311,15 +312,18 @@ void dispatchBacklight(const char * payload)
|
|||||||
// dispatchPrintln(F("LIGHT"), strPayload);
|
// dispatchPrintln(F("LIGHT"), strPayload);
|
||||||
|
|
||||||
// Set the current state
|
// Set the current state
|
||||||
if(strlen(payload) != 0) guiSetBacklight(isON(payload));
|
if(strlen(payload) != 0) guiSetBacklight(is_true(payload));
|
||||||
|
|
||||||
// Return the current state
|
// Return the current state
|
||||||
|
char buffer[4];
|
||||||
|
memcpy_P(buffer, guiGetBacklight() ? PSTR("ON") : PSTR("OFF"), sizeof(buffer));
|
||||||
|
|
||||||
#if HASP_USE_MQTT > 0
|
#if HASP_USE_MQTT > 0
|
||||||
mqtt_send_state(F("light"), guiGetBacklight() ? PSTR("ON") : PSTR("OFF"));
|
mqtt_send_state(F("light"), buffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HASP_USE_TASMOTA_SLAVE > 0
|
#if HASP_USE_TASMOTA_SLAVE > 0
|
||||||
slave_send_state(F("light"), guiGetBacklight() ? PSTR("ON") : PSTR("OFF"));
|
slave_send_state(F("light"), buffer);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#define LOG_CMND_CTR "CMND: "
|
#define LOG_CMND_CTR "CMND: "
|
||||||
|
|
||||||
|
bool is_true(const char * s);
|
||||||
|
|
||||||
void dispatchSetup(void);
|
void dispatchSetup(void);
|
||||||
void dispatchLoop(void);
|
void dispatchLoop(void);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user