mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 20:26:41 +00:00
Make action attribute a text value
This commit is contained in:
parent
57c0bb29b0
commit
52fd90cf46
@ -1454,7 +1454,8 @@ void hasp_process_obj_attribute(lv_obj_t* obj, const char* attr_p, const char* p
|
|||||||
break; // attribute_found
|
break; // attribute_found
|
||||||
|
|
||||||
case ATTR_ACTION:
|
case ATTR_ACTION:
|
||||||
update ? (void)(obj->user_data.actionid = (uint8_t)val) : attr_out_int(obj, attr, obj->user_data.actionid);
|
update ? (void)(obj->user_data.actionid = Parser::get_action_id(payload))
|
||||||
|
: attr_out_int(obj, attr, obj->user_data.actionid);
|
||||||
break; // attribute_found
|
break; // attribute_found
|
||||||
|
|
||||||
case ATTR_TRANSITION:
|
case ATTR_TRANSITION:
|
||||||
|
@ -191,6 +191,23 @@ int Parser::format_bytes(size_t filesize, char* buf, size_t len)
|
|||||||
return snprintf_P(buf, len, PSTR("%d.%d %ciB"), filesize / 10, filesize % 10, labels[unit]);
|
return snprintf_P(buf, len, PSTR("%d.%d %ciB"), filesize / 10, filesize % 10, labels[unit]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t Parser::get_action_id(const char* action)
|
||||||
|
{
|
||||||
|
if(!strcasecmp_P(action, PSTR("prev"))) {
|
||||||
|
return HASP_NUM_PAGE_PREV;
|
||||||
|
} else if(!strcasecmp_P(action, PSTR("next"))) {
|
||||||
|
return HASP_NUM_PAGE_NEXT;
|
||||||
|
} else if(!strcasecmp_P(action, PSTR("back"))) {
|
||||||
|
return HASP_NUM_PAGE_BACK;
|
||||||
|
} else if(action[0] == 'p') {
|
||||||
|
action++;
|
||||||
|
if(is_only_digits(action)) {
|
||||||
|
return atoi(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef ARDUINO
|
#ifndef ARDUINO
|
||||||
long map(long x, long in_min, long in_max, long out_min, long out_max)
|
long map(long x, long in_min, long in_max, long out_min, long out_max)
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@ class Parser {
|
|||||||
static bool haspPayloadToColor(const char* payload, lv_color32_t& color);
|
static bool haspPayloadToColor(const char* payload, lv_color32_t& color);
|
||||||
static bool get_event_state(uint8_t eventid);
|
static bool get_event_state(uint8_t eventid);
|
||||||
static void get_event_name(uint8_t eventid, char* buffer, size_t size);
|
static void get_event_name(uint8_t eventid, char* buffer, size_t size);
|
||||||
|
static uint8_t get_action_id(const char* action);
|
||||||
static uint16_t get_sdbm(const char* str);
|
static uint16_t get_sdbm(const char* str);
|
||||||
static bool is_true(const char* s);
|
static bool is_true(const char* s);
|
||||||
static bool is_only_digits(const char* s);
|
static bool is_only_digits(const char* s);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user