Add object_set_normalized_group_value

This commit is contained in:
fvanroie 2021-03-18 23:16:55 +01:00
parent a5d19a2283
commit 7e588181b8
3 changed files with 17 additions and 12 deletions

View File

@ -250,8 +250,13 @@ void dispatch_command(const char* topic, const char* payload)
/* =============================== Not standard payload commands ===================================== */
if(strlen(topic) == 7 && topic == strstr_P(topic, PSTR("output"))) {
if(strlen(payload) == 0) {
// reply state
} else {
int16_t state = atoi(payload);
dispatch_normalized_group_value(atoi(topic + 6), NULL, state, 0, 1); // + 6 => trim 'output' from the topic
}
// } else if(strcasecmp_P(topic, PSTR("screenshot")) == 0) {
// guiTakeScreenshot("/screenshot.bmp"); // Literal String
@ -270,7 +275,7 @@ void dispatch_command(const char* topic, const char* payload)
#if HASP_USE_MQTT > 0
} else if(!strcmp_P(topic, PSTR("mqtthost")) || !strcmp_P(topic, PSTR("mqttport")) ||
!strcmp_P(topic, PSTR("mqttport")) || !strcmp_P(topic, PSTR("mqttuser")) ||
!strcmp_P(topic, PSTR("mqttuser")) || !strcmp_P(topic, PSTR("mqttpass")) ||
!strcmp_P(topic, PSTR("hostname"))) {
// char item[5];
// memset(item, 0, sizeof(item));
@ -665,7 +670,7 @@ static inline void dispatch_state_msg(const __FlashStringHelper* subtopic, const
// if(groupid >= 0) {
// bool state = dispatch_get_event_state(eventid);
// gpio_set_group_onoff(groupid, state);
// object_set_group_state(groupid, eventid, obj);
// object_set_normalized_group_value(groupid, eventid, obj);
// }
// char payload[8];
@ -677,7 +682,7 @@ static inline void dispatch_state_msg(const __FlashStringHelper* subtopic, const
// {
// if(groupid >= 0) {
// gpio_set_group_value(groupid, state);
// object_set_group_state(groupid, state, obj);
// object_set_normalized_group_value(groupid, state, obj);
// }
// char payload[8];
@ -686,13 +691,13 @@ static inline void dispatch_state_msg(const __FlashStringHelper* subtopic, const
void dispatch_normalized_group_value(uint8_t groupid, lv_obj_t* obj, int16_t val, int16_t min, int16_t max)
{
if(groupid > 0) {
if(groupid == 0) return;
LOG_VERBOSE(TAG_MSGR, F("GROUP %d value %d (%d-%d)"), groupid, val, min, max);
#if HASP_USE_GPIO > 0
gpio_set_normalized_group_value(groupid, val, min, max);
gpio_set_normalized_group_value(groupid, val, min, max); // Update GPIO states
#endif
// object_set_group_state(groupid, value, obj);
}
object_set_normalized_group_value(groupid, obj, val, min, max); // Update onsreen objects
}
/********************************************** Native Commands ****************************************/

View File

@ -581,7 +581,7 @@ void object_set_group_value(lv_obj_t* parent, uint8_t groupid, int16_t intval)
}
// TODO make this a recursive function that goes over all objects only ONCE
void object_set_group_state(uint8_t groupid, lv_obj_t* src_obj, int16_t val, int16_t min, int16_t max)
void object_set_normalized_group_value(uint8_t groupid, lv_obj_t* src_obj, int16_t val, int16_t min, int16_t max)
{
if(groupid == 0) return;
if(min == max) return;

View File

@ -76,7 +76,7 @@ void hasp_send_obj_attribute_int(lv_obj_t* obj, const char* attribute, int32_t v
void hasp_send_obj_attribute_color(lv_obj_t* obj, const char* attribute, lv_color_t color);
void hasp_process_attribute(uint8_t pageid, uint8_t objid, const char* attr, const char* payload);
void object_set_group_state(uint8_t groupid, lv_obj_t* src_obj, int16_t val, int16_t min, int16_t max);
void object_set_normalized_group_value(uint8_t groupid, lv_obj_t* src_obj, int16_t val, int16_t min, int16_t max);
void generic_event_handler(lv_obj_t* obj, lv_event_t event);
void toggle_event_handler(lv_obj_t* obj, lv_event_t event);