From 219f1f150751a871ebe685d25c036f0ee54da3f2 Mon Sep 17 00:00:00 2001 From: Mitchell M Date: Sat, 5 Apr 2025 00:20:38 -0500 Subject: [PATCH] small wlvgl work --- main/drivers/wlvgl.cpp | 28 ++++++++++++++++++++++++---- main/drivers/wlvgl.h | 24 +++++++++++++++++++++++- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/main/drivers/wlvgl.cpp b/main/drivers/wlvgl.cpp index 1a215ac..851ff5f 100644 --- a/main/drivers/wlvgl.cpp +++ b/main/drivers/wlvgl.cpp @@ -7,14 +7,33 @@ static std::vector style_table; /// A table that maps an incrementing integer to a style reference static std::vector obj_table; +static int index_of_style(lv_style_t* style) { + for (size_t i = 0; i < style_table.size(); i++) { + if (style_table[i] == style) { + return i; + } + } + return -1; +} + +static int index_of_obj(lv_obj_t* obj) { + for (size_t i = 0; i < obj_table.size(); i++) { + if (obj_table[i] == obj) { + return i; + } + } + return -1; +} + + void reset_wlv_tables() { style_table.clear(); obj_table.clear(); } -lv_obj_t wlv_obj_create(lv_obj_t* parent) { +lv_obj_t * wlv_obj_create(lv_obj_t* parent) { // initialize the obj - lv_obj_t value = lv_obj_create(parent); + lv_obj_t* value = lv_obj_create(parent); if (is_state_tracking()) { // add the style to the table @@ -47,8 +66,9 @@ void wlv_obj_set_style_bg_color(lv_obj_t* obj, lv_color_t value, lv_style_select lv_obj_set_style_bg_color(obj, value, selector); if (is_state_tracking()) { - char buf[8]; - sprintf(buf, "%d", style_index); + int obj_index = index_of_obj(obj); + char buf[64]; + sprintf(buf, "%d,%d,%ld", obj_index, value.full, selector); event_occured("lv_obj_set_style_bg_color", buf); } } diff --git a/main/drivers/wlvgl.h b/main/drivers/wlvgl.h index 2ec8ac9..5868a9c 100644 --- a/main/drivers/wlvgl.h +++ b/main/drivers/wlvgl.h @@ -6,8 +6,30 @@ void reset_wlv_tables(); -void wlv_obj_create(lv_obj_t* parent); +lv_obj_t* wlv_obj_create(lv_obj_t* parent); void wlv_style_init(lv_style_t* style); void wlv_obj_set_style_bg_color(struct _lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector); +// lv_style_set_text_color +// lv_style_set_text_align +// lv_obj_align +// lv_obj_set_size +// lv_obj_add_style +// lv_obj_set_style_text_align +// lv_label_set_text +// lv_scr_load +// lv_scr_act +// lv_style_set_bg_color +// lv_style_set_bg_opa +// lv_style_set_text_align +// lv_obj_set_width +// lv_style_set_text_font +// lv_obj_add_style +// lv_style_set_text_color +// lv_label_create +// lv_obj_del +// lv_obj_center +// lv_obj_remove_style +// lv_obj_add_flag +// lv_obj_clear_flag #endif /* WLVGL_H */ \ No newline at end of file