From cbea0776c0838d845e5f15cde763be58f588ba9c Mon Sep 17 00:00:00 2001 From: fvanroie Date: Fri, 3 Apr 2020 18:42:46 +0200 Subject: [PATCH] Add id attribute --- src/hasp_attribute.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/hasp_attribute.cpp b/src/hasp_attribute.cpp index f67bbeb8..91190307 100644 --- a/src/hasp_attribute.cpp +++ b/src/hasp_attribute.cpp @@ -32,12 +32,12 @@ static uint8_t lv_roller_get_visible_row_count(lv_obj_t * roller) } // OK -static lv_color_t haspLogColor(lv_color_t color) +static inline lv_color_t haspLogColor(lv_color_t color) { - uint8_t r = (LV_COLOR_GET_R(color) * 263 + 7) >> 5; - uint8_t g = (LV_COLOR_GET_G(color) * 259 + 3) >> 6; - uint8_t b = (LV_COLOR_GET_B(color) * 263 + 7) >> 5; - Log.trace(F("Color: R%u G%u B%u"), r, g, b); + // uint8_t r = (LV_COLOR_GET_R(color) * 263 + 7) >> 5; + // uint8_t g = (LV_COLOR_GET_G(color) * 259 + 3) >> 6; + // uint8_t b = (LV_COLOR_GET_B(color) * 263 + 7) >> 5; + // Log.trace(F("Color: R%u G%u B%u"), r, g, b); return color; } @@ -602,6 +602,18 @@ static void hasp_process_obj_attribute1(lv_obj_t * obj, const char * attr, const hasp_local_style_attr(obj, attr, payload, update); } +// OK +static void hasp_process_obj_attribute2(lv_obj_t * obj, const char * attr, const char * payload, bool update) +{ + int16_t val = atoi(payload); + + if(!strcmp_P(attr, PSTR("id"))) { + return update ? (void)(obj->user_data = (uint8_t)val) : hasp_out_int(obj, attr, obj->user_data); + } + + hasp_local_style_attr(obj, attr, payload, update); +} + // OK static void hasp_process_obj_attribute3(lv_obj_t * obj, const char * attr, const char * payload, bool update) { @@ -641,6 +653,10 @@ static void hasp_process_obj_attribute4(lv_obj_t * obj, const char * attr, const } } + // if(!strcmp_P(attr, PSTR("page"))) { + // return lv_obj_set_parent; + // } + /* Attributes depending on objecttype */ lv_obj_type_t list; lv_obj_get_type(obj, &list); @@ -757,6 +773,9 @@ void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char case 1: hasp_process_obj_attribute1(obj, attr, payload, update); break; + case 2: + hasp_process_obj_attribute2(obj, attr, payload, update); + break; case 4: hasp_process_obj_attribute4(obj, attr, payload, update); break;