From 6fa5aec939d3009ea0ded12bb2e1fa9d8f71dde2 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sat, 23 Oct 2021 15:08:33 +0200 Subject: [PATCH] LVGL OpenHASP alpha2 --- lib/libesp32/Berry/default/be_lvgl_module.c | 13 +- .../Berry/default/be_lvgl_widgets_lib.c | 67 ++ lib/libesp32/Berry/default/be_python_compat.c | 2 +- .../Berry/default/embedded/openhasp.be | 189 +++- lib/libesp32/Berry/generate/be_fixed_debug.h | 2 +- lib/libesp32/Berry/generate/be_fixed_energy.h | 2 +- lib/libesp32/Berry/generate/be_fixed_flash.h | 2 +- lib/libesp32/Berry/generate/be_fixed_gc.h | 2 +- lib/libesp32/Berry/generate/be_fixed_global.h | 2 +- lib/libesp32/Berry/generate/be_fixed_gpio.h | 2 +- .../Berry/generate/be_fixed_introspect.h | 2 +- lib/libesp32/Berry/generate/be_fixed_json.h | 2 +- lib/libesp32/Berry/generate/be_fixed_light.h | 2 +- lib/libesp32/Berry/generate/be_fixed_math.h | 2 +- .../Berry/generate/be_fixed_persist.h | 2 +- .../Berry/generate/be_fixed_solidify.h | 2 +- lib/libesp32/Berry/generate/be_fixed_strict.h | 2 +- lib/libesp32/Berry/generate/be_fixed_string.h | 2 +- .../Berry/generate/be_fixed_tasmota_path.h | 2 +- .../Berry/generate/be_fixed_webserver.h | 2 +- lib/libesp32/Berry/src/be_constobj.h | 5 +- lib/libesp32/Berry/src/be_solidifylib.c | 58 + lib/libesp32/Berry/src/berry.h | 3 +- .../Berry/tools/coc/block_builder.cpp | 9 +- lib/libesp32/Berry/tools/coc/block_builder.h | 1 - .../LVGL_assets/src/lv_theme_openhasp.c | 1001 +++++++++++++++++ .../LVGL_assets/src/lv_theme_openhasp.h | 49 + tasmota/lvgl_berry/be_lv_c_mapping.h | 230 ++-- tools/lv_berry/convert.py | 49 +- tools/lv_berry/lv_funcs.h | 22 + tools/lv_berry/preprocessor.py | 4 +- 31 files changed, 1553 insertions(+), 181 deletions(-) create mode 100644 lib/libesp32_lvgl/LVGL_assets/src/lv_theme_openhasp.c create mode 100644 lib/libesp32_lvgl/LVGL_assets/src/lv_theme_openhasp.h diff --git a/lib/libesp32/Berry/default/be_lvgl_module.c b/lib/libesp32/Berry/default/be_lvgl_module.c index 1924ca34e..06035af04 100644 --- a/lib/libesp32/Berry/default/be_lvgl_module.c +++ b/lib/libesp32/Berry/default/be_lvgl_module.c @@ -10,6 +10,7 @@ #include "lvgl.h" #include "be_lvgl.h" +#include "lv_theme_openhasp.h" extern int lv0_member(bvm *vm); // resolve virtual members @@ -70,6 +71,7 @@ const lvbe_call_c_t lv_func[] = { { "get_ver_res", (void*) &lv_get_ver_res, "i", "" }, { "group_get_default", (void*) &lv_group_get_default, "lv.lv_group", "" }, { "img_src_get_type", (void*) &lv_img_src_get_type, "i", "." }, + { "indev_get_act", (void*) &lv_indev_get_act, "lv.lv_indev", "" }, { "indev_get_obj_act", (void*) &lv_indev_get_obj_act, "lv.lv_obj", "" }, { "indev_read_timer_cb", (void*) &lv_indev_read_timer_cb, "", "(lv.lv_timer)" }, { "layer_sys", (void*) &lv_layer_sys, "lv.lv_obj", "" }, @@ -81,18 +83,23 @@ const lvbe_call_c_t lv_func[] = { { "obj_enable_style_refresh", (void*) &lv_obj_enable_style_refresh, "", "b" }, { "obj_event_base", (void*) &lv_obj_event_base, "i", "(lv.lv_obj_class)(lv.lv_event)" }, { "obj_report_style_change", (void*) &lv_obj_report_style_change, "", "(lv.lv_style)" }, - { "obj_style_get_selector_part", (void*) &lv_obj_style_get_selector_part, "i", "(lv.lv_style_selector)" }, - { "obj_style_get_selector_state", (void*) &lv_obj_style_get_selector_state, "i", "(lv.lv_style_selector)" }, + { "obj_style_get_selector_part", (void*) &lv_obj_style_get_selector_part, "i", "i" }, + { "obj_style_get_selector_state", (void*) &lv_obj_style_get_selector_state, "i", "i" }, { "refr_now", (void*) &lv_refr_now, "", "(lv.lv_disp)" }, { "scr_act", (void*) &lv_scr_act, "lv.lv_obj", "" }, { "scr_load", (void*) &lv_scr_load, "", "(lv.lv_obj)" }, { "scr_load_anim", (void*) &lv_scr_load_anim, "", "(lv.lv_obj)iiib" }, { "theme_apply", (void*) &lv_theme_apply, "", "(lv.lv_obj)" }, + { "theme_default_init", (void*) &lv_theme_default_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" }, + { "theme_default_is_inited", (void*) &lv_theme_default_is_inited, "b", "" }, { "theme_get_color_primary", (void*) &lv_theme_get_color_primary, "lv.lv_color", "(lv.lv_obj)" }, { "theme_get_color_secondary", (void*) &lv_theme_get_color_secondary, "lv.lv_color", "(lv.lv_obj)" }, { "theme_get_font_large", (void*) &lv_theme_get_font_large, "lv.lv_font", "(lv.lv_obj)" }, { "theme_get_font_normal", (void*) &lv_theme_get_font_normal, "lv.lv_font", "(lv.lv_obj)" }, { "theme_get_font_small", (void*) &lv_theme_get_font_small, "lv.lv_font", "(lv.lv_obj)" }, + { "theme_get_from_obj", (void*) &lv_theme_get_from_obj, "lv.lv_theme", "(lv.lv_obj)" }, + { "theme_openhasp_init", (void*) &lv_theme_openhasp_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" }, + { "theme_openhasp_is_inited", (void*) &lv_theme_openhasp_is_inited, "b", "" }, { "theme_set_apply_cb", (void*) &lv_theme_set_apply_cb, "", "(lv.lv_theme)^lv_theme_apply_cb^" }, { "theme_set_parent", (void*) &lv_theme_set_parent, "", "(lv.lv_theme)(lv.lv_theme)" }, @@ -673,7 +680,7 @@ be_local_module(lv, { be_nested_key("start", 1697318111, 5, 0), be_const_func(lv0_start) }, })) ); -BE_EXPORT_VARIABLE be_define_const_native_module(lv, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(lv); #endif // USE_LVGL diff --git a/lib/libesp32/Berry/default/be_lvgl_widgets_lib.c b/lib/libesp32/Berry/default/be_lvgl_widgets_lib.c index fe66d0a81..79559790d 100644 --- a/lib/libesp32/Berry/default/be_lvgl_widgets_lib.c +++ b/lib/libesp32/Berry/default/be_lvgl_widgets_lib.c @@ -28,6 +28,7 @@ extern int lvs_tostring(bvm *vm); BE_EXPORT_VARIABLE extern const bclass be_class_lv_obj; extern int lvbe_font_create(bvm *vm); +extern int lvbe_theme_create(bvm *vm); /* `lv_style` external functions definitions */ @@ -125,6 +126,8 @@ extern int lvbe_style_set_arc_img_src(bvm *vm); /* `lv_color` external functions definitions */ +/* `lv_theme` external functions definitions */ + /* `lv_img` external functions definitions */ extern int lvbe_img_set_tasmota_logo(bvm *vm); extern int lvbe_img_create(bvm *vm); @@ -143,6 +146,22 @@ extern int lvbe_img_get_pivot(bvm *vm); extern int lvbe_img_get_zoom(bvm *vm); extern int lvbe_img_get_antialias(bvm *vm); +/* `lv_disp` external functions definitions */ +extern int lvbe_disp_get_scr_act(bvm *vm); +extern int lvbe_disp_get_scr_prev(bvm *vm); +extern int lvbe_disp_load_scr(bvm *vm); +extern int lvbe_disp_get_layer_top(bvm *vm); +extern int lvbe_disp_get_layer_sys(bvm *vm); +extern int lvbe_disp_set_theme(bvm *vm); +extern int lvbe_disp_get_theme(bvm *vm); +extern int lvbe_disp_set_bg_color(bvm *vm); +extern int lvbe_disp_set_bg_image(bvm *vm); +extern int lvbe_disp_set_bg_opa(bvm *vm); +extern int lvbe_disp_get_inactive_time(bvm *vm); +extern int lvbe_disp_trig_activity(bvm *vm); +extern int lvbe_disp_clean_dcache(bvm *vm); +extern int lvbe_disp_dpx(bvm *vm); + /* `lv_obj` external functions definitions */ extern int lvbe_obj_add_event_cb(bvm *vm); extern int lvbe_obj_remove_event_cb(bvm *vm); @@ -439,6 +458,7 @@ extern int lvbe_obj_set_parent(bvm *vm); extern int lvbe_obj_move_foreground(bvm *vm); extern int lvbe_obj_move_background(bvm *vm); extern int lvbe_obj_get_screen(bvm *vm); +extern int lvbe_obj_get_disp(bvm *vm); extern int lvbe_obj_get_parent(bvm *vm); extern int lvbe_obj_get_child(bvm *vm); extern int lvbe_obj_get_child_cnt(bvm *vm); @@ -786,7 +806,9 @@ extern int lvbe_textarea_cursor_up(bvm *vm); extern int be_ntv_lv_style_init(bvm *vm); extern int be_ntv_lv_font_init(bvm *vm); extern int be_ntv_lv_color_init(bvm *vm); +extern int be_ntv_lv_theme_init(bvm *vm); extern int be_ntv_lv_img_init(bvm *vm); +extern int be_ntv_lv_disp_init(bvm *vm); extern int be_ntv_lv_obj_init(bvm *vm); extern int be_ntv_lv_group_init(bvm *vm); extern int be_ntv_lv_indev_init(bvm *vm); @@ -882,6 +904,23 @@ be_local_class(lv_indev, ); /*******************************************************************/ +/******************************************************************** +** Solidified class: lv_disp +********************************************************************/ +be_local_class(lv_disp, + 1, + NULL, + be_nested_map(4, + ( (struct bmapnode*) &(const bmapnode[]) { + { be_nested_key("init", 380752755, 4, -1), be_const_func(lv0_init) }, + { be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) }, + { be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) }, + { be_nested_key("member", 719708611, 6, 0), be_const_func(lvx_member) }, + })), + (be_nested_const_str("lv_disp", 609712084, 8)) +); +/*******************************************************************/ + /******************************************************************** ** Solidified class: lv_font ********************************************************************/ @@ -898,6 +937,22 @@ be_local_class(lv_font, ); /*******************************************************************/ +/******************************************************************** +** Solidified class: lv_theme +********************************************************************/ +be_local_class(lv_theme, + 1, + NULL, + be_nested_map(3, + ( (struct bmapnode*) &(const bmapnode[]) { + { be_nested_key("init", 380752755, 4, -1), be_const_func(lvbe_theme_create) }, + { be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) }, + { be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) }, + })), + (be_nested_const_str("lv_theme", 1550958453, 7)) +); +/*******************************************************************/ + /******************************************************************** ** Solidified class: lv_color ********************************************************************/ @@ -933,6 +988,12 @@ void be_load_lv_color_class(bvm *vm) { be_pop(vm, 1); } +void be_load_lv_theme_class(bvm *vm) { + be_pushntvclass(vm, &be_class_lv_theme); + be_setglobal(vm, "lv_theme"); + be_pop(vm, 1); +} + /******************************************************************** ** Solidified class: lv_img ********************************************************************/ @@ -955,6 +1016,12 @@ void be_load_lv_img_class(bvm *vm) { be_pop(vm, 1); } +void be_load_lv_disp_class(bvm *vm) { + be_pushntvclass(vm, &be_class_lv_disp); + be_setglobal(vm, "lv_disp"); + be_pop(vm, 1); +} + void be_load_lv_obj_class(bvm *vm) { be_pushntvclass(vm, &be_class_lv_obj); be_setglobal(vm, "lv_obj"); diff --git a/lib/libesp32/Berry/default/be_python_compat.c b/lib/libesp32/Berry/default/be_python_compat.c index d36f468fd..7213c10ad 100644 --- a/lib/libesp32/Berry/default/be_python_compat.c +++ b/lib/libesp32/Berry/default/be_python_compat.c @@ -54,5 +54,5 @@ be_local_module(python_compat, { be_nested_key("init", 380752755, 4, -1), be_const_closure(_anonymous__closure) }, })) ); -BE_EXPORT_VARIABLE be_define_const_native_module(python_compat, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(python_compat); /********************************************************************/ diff --git a/lib/libesp32/Berry/default/embedded/openhasp.be b/lib/libesp32/Berry/default/embedded/openhasp.be index 3abd8284e..095ff3141 100644 --- a/lib/libesp32/Berry/default/embedded/openhasp.be +++ b/lib/libesp32/Berry/default/embedded/openhasp.be @@ -1,7 +1,45 @@ - import string import json +# lv.start() +# scr = lv.scr_act() # default screean object +# scr.set_style_bg_color(lv.color(0x0000A0), lv.PART_MAIN | lv.STATE_DEFAULT) + +lv.start() + +hres = lv.get_hor_res() # should be 320 +vres = lv.get_ver_res() # should be 240 + +scr = lv.scr_act() # default screean object +f20 = lv.montserrat_font(20) # load embedded Montserrat 20 + +th2 = lv.theme_openhasp_init(0, lv.color(0xFF0000), lv.color(0xFFFF00), true, f20) +scr.get_disp().set_theme(th2) +# apply theme to layer_top, but keep it transparent +lv.theme_apply(lv.layer_top()) +lv.layer_top().set_style_bg_opa(0,0) + + +# parse hex string +def parse_hex(s) + import string + s = string.toupper(s) # turn to uppercase + var val = 0 + for i:0..size(s)-1 + var c = s[i] + # var c_int = string.byte(c) + if c == "#" continue end # skip '#' prefix if any + if c == "x" || c == "X" continue end # skip 'x' or 'X' + + if c >= "A" && c <= "F" + val = (val << 4) | string.byte(c) - 55 + elif c >= "0" && c <= "9" + val = (val << 4) | string.byte(c) - 48 + end + end + return val +end + #- ------------------------------------------------------------ Class `lvh_obj` encapsulating `lv_obj`` @@ -11,7 +49,9 @@ import json Adds specific virtual members used by OpenHASP - ------------------------------------------------------------ -# class lvh_obj - static _lv_class = lv_obj + # _lv_class refers to the lvgl class encapsulated, and is overriden by subclasses + static _lv_class = lv.obj + #- mapping from OpenHASP attribute to LVGL attribute -# #- if mapping is null, we use set_X and get_X from our own class -# static _attr_map = { @@ -25,31 +65,37 @@ class lvh_obj "hidden": nil, # apply to self "enabled": nil, # apply to self "toggle": nil, + "bg_color": nil, + "align": nil, } var _lv_obj # native lvgl object var _lv_label # sub-label if exists + # init + # - create the LVGL encapsulated object def init(parent) - var obj_class = self._lv_class # need to copy to a var to distinguish from method call - self._lv_obj = obj_class(parent) + var obj_class = self._lv_class # need to assign to a var to distinguish from method call + self._lv_obj = obj_class(parent) # instanciate LVGL object + self.post_init() end - def obj() + # post-init, to be overriden + def post_init() + end + + # get LVGL encapsulated object + def get_obj() return self._lv_obj end - def tostring() - return "" - end - #- ------------------------------------------------------------ Mapping of synthetic attributes - text - hidden - enabled - ------------------------------------------------------------ -# - #- `hidden` attributes mapped to LV_OBJ_FLAG_HIDDEN -# + #- `hidden` attributes mapped to OBJ_FLAG_HIDDEN -# def set_hidden(h) if h self._lv_obj.add_flag(lv.OBJ_FLAG_HIDDEN) @@ -62,6 +108,7 @@ class lvh_obj return self._lv_obj.has_flag(lv.OBJ_FLAG_HIDDEN) end + #- `enabled` attributes mapped to OBJ_FLAG_CLICKABLE -# def set_enabled(h) if h self._lv_obj.add_flag(lv.OBJ_FLAG_CLICKABLE) @@ -74,9 +121,10 @@ class lvh_obj return self._lv_obj.has_flag(lv.OBJ_FLAG_CLICKABLE) end + #- `toggle` attributes mapped to STATE_CHECKED -# def set_toggle(t) if t == "TRUE" t = true end - if t == "FASLE" t = false end + if t == "FALSE" t = false end if t self._lv_obj.add_state(lv.STATE_CHECKED) else @@ -90,24 +138,67 @@ class lvh_obj #- set_text: create a `lv_label` sub object to the current object -# #- (default case, may be overriden by object that directly take text) -# - def set_text(t) + def check_label() if self._lv_label == nil - self._lv_label = lv_label(self.obj()) + self._lv_label = lv.label(self.get_obj()) end + end + def set_text(t) + self.check_label() self._lv_label.set_text(t) end def get_text() - if self._lv_label == nil + if self._lv_label == nil return nil end + return self._lv_label.get_text() + end + + def set_align(t) + var align + self.check_label() + + if t == 0 || t == "left" + align = lv.TEXT_ALIGN_LEFT + elif t == 1 || t == "center" + align = lv.TEXT_ALIGN_CENTER + elif t == 2 || t == "right" + align = lv.TEXT_ALIGN_RIGHT + else + align = lv.TEXT_ALIGN_auto + end + self._lv_label.set_style_text_align(align, lv.PART_MAIN | lv.STATE_DEFAULT) + end + + def get_align() + if self._lv_label == nil return nil end + var align self._lv_label.get_style_text_align(lv.PART_MAIN | lv.STATE_DEFAULT) + if align == lv.TEXT_ALIGN_LEFT + return "left" + elif align == lv.TEXT_ALIGN_CENTER + return "center" + elif align == lv.TEXT_ALIGN_RIGHT + return "right" + else return nil end - return self._lv_label.get_text() + end + + def set_bg_color(t) + var color = lv.color(parse_hex(t)) + self._lv_obj.set_style_bg_color(color, lv.PART_MAIN | lv.STATE_DEFAULT) + end + + def get_bg_color() + return self._lv_obj.get_style_bg_color(lv.PART_MAIN | lv.STATE_DEFAULT) end #- ------------------------------------------------------------ Mapping of virtual attributes - ------------------------------------------------------------ -# def member(k) + # tostring is a special case, we shouldn't raise an exception for it + if k == 'tostring' return nil end + # if self._attr_map.has(k) import introspect if self._attr_map[k] @@ -153,34 +244,42 @@ class lvh_obj end end -#- creat sub-classes of lvh_obj and map the LVGL class in static '_lv_class' attribute -# -class lvh_arc : lvh_obj static _lv_class = lv_arc end -class lvh_bar : lvh_obj static _lv_class = lv_bar end -class lvh_btn : lvh_obj static _lv_class = lv_btn end -class lvh_btnmatrix : lvh_obj static _lv_class = lv_btnmatrix end -class lvh_checkbox : lvh_obj static _lv_class = lv_checkbox end -class lvh_dropdown : lvh_obj static _lv_class = lv_dropdown end -class lvh_img : lvh_obj static _lv_class = lv_img end -class lvh_label : lvh_obj static _lv_class = lv_label end -class lvh_line : lvh_obj static _lv_class = lv_line end -class lvh_roller : lvh_obj static _lv_class = lv_roller end -class lvh_slider : lvh_obj static _lv_class = lv_slider end -class lvh_slider : lvh_obj static _lv_class = lv_slider end -class lvh_switch : lvh_obj static _lv_class = lv_switch end -class lvh_textarea : lvh_obj static _lv_class = lv_textarea end +class lvh_label : lvh_obj + static _lv_class = lv.label + # label do not need a sub-label + def post_init() + self._lv_label = self._lv_obj + # label don't have opaque background by default + self._lv_obj.set_style_bg_opa(lv.OPA_COVER, lv.PART_MAIN | lv.STATE_DEFAULT) + end +end -#- ------------------------------------------------------------ - Class `lvh_page` encapsulating `lv_obj` as screen (created with lv_obj(0)) -- ------------------------------------------------------------ -# +#- creat sub-classes of lvh_obj and map the LVGL class in static '_lv_class' attribute -# +class lvh_arc : lvh_obj static _lv_class = lv.arc end +class lvh_bar : lvh_obj static _lv_class = lv.bar end +class lvh_btn : lvh_obj static _lv_class = lv.btn end +class lvh_btnmatrix : lvh_obj static _lv_class = lv.btnmatrix end +class lvh_checkbox : lvh_obj static _lv_class = lv.checkbox end +class lvh_dropdown : lvh_obj static _lv_class = lv.dropdown end +class lvh_img : lvh_obj static _lv_class = lv.img end +class lvh_line : lvh_obj static _lv_class = lv.line end +class lvh_roller : lvh_obj static _lv_class = lv.roller end +class lvh_slider : lvh_obj static _lv_class = lv.slider end +class lvh_slider : lvh_obj static _lv_class = lv.slider end +class lvh_switch : lvh_obj static _lv_class = lv.switch end +class lvh_textarea : lvh_obj static _lv_class = lv.textarea end + +#- ---------------------------------------------------------------------------- + Class `lvh_page` encapsulating `lv_obj` as screen (created with lv.obj(0)) +- ----------------------------------------------------------------------------- -# # ex of transition: lv.scr_load_anim(scr, lv.SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, false) class lvh_page - var _obj_id # list of objects by id numbers - var _page_id - var _lv_scr # lvgl screen object + var _obj_id # (map) of objects by id numbers + var _page_id # (int) id number of the page + var _lv_scr # (lv_obj) lvgl screen object #- init(page_number) -# def init(page_number) - import string import global # if no parameter, default to page #1 @@ -190,8 +289,10 @@ class lvh_page self._obj_id = {} # init list of objects if page_number == 1 self._lv_scr = lv.scr_act() # default screen + elif page_number == 0 + self._lv_scr = lv.layer_top() # top layer, visible over all screens else - self._lv_scr = lv_obj(0) # allocate a new screen + self._lv_scr = lv.obj(0) # allocate a new screen self._lv_scr.set_style_bg_color(lv_color(0x000000), lv.PART_MAIN | lv.STATE_DEFAULT) # set black background end @@ -217,6 +318,8 @@ class lvh_page #- show this page, with animation -# def show(anim, duration) + # ignore if there is no screen, like for id 0 + if self._lv_scr == nil return nil end # ignore if the screen is already active if self._lv_scr._p == lv.scr_act()._p return end # do nothing @@ -289,11 +392,11 @@ def parse_obj(jline, page) # add object to page object lvh_page_cur.set_obj(obj_id, obj) - # set attributes # try every attribute, if not supported it is silently ignored for k:jline.keys() - obj.(k) = jline[k] + introspect.set(obj, k, jline[k]) + # obj.(k) = jline[k] end # create a global variable for this object of form pb, ex p1b2 @@ -314,8 +417,10 @@ for j:jsonl var jline = json.load(j) # parse page first - parse_page(jline) - parse_obj(jline, lvh_page_cur) + if type(jline) == 'instance' + parse_page(jline) + parse_obj(jline, lvh_page_cur) + end end print(lvh_pages[1]._obj_id) diff --git a/lib/libesp32/Berry/generate/be_fixed_debug.h b/lib/libesp32/Berry/generate/be_fixed_debug.h index ef3b32236..b7b396a35 100644 --- a/lib/libesp32/Berry/generate/be_fixed_debug.h +++ b/lib/libesp32/Berry/generate/be_fixed_debug.h @@ -19,4 +19,4 @@ static be_define_const_module( "debug" ); -BE_EXPORT_VARIABLE be_define_const_native_module(debug, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(debug); diff --git a/lib/libesp32/Berry/generate/be_fixed_energy.h b/lib/libesp32/Berry/generate/be_fixed_energy.h index 719d24f2d..3af466055 100644 --- a/lib/libesp32/Berry/generate/be_fixed_energy.h +++ b/lib/libesp32/Berry/generate/be_fixed_energy.h @@ -18,4 +18,4 @@ static be_define_const_module( "energy" ); -BE_EXPORT_VARIABLE be_define_const_native_module(energy, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(energy); diff --git a/lib/libesp32/Berry/generate/be_fixed_flash.h b/lib/libesp32/Berry/generate/be_fixed_flash.h index fc9305aac..4909e0fe6 100644 --- a/lib/libesp32/Berry/generate/be_fixed_flash.h +++ b/lib/libesp32/Berry/generate/be_fixed_flash.h @@ -16,4 +16,4 @@ static be_define_const_module( "flash" ); -BE_EXPORT_VARIABLE be_define_const_native_module(flash, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(flash); diff --git a/lib/libesp32/Berry/generate/be_fixed_gc.h b/lib/libesp32/Berry/generate/be_fixed_gc.h index 388427f71..401c77b53 100644 --- a/lib/libesp32/Berry/generate/be_fixed_gc.h +++ b/lib/libesp32/Berry/generate/be_fixed_gc.h @@ -15,4 +15,4 @@ static be_define_const_module( "gc" ); -BE_EXPORT_VARIABLE be_define_const_native_module(gc, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(gc); diff --git a/lib/libesp32/Berry/generate/be_fixed_global.h b/lib/libesp32/Berry/generate/be_fixed_global.h index 2f43d87e0..4094ca20d 100644 --- a/lib/libesp32/Berry/generate/be_fixed_global.h +++ b/lib/libesp32/Berry/generate/be_fixed_global.h @@ -16,4 +16,4 @@ static be_define_const_module( "global" ); -BE_EXPORT_VARIABLE be_define_const_native_module(global, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(global); diff --git a/lib/libesp32/Berry/generate/be_fixed_gpio.h b/lib/libesp32/Berry/generate/be_fixed_gpio.h index 891d18896..091842bca 100644 --- a/lib/libesp32/Berry/generate/be_fixed_gpio.h +++ b/lib/libesp32/Berry/generate/be_fixed_gpio.h @@ -283,4 +283,4 @@ static be_define_const_module( "gpio" ); -BE_EXPORT_VARIABLE be_define_const_native_module(gpio, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(gpio); diff --git a/lib/libesp32/Berry/generate/be_fixed_introspect.h b/lib/libesp32/Berry/generate/be_fixed_introspect.h index c5bc4a6aa..e6d5624f5 100644 --- a/lib/libesp32/Berry/generate/be_fixed_introspect.h +++ b/lib/libesp32/Berry/generate/be_fixed_introspect.h @@ -18,4 +18,4 @@ static be_define_const_module( "introspect" ); -BE_EXPORT_VARIABLE be_define_const_native_module(introspect, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(introspect); diff --git a/lib/libesp32/Berry/generate/be_fixed_json.h b/lib/libesp32/Berry/generate/be_fixed_json.h index ab4b0254c..c0149e316 100644 --- a/lib/libesp32/Berry/generate/be_fixed_json.h +++ b/lib/libesp32/Berry/generate/be_fixed_json.h @@ -15,4 +15,4 @@ static be_define_const_module( "json" ); -BE_EXPORT_VARIABLE be_define_const_native_module(json, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(json); diff --git a/lib/libesp32/Berry/generate/be_fixed_light.h b/lib/libesp32/Berry/generate/be_fixed_light.h index 4afeb464e..9540ca804 100644 --- a/lib/libesp32/Berry/generate/be_fixed_light.h +++ b/lib/libesp32/Berry/generate/be_fixed_light.h @@ -18,4 +18,4 @@ static be_define_const_module( "light" ); -BE_EXPORT_VARIABLE be_define_const_native_module(light, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(light); diff --git a/lib/libesp32/Berry/generate/be_fixed_math.h b/lib/libesp32/Berry/generate/be_fixed_math.h index 111c556c8..f36928843 100644 --- a/lib/libesp32/Berry/generate/be_fixed_math.h +++ b/lib/libesp32/Berry/generate/be_fixed_math.h @@ -40,4 +40,4 @@ static be_define_const_module( "math" ); -BE_EXPORT_VARIABLE be_define_const_native_module(math, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(math); diff --git a/lib/libesp32/Berry/generate/be_fixed_persist.h b/lib/libesp32/Berry/generate/be_fixed_persist.h index 2bcedb715..4cea6af1d 100644 --- a/lib/libesp32/Berry/generate/be_fixed_persist.h +++ b/lib/libesp32/Berry/generate/be_fixed_persist.h @@ -14,4 +14,4 @@ static be_define_const_module( "persist" ); -BE_EXPORT_VARIABLE be_define_const_native_module(persist, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(persist); diff --git a/lib/libesp32/Berry/generate/be_fixed_solidify.h b/lib/libesp32/Berry/generate/be_fixed_solidify.h index fea7be4ed..82e81d27b 100644 --- a/lib/libesp32/Berry/generate/be_fixed_solidify.h +++ b/lib/libesp32/Berry/generate/be_fixed_solidify.h @@ -14,4 +14,4 @@ static be_define_const_module( "solidify" ); -BE_EXPORT_VARIABLE be_define_const_native_module(solidify, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(solidify); diff --git a/lib/libesp32/Berry/generate/be_fixed_strict.h b/lib/libesp32/Berry/generate/be_fixed_strict.h index fe93fca6d..b26e3f566 100644 --- a/lib/libesp32/Berry/generate/be_fixed_strict.h +++ b/lib/libesp32/Berry/generate/be_fixed_strict.h @@ -14,4 +14,4 @@ static be_define_const_module( "strict" ); -BE_EXPORT_VARIABLE be_define_const_native_module(strict, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(strict); diff --git a/lib/libesp32/Berry/generate/be_fixed_string.h b/lib/libesp32/Berry/generate/be_fixed_string.h index 906c11f55..eb1e5cf58 100644 --- a/lib/libesp32/Berry/generate/be_fixed_string.h +++ b/lib/libesp32/Berry/generate/be_fixed_string.h @@ -22,4 +22,4 @@ static be_define_const_module( "string" ); -BE_EXPORT_VARIABLE be_define_const_native_module(string, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(string); diff --git a/lib/libesp32/Berry/generate/be_fixed_tasmota_path.h b/lib/libesp32/Berry/generate/be_fixed_tasmota_path.h index 7ff9e3d66..4689021c4 100644 --- a/lib/libesp32/Berry/generate/be_fixed_tasmota_path.h +++ b/lib/libesp32/Berry/generate/be_fixed_tasmota_path.h @@ -15,4 +15,4 @@ static be_define_const_module( "path" ); -BE_EXPORT_VARIABLE be_define_const_native_module(path, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(path); diff --git a/lib/libesp32/Berry/generate/be_fixed_webserver.h b/lib/libesp32/Berry/generate/be_fixed_webserver.h index 4af8183a3..27f475997 100644 --- a/lib/libesp32/Berry/generate/be_fixed_webserver.h +++ b/lib/libesp32/Berry/generate/be_fixed_webserver.h @@ -28,4 +28,4 @@ static be_define_const_module( "webserver" ); -BE_EXPORT_VARIABLE be_define_const_native_module(webserver, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(webserver); diff --git a/lib/libesp32/Berry/src/be_constobj.h b/lib/libesp32/Berry/src/be_constobj.h index 979f10756..5bb495c72 100644 --- a/lib/libesp32/Berry/src/be_constobj.h +++ b/lib/libesp32/Berry/src/be_constobj.h @@ -138,13 +138,12 @@ const bvector _name = { \ .end = (void*)(_data + (_size) - 1) \ } -#define be_define_const_native_module(_module, _init) \ +#define be_define_const_native_module(_module) \ const bntvmodule be_native_module(_module) = { \ .name = #_module, \ .attrs = NULL, \ .size = 0, \ - .module = (bmodule*)&(m_lib##_module), \ - .init = _init \ + .module = (bmodule*)&(m_lib##_module) \ } /* defines needed for solidified classes */ diff --git a/lib/libesp32/Berry/src/be_solidifylib.c b/lib/libesp32/Berry/src/be_solidifylib.c index 431765e37..b3777cb28 100644 --- a/lib/libesp32/Berry/src/be_solidifylib.c +++ b/lib/libesp32/Berry/src/be_solidifylib.c @@ -297,6 +297,62 @@ static void m_solidify_class(bvm *vm, bclass *cl, int builtins) logfmt("}\n"); } +static void m_solidify_module(bvm *vm, bmodule *ml, int builtins) +{ + const char * module_name = ml->info.name; + + /* iterate on members to dump closures */ + if (ml->table) { + bmapnode *node; + bmapiter iter = be_map_iter(); + while ((node = be_map_next(ml->table, &iter)) != NULL) { + if (var_isstr(&node->key) && var_isclosure(&node->value)) { + bclosure *f = var_toobj(&node->value); + m_solidify_closure(vm, f, builtins); + } + } + } + + + logfmt("\n"); + logfmt("/********************************************************************\n"); + logfmt("** Solidified module: %s\n", module_name); + logfmt("********************************************************************/\n"); + + logfmt("be_local_module(%s,\n", module_name); + logfmt(" \"%s\",\n", module_name); + + if (ml->table) { + logfmt(" be_nested_map(%i,\n", ml->table->count); + + logfmt(" ( (struct bmapnode*) &(const bmapnode[]) {\n"); + for (int i = 0; i < ml->table->count; i++) { + bmapnode * node = &ml->table->slots[i]; + if (node->key.type != BE_STRING) { + char error[64]; + snprintf(error, sizeof(error), "Unsupported type in key: %i", node->key.type); + be_raise(vm, "internal_error", error); + } + int key_next = node->key.next; + size_t len = strlen(str(node->key.v.s)); + if (0xFFFFFF == key_next) { + key_next = -1; /* more readable */ + } + logfmt(" { be_nested_key(\"%s\", %i, %zu, %i), ", str(node->key.v.s), be_strhash(node->key.v.s), len >= 255 ? 255 : len, key_next); + m_solidify_bvalue(vm, &node->value, module_name, str(node->key.v.s)); + + logfmt(" },\n"); + } + logfmt(" }))\n"); + } else { + logfmt(" NULL,\n"); + } + logfmt(");\n"); + logfmt("BE_EXPORT_VARIABLE be_define_const_native_module(%s, NULL);\n", module_name); + logfmt("/********************************************************************\n"); + +} + #define be_builtin_count(vm) \ be_vector_count(&(vm)->gbldesc.builtin.vlist) @@ -308,6 +364,8 @@ static int m_dump(bvm *vm) m_solidify_closure(vm, var_toobj(v), be_builtin_count(vm)); } else if (var_isclass(v)) { m_solidify_class(vm, var_toobj(v), be_builtin_count(vm)); + } else if (var_ismodule(v)) { + m_solidify_module(vm, var_toobj(v), be_builtin_count(vm)); } } be_return_nil(vm); diff --git a/lib/libesp32/Berry/src/berry.h b/lib/libesp32/Berry/src/berry.h index 9692d049f..fb67f28af 100644 --- a/lib/libesp32/Berry/src/berry.h +++ b/lib/libesp32/Berry/src/berry.h @@ -18,7 +18,7 @@ extern "C" { #endif /* do not modify the version number! */ -#define BERRY_VERSION "0.1.10" +#define BERRY_VERSION "1.0.0" #if BE_STACK_TOTAL_MAX < BE_STACK_FREE_MIN * 2 #error "The value of the macro BE_STACK_TOTAL_MAX is too small." @@ -172,7 +172,6 @@ typedef struct bntvmodule { const bntvmodobj *attrs; /* native module attributes */ size_t size; /* native module attribute count */ const struct bmodule *module; /* const module object */ - bntvfunc init; /* initialization function */ } bntvmodule; /* native module node definition macro */ diff --git a/lib/libesp32/Berry/tools/coc/block_builder.cpp b/lib/libesp32/Berry/tools/coc/block_builder.cpp index acea6777c..bd76cdbf5 100755 --- a/lib/libesp32/Berry/tools/coc/block_builder.cpp +++ b/lib/libesp32/Berry/tools/coc/block_builder.cpp @@ -143,8 +143,7 @@ std::string block_builder::module_tostring(const block &block) if (scp != "static") { /* extern */ ostr << "\n" << scp << " be_define_const_native_module(" - << block.name << ", " - << init(block) << ");" << std::endl; + << block.name << ");" << std::endl; } return ostr.str(); } @@ -168,12 +167,6 @@ std::string block_builder::name(const block &block) return it == block.attr.end() ? block.name : it->second; } -std::string block_builder::init(const block &block) -{ - auto it = block.attr.find("init"); - return it == block.attr.end() ? "NULL" : it->second; -} - void block_builder::writefile(const std::string &filename, const std::string &text) { std::string pathname(filename); diff --git a/lib/libesp32/Berry/tools/coc/block_builder.h b/lib/libesp32/Berry/tools/coc/block_builder.h index 1a45ada3e..2811419eb 100755 --- a/lib/libesp32/Berry/tools/coc/block_builder.h +++ b/lib/libesp32/Berry/tools/coc/block_builder.h @@ -39,7 +39,6 @@ private: std::string scope(const block &block); std::string super(const block &block); std::string name(const block &block); - std::string init(const block &block); void writefile(const std::string &filename, const std::string &text); private: diff --git a/lib/libesp32_lvgl/LVGL_assets/src/lv_theme_openhasp.c b/lib/libesp32_lvgl/LVGL_assets/src/lv_theme_openhasp.c new file mode 100644 index 000000000..b3b0db0c2 --- /dev/null +++ b/lib/libesp32_lvgl/LVGL_assets/src/lv_theme_openhasp.c @@ -0,0 +1,1001 @@ +/** + * @file lv_theme_defau.c + * + */ + +/********************* + * INCLUDES + *********************/ +#include "../lvgl.h" /*To see all the widgets*/ + +#include "lv_theme_openhasp.h" +#include "misc/lv_gc.h" + +/********************* + * DEFINES + *********************/ +#define MODE_DARK 1 +#define RADIUS_DEFAULT (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 8)) + +/*SCREEN*/ +#define LIGHT_COLOR_SCR lv_palette_lighten(LV_PALETTE_GREY, 4) +#define LIGHT_COLOR_CARD lv_color_white() +#define LIGHT_COLOR_TEXT lv_palette_darken(LV_PALETTE_GREY, 4) +#define LIGHT_COLOR_GREY lv_palette_lighten(LV_PALETTE_GREY, 2) +#define DARK_COLOR_SCR lv_color_hex(0x15171A) +#define DARK_COLOR_CARD lv_color_hex(0x545b6a) +#define DARK_COLOR_TEXT lv_color_hex(0xefefef) +#define DARK_COLOR_GREY lv_color_hex(0x2f3237) + +#define TRANSITION_TIME LV_THEME_DEFAULT_TRANSITON_TIME +#define BORDER_WIDTH lv_disp_dpx(theme.disp, 2) +#define OUTLINE_WIDTH lv_disp_dpx(theme.disp, 3) + +#define PAD_DEF (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 24) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 20) : lv_disp_dpx(theme.disp, 16)) +#define PAD_SMALL (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 14) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 10)) +#define PAD_TINY (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 8) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 6) : lv_disp_dpx(theme.disp, 2)) + +/********************** + * TYPEDEFS + **********************/ +typedef struct { + lv_style_t scr; + lv_style_t scrollbar; + lv_style_t scrollbar_scrolled; + lv_style_t card; + lv_style_t btn; + + /*Utility*/ + lv_style_t bg_color_primary; + lv_style_t bg_color_primary_muted; + lv_style_t bg_color_secondary; + lv_style_t bg_color_secondary_muted; + lv_style_t bg_color_grey; + lv_style_t bg_color_white; + lv_style_t pressed; + lv_style_t disabled; + lv_style_t pad_zero; + lv_style_t pad_tiny; + lv_style_t pad_small; + lv_style_t pad_normal; + lv_style_t pad_gap; + lv_style_t line_space_large; + lv_style_t text_align_center; + lv_style_t outline_primary; + lv_style_t outline_secondary; + lv_style_t circle; + lv_style_t no_radius; + lv_style_t clip_corner; +#if LV_THEME_DEFAULT_GROW + lv_style_t grow; +#endif + lv_style_t transition_delayed; + lv_style_t transition_normal; + lv_style_t anim; + + /*Parts*/ + lv_style_t knob; + lv_style_t indic; + +#if LV_USE_ARC + lv_style_t arc_indic; + lv_style_t arc_indic_primary; +#endif + +#if LV_USE_CHART + lv_style_t chart_series, chart_indic, chart_ticks, chart_bg; +#endif + +#if LV_USE_DROPDOWN + lv_style_t dropdown_list; +#endif + +#if LV_USE_CHECKBOX + lv_style_t cb_marker, cb_marker_checked; +#endif + +#if LV_USE_SWITCH + lv_style_t switch_knob; +#endif + +#if LV_USE_LINE + lv_style_t line; +#endif + +#if LV_USE_TABLE + lv_style_t table_cell; +#endif + +#if LV_USE_METER + lv_style_t meter_marker, meter_indic; +#endif + +#if LV_USE_TEXTAREA + lv_style_t ta_cursor, ta_placeholder; +#endif + +#if LV_USE_CALENDAR + lv_style_t calendar_bg, calendar_day; +#endif + +#if LV_USE_COLORWHEEL + lv_style_t colorwheel_main; +#endif + +#if LV_USE_MSGBOX + lv_style_t msgbox_bg, msgbox_btn_bg; +#endif + +#if LV_USE_KEYBOARD + lv_style_t keyboard_btn_bg; +#endif + +#if LV_USE_LIST + lv_style_t list_bg, list_btn, list_item_grow, list_label; +#endif + +#if LV_USE_TABVIEW + lv_style_t tab_bg_focus, tab_btn; +#endif +#if LV_USE_LED + lv_style_t led; +#endif +} my_theme_styles_t; + +typedef struct { + lv_theme_t base; + uint8_t light :1; +}my_theme_t; + +typedef enum { + DISP_SMALL = 3, + DISP_MEDIUM = 2, + DISP_LARGE = 1, +}disp_size_t; + +/********************** + * STATIC PROTOTYPES + **********************/ +static void theme_apply(lv_theme_t * th, lv_obj_t * obj); +static void style_init_reset(lv_style_t * style); + +/********************** + * STATIC VARIABLES + **********************/ +static my_theme_styles_t * styles; +static lv_theme_t theme; +static disp_size_t disp_size; +static bool inited; +static lv_color_t color_scr; +static lv_color_t color_text; +static lv_color_t color_card; +static lv_color_t color_grey; + + +/********************** + * MACROS + **********************/ + +/********************** + * STATIC FUNCTIONS + **********************/ + + +static lv_color_t dark_color_filter_cb(const lv_color_filter_dsc_t * f, lv_color_t c, lv_opa_t opa) +{ + LV_UNUSED(f); + return lv_color_darken(c, opa); +} + +static lv_color_t grey_filter_cb(const lv_color_filter_dsc_t * f, lv_color_t color, lv_opa_t opa) +{ + LV_UNUSED(f); + if(theme.flags & MODE_DARK) return lv_color_mix(lv_palette_darken(LV_PALETTE_GREY, 2), color, opa); + else return lv_color_mix(lv_palette_lighten(LV_PALETTE_GREY, 2), color, opa); +} + +static void style_init(void) +{ + static const lv_style_prop_t trans_props[] = { + LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR, + LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT, + LV_STYLE_TRANSLATE_Y, LV_STYLE_TRANSLATE_X, + LV_STYLE_TRANSFORM_ZOOM, LV_STYLE_TRANSFORM_ANGLE, + LV_STYLE_COLOR_FILTER_OPA, LV_STYLE_COLOR_FILTER_DSC, + 0 + }; + + color_scr = theme.flags & MODE_DARK ? DARK_COLOR_SCR : LIGHT_COLOR_SCR; + color_text = theme.flags & MODE_DARK ? DARK_COLOR_TEXT : LIGHT_COLOR_TEXT; + color_card = theme.flags & MODE_DARK ? DARK_COLOR_CARD : LIGHT_COLOR_CARD; + color_grey = theme.flags & MODE_DARK ? DARK_COLOR_GREY : LIGHT_COLOR_GREY; + + static lv_style_transition_dsc_t trans_delayed; + lv_style_transition_dsc_init(&trans_delayed, trans_props, lv_anim_path_linear, TRANSITION_TIME, 70, NULL); + + static lv_style_transition_dsc_t trans_normal; + lv_style_transition_dsc_init(&trans_normal, trans_props, lv_anim_path_linear, TRANSITION_TIME, 0, NULL); + + style_init_reset(&styles->transition_delayed); + lv_style_set_transition(&styles->transition_delayed, &trans_delayed); /*Go back to default state with delay*/ + + style_init_reset(&styles->transition_normal); + lv_style_set_transition(&styles->transition_normal, &trans_normal); /*Go back to default state with delay*/ + + style_init_reset(&styles->scrollbar); + lv_style_set_bg_color(&styles->scrollbar, (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY, 2) : lv_palette_main(LV_PALETTE_GREY)); + lv_style_set_radius(&styles->scrollbar, LV_RADIUS_CIRCLE); + lv_style_set_pad_right(&styles->scrollbar, lv_disp_dpx(theme.disp, 7)); + lv_style_set_pad_top(&styles->scrollbar, lv_disp_dpx(theme.disp, 7)); + lv_style_set_size(&styles->scrollbar, lv_disp_dpx(theme.disp, 5)); + lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_40); + lv_style_set_transition(&styles->scrollbar, &trans_normal); + + style_init_reset(&styles->scrollbar_scrolled); + lv_style_set_bg_opa(&styles->scrollbar_scrolled, LV_OPA_COVER); + + style_init_reset(&styles->scr); + lv_style_set_bg_opa(&styles->scr, LV_OPA_COVER); + lv_style_set_bg_color(&styles->scr, color_scr); + lv_style_set_text_color(&styles->scr, color_text); + lv_style_set_pad_row(&styles->scr, PAD_SMALL); + lv_style_set_pad_column(&styles->scr, PAD_SMALL); + lv_style_set_text_font(&styles->scr, theme.font_small); + lv_style_set_text_color(&styles->scr, color_text); + + style_init_reset(&styles->card); + lv_style_set_radius(&styles->card, RADIUS_DEFAULT); + lv_style_set_bg_opa(&styles->card, LV_OPA_COVER); + lv_style_set_bg_color(&styles->card, color_card); + lv_style_set_border_color(&styles->card, color_grey); + lv_style_set_border_width(&styles->card, BORDER_WIDTH); + lv_style_set_border_post(&styles->card, true); + lv_style_set_text_color(&styles->card, color_text); + lv_style_set_pad_all(&styles->card, PAD_DEF); + lv_style_set_pad_row(&styles->card, PAD_SMALL); + lv_style_set_pad_column(&styles->card, PAD_SMALL); + lv_style_set_line_color(&styles->card, lv_palette_main(LV_PALETTE_GREY)); + lv_style_set_line_width(&styles->card, lv_disp_dpx(theme.disp, 1)); + + style_init_reset(&styles->outline_primary); + lv_style_set_outline_color(&styles->outline_primary, theme.color_primary); + lv_style_set_outline_width(&styles->outline_primary, OUTLINE_WIDTH); + lv_style_set_outline_pad(&styles->outline_primary, OUTLINE_WIDTH); + lv_style_set_outline_opa(&styles->outline_primary, LV_OPA_50); + + style_init_reset(&styles->outline_secondary); + lv_style_set_outline_color(&styles->outline_secondary, theme.color_secondary); + lv_style_set_outline_width(&styles->outline_secondary, OUTLINE_WIDTH); + lv_style_set_outline_opa(&styles->outline_secondary, LV_OPA_50); + + style_init_reset(&styles->btn); + lv_style_set_radius(&styles->btn, (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 16) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 8))); + lv_style_set_bg_opa(&styles->btn, LV_OPA_COVER); + lv_style_set_bg_color(&styles->btn, color_grey); + if(!(theme.flags & MODE_DARK)) { + lv_style_set_shadow_color(&styles->btn, lv_palette_lighten(LV_PALETTE_GREY, 3)); + lv_style_set_shadow_width(&styles->btn, 1); + lv_style_set_shadow_ofs_y(&styles->btn, lv_disp_dpx(theme.disp, 4)); + } + lv_style_set_text_color(&styles->btn, color_text); + lv_style_set_pad_hor(&styles->btn, PAD_DEF); + lv_style_set_pad_ver(&styles->btn, PAD_SMALL); + lv_style_set_pad_column(&styles->btn, lv_disp_dpx(theme.disp, 5)); + lv_style_set_pad_row(&styles->btn, lv_disp_dpx(theme.disp, 5)); + lv_style_set_text_font(&styles->btn, theme.font_normal); + + static lv_color_filter_dsc_t dark_filter; + lv_color_filter_dsc_init(&dark_filter, dark_color_filter_cb); + + static lv_color_filter_dsc_t grey_filter; + lv_color_filter_dsc_init(&grey_filter, grey_filter_cb); + + style_init_reset(&styles->pressed); + lv_style_set_color_filter_dsc(&styles->pressed, &dark_filter); + lv_style_set_color_filter_opa(&styles->pressed, 35); + + style_init_reset(&styles->disabled); + lv_style_set_color_filter_dsc(&styles->disabled, &grey_filter); + lv_style_set_color_filter_opa(&styles->disabled, LV_OPA_50); + + style_init_reset(&styles->clip_corner); + lv_style_set_clip_corner(&styles->clip_corner, true); + + style_init_reset(&styles->pad_normal); + lv_style_set_pad_all(&styles->pad_normal, PAD_DEF); + lv_style_set_pad_row(&styles->pad_normal, PAD_DEF); + lv_style_set_pad_column(&styles->pad_normal, PAD_DEF); + + style_init_reset(&styles->pad_small); + lv_style_set_pad_all(&styles->pad_small, PAD_SMALL); + lv_style_set_pad_gap(&styles->pad_small, PAD_SMALL); + + style_init_reset(&styles->pad_gap); + lv_style_set_pad_row(&styles->pad_gap, lv_disp_dpx(theme.disp, 10)); + lv_style_set_pad_column(&styles->pad_gap, lv_disp_dpx(theme.disp, 10)); + + style_init_reset(&styles->line_space_large); + lv_style_set_text_line_space(&styles->line_space_large, lv_disp_dpx(theme.disp, 20)); + + style_init_reset(&styles->text_align_center); + lv_style_set_text_align(&styles->text_align_center, LV_TEXT_ALIGN_CENTER); + + style_init_reset(&styles->pad_zero); + lv_style_set_pad_all(&styles->pad_zero, 0); + lv_style_set_pad_row(&styles->pad_zero, 0); + lv_style_set_pad_column(&styles->pad_zero, 0); + + style_init_reset(&styles->pad_tiny); + lv_style_set_pad_all(&styles->pad_tiny, PAD_TINY); + lv_style_set_pad_row(&styles->pad_tiny, PAD_TINY); + lv_style_set_pad_column(&styles->pad_tiny, PAD_TINY); + + style_init_reset(&styles->bg_color_primary); + lv_style_set_bg_color(&styles->bg_color_primary, theme.color_primary); + lv_style_set_text_color(&styles->bg_color_primary, lv_color_white()); + lv_style_set_bg_opa(&styles->bg_color_primary, LV_OPA_COVER); + + style_init_reset(&styles->bg_color_primary_muted); + lv_style_set_bg_color(&styles->bg_color_primary_muted, theme.color_primary); + lv_style_set_text_color(&styles->bg_color_primary_muted, theme.color_primary); + lv_style_set_bg_opa(&styles->bg_color_primary_muted, LV_OPA_20); + + style_init_reset(&styles->bg_color_secondary); + lv_style_set_bg_color(&styles->bg_color_secondary, theme.color_secondary); + lv_style_set_text_color(&styles->bg_color_secondary, lv_color_white()); + lv_style_set_bg_opa(&styles->bg_color_secondary, LV_OPA_COVER); + + style_init_reset(&styles->bg_color_secondary_muted); + lv_style_set_bg_color(&styles->bg_color_secondary_muted, theme.color_secondary); + lv_style_set_text_color(&styles->bg_color_secondary_muted, theme.color_secondary); + lv_style_set_bg_opa(&styles->bg_color_secondary_muted, LV_OPA_20); + + style_init_reset(&styles->bg_color_grey); + lv_style_set_bg_color(&styles->bg_color_grey, color_grey); + lv_style_set_bg_opa(&styles->bg_color_grey, LV_OPA_COVER); + lv_style_set_text_color(&styles->bg_color_grey, color_text); + + style_init_reset(&styles->bg_color_white); + lv_style_set_bg_color(&styles->bg_color_white, color_card); + lv_style_set_bg_opa(&styles->bg_color_white, LV_OPA_COVER); + lv_style_set_text_color(&styles->bg_color_white, color_text); + + style_init_reset(&styles->circle); + lv_style_set_radius(&styles->circle, LV_RADIUS_CIRCLE); + + style_init_reset(&styles->no_radius); + lv_style_set_radius(&styles->no_radius, 0); + +#if LV_THEME_DEFAULT_GROW + style_init_reset(&styles->grow); + lv_style_set_transform_width(&styles->grow, lv_disp_dpx(theme.disp, 3)); + lv_style_set_transform_height(&styles->grow, lv_disp_dpx(theme.disp, 3)); +#endif + + style_init_reset(&styles->knob); + lv_style_set_bg_color(&styles->knob, theme.color_primary); + lv_style_set_bg_opa(&styles->knob, LV_OPA_COVER); + lv_style_set_pad_all(&styles->knob, lv_disp_dpx(theme.disp, 6)); + lv_style_set_radius(&styles->knob, LV_RADIUS_CIRCLE); + + style_init_reset(&styles->anim); + lv_style_set_anim_time(&styles->anim, 200); + +#if LV_USE_ARC + style_init_reset(&styles->arc_indic); + lv_style_set_arc_color(&styles->arc_indic, color_grey); + lv_style_set_arc_width(&styles->arc_indic, lv_disp_dpx(theme.disp, 15)); + lv_style_set_arc_rounded(&styles->arc_indic, true); + + style_init_reset(&styles->arc_indic_primary); + lv_style_set_arc_color(&styles->arc_indic_primary, theme.color_primary); +#endif + +#if LV_USE_DROPDOWN + style_init_reset(&styles->dropdown_list); + lv_style_set_max_height(&styles->dropdown_list, LV_DPI_DEF * 2); +#endif +#if LV_USE_CHECKBOX + style_init_reset(&styles->cb_marker); + lv_style_set_pad_all(&styles->cb_marker, lv_disp_dpx(theme.disp, 3)); + lv_style_set_border_width(&styles->cb_marker, BORDER_WIDTH); + lv_style_set_border_color(&styles->cb_marker, theme.color_primary); + lv_style_set_bg_color(&styles->cb_marker, color_card); + lv_style_set_bg_opa(&styles->cb_marker, LV_OPA_COVER); + lv_style_set_radius(&styles->cb_marker, RADIUS_DEFAULT / 2); + + style_init_reset(&styles->cb_marker_checked); + lv_style_set_bg_img_src(&styles->cb_marker_checked, LV_SYMBOL_OK); + lv_style_set_text_color(&styles->cb_marker_checked, lv_color_white()); + lv_style_set_text_font(&styles->cb_marker_checked, theme.font_small); +#endif + +#if LV_USE_SWITCH + style_init_reset(&styles->switch_knob); + lv_style_set_pad_all(&styles->switch_knob, - lv_disp_dpx(theme.disp, 4)); + lv_style_set_bg_color(&styles->switch_knob, lv_color_white()); +#endif + +#if LV_USE_LINE + style_init_reset(&styles->line); + lv_style_set_line_width(&styles->line, 1); + lv_style_set_line_color(&styles->line, color_text); +#endif + +#if LV_USE_CHART + style_init_reset(&styles->chart_bg); + lv_style_set_border_post(&styles->chart_bg, false); + lv_style_set_pad_column(&styles->chart_bg, lv_disp_dpx(theme.disp, 10)); + lv_style_set_line_color(&styles->chart_bg, color_grey); + + style_init_reset(&styles->chart_series); + lv_style_set_line_width(&styles->chart_series, lv_disp_dpx(theme.disp, 3)); + lv_style_set_radius(&styles->chart_series, lv_disp_dpx(theme.disp, 3)); + lv_style_set_size(&styles->chart_series, lv_disp_dpx(theme.disp, 8)); + lv_style_set_pad_column(&styles->chart_series, lv_disp_dpx(theme.disp, 2)); + + style_init_reset(&styles->chart_indic); + lv_style_set_radius(&styles->chart_indic,LV_RADIUS_CIRCLE); + lv_style_set_size(&styles->chart_indic, lv_disp_dpx(theme.disp, 8)); + lv_style_set_bg_color(&styles->chart_indic, theme.color_primary); + lv_style_set_bg_opa(&styles->chart_indic, LV_OPA_COVER); + + style_init_reset(&styles->chart_ticks); + lv_style_set_line_width(&styles->chart_ticks, lv_disp_dpx(theme.disp, 1)); + lv_style_set_line_color(&styles->chart_ticks, color_text); + lv_style_set_pad_all(&styles->chart_ticks, lv_disp_dpx(theme.disp, 2)); + lv_style_set_text_color(&styles->chart_ticks, lv_palette_main(LV_PALETTE_GREY)); +#endif + +#if LV_USE_METER + style_init_reset(&styles->meter_marker); + lv_style_set_line_width(&styles->meter_marker, lv_disp_dpx(theme.disp, 5)); + lv_style_set_line_color(&styles->meter_marker, color_text); + lv_style_set_size(&styles->meter_marker, lv_disp_dpx(theme.disp, 20)); + lv_style_set_pad_left(&styles->meter_marker, lv_disp_dpx(theme.disp, 15)); + + style_init_reset(&styles->meter_indic); + lv_style_set_radius(&styles->meter_indic, LV_RADIUS_CIRCLE); + lv_style_set_bg_color(&styles->meter_indic, color_text); + lv_style_set_bg_opa(&styles->meter_indic, LV_OPA_COVER); + lv_style_set_size(&styles->meter_indic, lv_disp_dpx(theme.disp, 15)); +#endif + +#if LV_USE_TABLE + style_init_reset(&styles->table_cell); + lv_style_set_border_width(&styles->table_cell, lv_disp_dpx(theme.disp, 1)); + lv_style_set_border_color(&styles->table_cell, color_grey); + lv_style_set_border_side(&styles->table_cell, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM ); +#endif + +#if LV_USE_TEXTAREA + style_init_reset(&styles->ta_cursor); + lv_style_set_border_color(&styles->ta_cursor, color_text); + lv_style_set_border_width(&styles->ta_cursor, lv_disp_dpx(theme.disp, 2)); + lv_style_set_pad_left(&styles->ta_cursor, lv_disp_dpx(theme.disp, 1)); + lv_style_set_border_side(&styles->ta_cursor, LV_BORDER_SIDE_LEFT); + lv_style_set_anim_time(&styles->ta_cursor, 400); + + style_init_reset(&styles->ta_placeholder); + lv_style_set_text_color(&styles->ta_placeholder, (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY, 2) : lv_palette_lighten(LV_PALETTE_GREY, 1)); +#endif + +#if LV_USE_CALENDAR + style_init_reset(&styles->calendar_bg); + lv_style_set_pad_all(&styles->calendar_bg, PAD_SMALL); + lv_style_set_pad_gap(&styles->calendar_bg, PAD_SMALL / 2); + lv_style_set_radius(&styles->calendar_bg, 0); + + style_init_reset(&styles->calendar_day); + lv_style_set_border_width(&styles->calendar_day, lv_disp_dpx(theme.disp, 1)); + lv_style_set_border_color(&styles->calendar_day, color_grey); + lv_style_set_bg_color(&styles->calendar_day, color_card); + lv_style_set_bg_opa(&styles->calendar_day, LV_OPA_20); +#endif + +#if LV_USE_COLORWHEEL + style_init_reset(&styles->colorwheel_main); + lv_style_set_arc_width(&styles->colorwheel_main, lv_disp_dpx(theme.disp, 10)); +#endif + +#if LV_USE_MSGBOX + /*To add space for for the button shadow*/ + style_init_reset(&styles->msgbox_btn_bg); + lv_style_set_pad_all(&styles->msgbox_btn_bg, lv_disp_dpx(theme.disp, 4)); + + style_init_reset(&styles->msgbox_bg); + lv_style_set_max_width(&styles->msgbox_bg, lv_pct(100)); +#endif +#if LV_USE_KEYBOARD + style_init_reset(&styles->keyboard_btn_bg); + lv_style_set_shadow_width(&styles->keyboard_btn_bg, 0); + lv_style_set_radius(&styles->keyboard_btn_bg, disp_size == DISP_SMALL ? RADIUS_DEFAULT / 2 : RADIUS_DEFAULT); +#endif + +#if LV_USE_TABVIEW + style_init_reset(&styles->tab_btn); + lv_style_set_border_color(&styles->tab_btn, theme.color_primary); + lv_style_set_border_width(&styles->tab_btn, BORDER_WIDTH * 2); + lv_style_set_border_side(&styles->tab_btn, LV_BORDER_SIDE_BOTTOM); + + style_init_reset(&styles->tab_bg_focus); + lv_style_set_outline_pad(&styles->tab_bg_focus, -BORDER_WIDTH); +#endif + +#if LV_USE_LIST + style_init_reset(&styles->list_bg); + lv_style_set_pad_hor(&styles->list_bg, PAD_DEF); + lv_style_set_pad_ver(&styles->list_bg, 0); + lv_style_set_pad_gap(&styles->list_bg, 0); + lv_style_set_clip_corner(&styles->list_bg, true); + + style_init_reset(&styles->list_btn); + lv_style_set_border_width(&styles->list_btn, lv_disp_dpx(theme.disp, 1)); + lv_style_set_border_color(&styles->list_btn, color_grey); + lv_style_set_border_side(&styles->list_btn, LV_BORDER_SIDE_BOTTOM); + lv_style_set_pad_all(&styles->list_btn, PAD_SMALL); + lv_style_set_pad_column(&styles->list_btn, PAD_SMALL); + + style_init_reset(&styles->list_item_grow); + lv_style_set_transform_width(&styles->list_item_grow, PAD_DEF); +#endif + + +#if LV_USE_LED + style_init_reset(&styles->led); + lv_style_set_bg_opa(&styles->led, LV_OPA_COVER); + lv_style_set_bg_color(&styles->led, lv_color_white()); + lv_style_set_bg_grad_color(&styles->led, lv_palette_main(LV_PALETTE_GREY)); + lv_style_set_radius(&styles->led, LV_RADIUS_CIRCLE); + lv_style_set_shadow_width(&styles->led, lv_disp_dpx(theme.disp, 15)); + lv_style_set_shadow_color(&styles->led, lv_color_white()); + lv_style_set_shadow_spread(&styles->led, lv_disp_dpx(theme.disp, 5)); +#endif +} + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font) +{ + + /*This trick is required only to avoid the garbage collection of + *styles' data if LVGL is used in a binding (e.g. Micropython) + *In a general case styles could be in simple `static lv_style_t my_style...` variables*/ + if(!inited) { + LV_GC_ROOT(_lv_theme_default_styles) = lv_mem_alloc(sizeof(my_theme_styles_t)); + styles = (my_theme_styles_t *)LV_GC_ROOT(_lv_theme_default_styles); + } + + if(LV_HOR_RES <= 320) disp_size = DISP_SMALL; + else if(LV_HOR_RES < 720) disp_size = DISP_MEDIUM; + else disp_size = DISP_LARGE; + + theme.disp = disp; + theme.color_primary = color_primary; + theme.color_secondary = color_secondary; + theme.font_small = font; + theme.font_normal = font; + theme.font_large = font; + theme.apply_cb = theme_apply; + theme.flags = dark ? MODE_DARK : 0; + + style_init(); + + inited = true; + + if(disp == NULL || lv_disp_get_theme(disp) == &theme) lv_obj_report_style_change(NULL); + + return (lv_theme_t *)&theme; +} + +bool lv_theme_openhasp_is_inited(void) +{ + return inited; +} + + +static void theme_apply(lv_theme_t * th, lv_obj_t * obj) +{ + LV_UNUSED(th); + + if(lv_obj_get_parent(obj) == NULL) { + lv_obj_add_style(obj, &styles->scr, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + return; + } + + if(lv_obj_check_type(obj, &lv_obj_class)) { +#if LV_USE_TABVIEW + lv_obj_t * parent = lv_obj_get_parent(obj); + /*Tabview content area*/ + if(lv_obj_check_type(parent, &lv_tabview_class)) { + return; + } + /*Tabview pages*/ + else if(lv_obj_check_type(lv_obj_get_parent(parent), &lv_tabview_class)) { + lv_obj_add_style(obj, &styles->pad_normal, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + return; + } +#endif + +#if LV_USE_WIN + /*Header*/ + if(lv_obj_get_child_id(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) { + lv_obj_add_style(obj, &styles->bg_color_grey, 0); + lv_obj_add_style(obj, &styles->pad_tiny, 0); + return; + } + /*Content*/ + else if(lv_obj_get_child_id(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) { + lv_obj_add_style(obj, &styles->scr, 0); + lv_obj_add_style(obj, &styles->pad_normal, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + return; + } +#endif + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + } + #if LV_USE_BTN + else if(lv_obj_check_type(obj, &lv_btn_class)) { + lv_obj_add_style(obj, &styles->btn, 0); + lv_obj_add_style(obj, &styles->bg_color_primary, 0); + lv_obj_add_style(obj, &styles->transition_delayed, 0); + lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->transition_normal, LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); +#if LV_THEME_DEFAULT_GROW + lv_obj_add_style(obj, &styles->grow, LV_STATE_PRESSED); +#endif + lv_obj_add_style(obj, &styles->bg_color_secondary, LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED); + } +#endif + +#if LV_USE_LINE + else if(lv_obj_check_type(obj, &lv_line_class)) { + lv_obj_add_style(obj, &styles->line, 0); + } +#endif + +#if LV_USE_BTNMATRIX + else if(lv_obj_check_type(obj, &lv_btnmatrix_class)) { +#if LV_USE_MSGBOX + if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) { + lv_obj_add_style(obj, &styles->msgbox_btn_bg, 0); + lv_obj_add_style(obj, &styles->pad_gap, 0); + lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->bg_color_secondary_muted, LV_PART_ITEMS | LV_STATE_EDITED); + return; + } +#endif +#if LV_USE_TABVIEW + if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_tabview_class)) { + lv_obj_add_style(obj, &styles->bg_color_white, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->tab_bg_focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->tab_btn, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->tab_bg_focus, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + return; + } +#endif + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); + } +#endif + +#if LV_USE_BAR + else if(lv_obj_check_type(obj, &lv_bar_class)) { + lv_obj_add_style(obj, &styles->bg_color_primary_muted, 0); + lv_obj_add_style(obj, &styles->circle, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR); + } +#endif + +#if LV_USE_SLIDER + else if(lv_obj_check_type(obj, &lv_slider_class)) { + lv_obj_add_style(obj, &styles->bg_color_primary_muted, 0); + lv_obj_add_style(obj, &styles->circle, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB); +#if LV_THEME_DEFAULT_GROW + lv_obj_add_style(obj, &styles->grow, LV_PART_KNOB | LV_STATE_PRESSED); +#endif + lv_obj_add_style(obj, &styles->transition_delayed, LV_PART_KNOB); + lv_obj_add_style(obj, &styles->transition_normal, LV_PART_KNOB | LV_STATE_PRESSED); + } +#endif + +#if LV_USE_TABLE + else if(lv_obj_check_type(obj, &lv_table_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->pad_zero, 0); + lv_obj_add_style(obj, &styles->no_radius, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->table_cell, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->pad_normal, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->bg_color_secondary, LV_PART_ITEMS | LV_STATE_EDITED); + } +#endif + +#if LV_USE_CHECKBOX + else if(lv_obj_check_type(obj, &lv_checkbox_class)) { + lv_obj_add_style(obj, &styles->pad_gap, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); + lv_obj_add_style(obj, &styles->cb_marker, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->cb_marker_checked, LV_PART_INDICATOR | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->pressed, LV_PART_INDICATOR | LV_STATE_PRESSED); +#if LV_THEME_DEFAULT_GROW + lv_obj_add_style(obj, &styles->grow, LV_PART_INDICATOR | LV_STATE_PRESSED); +#endif + lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR | LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->transition_delayed, LV_PART_INDICATOR); + } +#endif + +#if LV_USE_SWITCH + else if(lv_obj_check_type(obj, &lv_switch_class)) { + lv_obj_add_style(obj, &styles->bg_color_grey, 0); + lv_obj_add_style(obj, &styles->circle, 0); + lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); + lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB); + lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_KNOB); + lv_obj_add_style(obj, &styles->switch_knob, LV_PART_KNOB); + lv_obj_add_style(obj, &styles->disabled, LV_PART_KNOB | LV_STATE_DISABLED); + } +#endif + +#if LV_USE_CHART + else if(lv_obj_check_type(obj, &lv_chart_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->pad_small, 0); + lv_obj_add_style(obj, &styles->chart_bg, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &styles->chart_series, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->chart_indic, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->chart_ticks, LV_PART_TICKS); + lv_obj_add_style(obj, &styles->chart_series, LV_PART_CURSOR); + } +#endif + +#if LV_USE_ROLLER + else if(lv_obj_check_type(obj, &lv_roller_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->anim, 0); + lv_obj_add_style(obj, &styles->line_space_large, 0); + lv_obj_add_style(obj, &styles->text_align_center, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_SELECTED); + } +#endif + +#if LV_USE_DROPDOWN + else if(lv_obj_check_type(obj, &lv_dropdown_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->pad_small, 0); + lv_obj_add_style(obj, &styles->transition_delayed, 0); + lv_obj_add_style(obj, &styles->transition_normal, LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR); + } + else if(lv_obj_check_type(obj, &lv_dropdownlist_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->clip_corner, 0); + lv_obj_add_style(obj, &styles->line_space_large, 0); + lv_obj_add_style(obj, &styles->dropdown_list, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_SELECTED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_SELECTED | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->pressed, LV_PART_SELECTED | LV_STATE_PRESSED); + } +#endif + +#if LV_USE_ARC + else if(lv_obj_check_type(obj, &lv_arc_class)) { + lv_obj_add_style(obj, &styles->arc_indic, 0); + lv_obj_add_style(obj, &styles->arc_indic, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->arc_indic_primary, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB); + } +#endif + + +#if LV_USE_SPINNER + else if(lv_obj_check_type(obj, &lv_spinner_class)) { + lv_obj_add_style(obj, &styles->arc_indic, 0); + lv_obj_add_style(obj, &styles->arc_indic, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->arc_indic_primary, LV_PART_INDICATOR); + } +#endif + +#if LV_USE_METER + else if(lv_obj_check_type(obj, &lv_meter_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->circle, 0); + lv_obj_add_style(obj, &styles->meter_indic, LV_PART_INDICATOR); + } +#endif + +#if LV_USE_TEXTAREA + else if(lv_obj_check_type(obj, &lv_textarea_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->pad_small, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &styles->ta_cursor, LV_PART_CURSOR | LV_STATE_FOCUSED); + lv_obj_add_style(obj, &styles->ta_placeholder, LV_PART_TEXTAREA_PLACEHOLDER); + } +#endif + +#if LV_USE_CALENDAR + else if(lv_obj_check_type(obj, &lv_calendar_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->calendar_bg, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->calendar_day, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); + } +#endif + +#if LV_USE_CALENDAR_HEADER_ARROW + else if(lv_obj_check_type(obj, &lv_calendar_header_arrow_class)) { + lv_obj_add_style(obj, &styles->card, 0); + } +#endif + +#if LV_USE_CALENDAR_HEADER_DROPDOWN + else if(lv_obj_check_type(obj, &lv_calendar_header_dropdown_class)) { + lv_obj_add_style(obj, &styles->card, 0); + } +#endif + +#if LV_USE_KEYBOARD + else if(lv_obj_check_type(obj, &lv_keyboard_class)) { + lv_obj_add_style(obj, &styles->scr, 0); + lv_obj_add_style(obj, disp_size == DISP_LARGE ? &styles->pad_small : &styles->pad_tiny, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->keyboard_btn_bg, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->bg_color_grey, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->bg_color_secondary_muted, LV_PART_ITEMS | LV_STATE_EDITED); + } +#endif +#if LV_USE_LIST + else if(lv_obj_check_type(obj, &lv_list_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->list_bg, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + return; + } + else if(lv_obj_check_type(obj, &lv_list_text_class)) { + lv_obj_add_style(obj, &styles->bg_color_grey, 0); + lv_obj_add_style(obj, &styles->list_item_grow, 0); + } + else if(lv_obj_check_type(obj, &lv_list_btn_class)) { + lv_obj_add_style(obj, &styles->bg_color_white, 0); + lv_obj_add_style(obj, &styles->list_btn, 0); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->list_item_grow, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->list_item_grow, LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED); + + } +#endif +#if LV_USE_MSGBOX + else if(lv_obj_check_type(obj, &lv_msgbox_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->msgbox_bg, 0); + return; + } +#endif +#if LV_USE_SPINBOX + else if(lv_obj_check_type(obj, &lv_spinbox_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->pad_small, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_CURSOR); + } +#endif +#if LV_USE_TILEVIEW + else if(lv_obj_check_type(obj, &lv_tileview_class)) { + lv_obj_add_style(obj, &styles->scr, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + } + else if(lv_obj_check_type(obj, &lv_tileview_tile_class)) { + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + } +#endif + +#if LV_USE_TABVIEW + if(lv_obj_check_type(obj, &lv_tabview_class)) { + lv_obj_add_style(obj, &styles->scr, 0); + lv_obj_add_style(obj, &styles->pad_zero, 0); + return; + } +#endif + +#if LV_USE_COLORWHEEL + else if(lv_obj_check_type(obj, &lv_colorwheel_class)) { + lv_obj_add_style(obj, &styles->colorwheel_main, 0); + lv_obj_add_style(obj, &styles->pad_normal, 0); + lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_KNOB); + lv_obj_add_style(obj, &styles->pad_normal, LV_PART_KNOB); + } +#endif + +#if LV_USE_LED + else if(lv_obj_check_type(obj, &lv_led_class)) { + lv_obj_add_style(obj, &styles->led, 0); + } +#endif +} + +/********************** + * STATIC FUNCTIONS + **********************/ + +static void style_init_reset(lv_style_t * style) +{ + if(inited) lv_style_reset(style); + else lv_style_init(style); +} diff --git a/lib/libesp32_lvgl/LVGL_assets/src/lv_theme_openhasp.h b/lib/libesp32_lvgl/LVGL_assets/src/lv_theme_openhasp.h new file mode 100644 index 000000000..fcd755cbb --- /dev/null +++ b/lib/libesp32_lvgl/LVGL_assets/src/lv_theme_openhasp.h @@ -0,0 +1,49 @@ +/** + * @file lv_theme_openhasp.h + * + */ + +#ifndef LV_THEME_OPENHASP_H +#define LV_THEME_OPENHASP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "core/lv_obj.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/** + * Initialize the theme + * @param color_primary the primary color of the theme + * @param color_secondary the secondary color for the theme + * @param font pointer to a font to use. + * @return a pointer to reference this theme later + */ +lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font); + +bool lv_theme_openhasp_is_inited(void); + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*LV_THEME_DEFAULT_H*/ diff --git a/tasmota/lvgl_berry/be_lv_c_mapping.h b/tasmota/lvgl_berry/be_lv_c_mapping.h index 4745859c6..1a110c163 100644 --- a/tasmota/lvgl_berry/be_lv_c_mapping.h +++ b/tasmota/lvgl_berry/be_lv_c_mapping.h @@ -110,6 +110,10 @@ const lvbe_call_c_t lv_font_func[] = { const lvbe_call_c_t lv_color_func[] = { }; +/* `lv_theme` methods */ +const lvbe_call_c_t lv_theme_func[] = { +}; + /* `lv_img` methods */ #ifdef BE_LV_WIDGET_IMG const lvbe_call_c_t lv_img_func[] = { @@ -131,12 +135,30 @@ const lvbe_call_c_t lv_img_func[] = { }; #endif // BE_LV_WIDGET_IMG +/* `lv_disp` methods */ +const lvbe_call_c_t lv_disp_func[] = { + { "clean_dcache", (void*) &lv_disp_clean_dcache, "", "(lv.lv_disp)" }, + { "dpx", (void*) &lv_disp_dpx, "i", "(lv.lv_disp)i" }, + { "get_inactive_time", (void*) &lv_disp_get_inactive_time, "i", "(lv.lv_disp)" }, + { "get_layer_sys", (void*) &lv_disp_get_layer_sys, "lv.lv_obj", "(lv.lv_disp)" }, + { "get_layer_top", (void*) &lv_disp_get_layer_top, "lv.lv_obj", "(lv.lv_disp)" }, + { "get_scr_act", (void*) &lv_disp_get_scr_act, "lv.lv_obj", "(lv.lv_disp)" }, + { "get_scr_prev", (void*) &lv_disp_get_scr_prev, "lv.lv_obj", "(lv.lv_disp)" }, + { "get_theme", (void*) &lv_disp_get_theme, "lv.lv_theme", "(lv.lv_disp)" }, + { "load_scr", (void*) &lv_disp_load_scr, "", "(lv.lv_obj)" }, + { "set_bg_color", (void*) &lv_disp_set_bg_color, "", "(lv.lv_disp)(lv.lv_color)" }, + { "set_bg_image", (void*) &lv_disp_set_bg_image, "", "(lv.lv_disp)." }, + { "set_bg_opa", (void*) &lv_disp_set_bg_opa, "", "(lv.lv_disp)i" }, + { "set_theme", (void*) &lv_disp_set_theme, "", "(lv.lv_disp)(lv.lv_theme)" }, + { "trig_activity", (void*) &lv_disp_trig_activity, "", "(lv.lv_disp)" }, +}; + /* `lv_obj` methods */ const lvbe_call_c_t lv_obj_func[] = { { "add_event_cb", (void*) &lv_obj_add_event_cb, "i", "(lv.lv_obj)^lv_event_cb^i." }, { "add_flag", (void*) &lv_obj_add_flag, "", "(lv.lv_obj)i" }, { "add_state", (void*) &lv_obj_add_state, "", "(lv.lv_obj)i" }, - { "add_style", (void*) &lv_obj_add_style, "", "(lv.lv_obj)(lv.lv_style)(lv.lv_style_selector)" }, + { "add_style", (void*) &lv_obj_add_style, "", "(lv.lv_obj)(lv.lv_style)i" }, { "align", (void*) &lv_obj_align, "", "(lv.lv_obj)iii" }, { "align_to", (void*) &lv_obj_align_to, "", "(lv.lv_obj)(lv.lv_obj)iii" }, { "allocate_spec_attr", (void*) &lv_obj_allocate_spec_attr, "", "(lv.lv_obj)" }, @@ -162,9 +184,10 @@ const lvbe_call_c_t lv_obj_func[] = { { "get_content_height", (void*) &lv_obj_get_content_height, "i", "(lv.lv_obj)" }, { "get_content_width", (void*) &lv_obj_get_content_width, "i", "(lv.lv_obj)" }, { "get_coords", (void*) &lv_obj_get_coords, "", "(lv.lv_obj)(lv.lv_area)" }, + { "get_disp", (void*) &lv_obj_get_disp, "lv.lv_disp", "(lv.lv_obj)" }, { "get_group", (void*) &lv_obj_get_group, ".", "(lv.lv_obj)" }, { "get_height", (void*) &lv_obj_get_height, "i", "(lv.lv_obj)" }, - { "get_local_style_prop", (void*) &lv_obj_get_local_style_prop, "i", "(lv.lv_obj)(lv.lv_style_prop)(lv.lv_style_value)(lv.lv_style_selector)" }, + { "get_local_style_prop", (void*) &lv_obj_get_local_style_prop, "i", "(lv.lv_obj)(lv.lv_style_prop)(lv.lv_style_value)i" }, { "get_parent", (void*) &lv_obj_get_parent, "lv.lv_obj", "(lv.lv_obj)" }, { "get_screen", (void*) &lv_obj_get_screen, "lv.lv_obj", "(lv.lv_obj)" }, { "get_scroll_bottom", (void*) &lv_obj_get_scroll_bottom, "i", "(lv.lv_obj)" }, @@ -307,8 +330,8 @@ const lvbe_call_c_t lv_obj_func[] = { { "refresh_style", (void*) &lv_obj_refresh_style, "", "(lv.lv_obj)i(lv.lv_style_prop)" }, { "remove_event_cb", (void*) &lv_obj_remove_event_cb, "b", "(lv.lv_obj)^lv_event_cb^" }, { "remove_event_dsc", (void*) &lv_obj_remove_event_dsc, "b", "(lv.lv_obj)i" }, - { "remove_local_style_prop", (void*) &lv_obj_remove_local_style_prop, "b", "(lv.lv_obj)(lv.lv_style_prop)(lv.lv_style_selector)" }, - { "remove_style", (void*) &lv_obj_remove_style, "", "(lv.lv_obj)(lv.lv_style)(lv.lv_style_selector)" }, + { "remove_local_style_prop", (void*) &lv_obj_remove_local_style_prop, "b", "(lv.lv_obj)(lv.lv_style_prop)i" }, + { "remove_style", (void*) &lv_obj_remove_style, "", "(lv.lv_obj)(lv.lv_style)i" }, { "remove_style_all", (void*) &lv_obj_remove_style_all, "", "(lv.lv_obj)" }, { "scroll_by", (void*) &lv_obj_scroll_by, "", "(lv.lv_obj)ii(lv.lv_anim_enable)" }, { "scroll_to", (void*) &lv_obj_scroll_to, "", "(lv.lv_obj)ii(lv.lv_anim_enable)" }, @@ -323,7 +346,7 @@ const lvbe_call_c_t lv_obj_func[] = { { "set_ext_click_area", (void*) &lv_obj_set_ext_click_area, "", "(lv.lv_obj)i" }, { "set_height", (void*) &lv_obj_set_height, "", "(lv.lv_obj)i" }, { "set_layout", (void*) &lv_obj_set_layout, "", "(lv.lv_obj)i" }, - { "set_local_style_prop", (void*) &lv_obj_set_local_style_prop, "", "(lv.lv_obj)(lv.lv_style_prop)i(lv.lv_style_selector)" }, + { "set_local_style_prop", (void*) &lv_obj_set_local_style_prop, "", "(lv.lv_obj)(lv.lv_style_prop)ii" }, { "set_parent", (void*) &lv_obj_set_parent, "", "(lv.lv_obj)(lv.lv_obj)" }, { "set_pos", (void*) &lv_obj_set_pos, "", "(lv.lv_obj)ii" }, { "set_scroll_dir", (void*) &lv_obj_set_scroll_dir, "", "(lv.lv_obj)i" }, @@ -331,100 +354,100 @@ const lvbe_call_c_t lv_obj_func[] = { { "set_scroll_snap_y", (void*) &lv_obj_set_scroll_snap_y, "", "(lv.lv_obj)i" }, { "set_scrollbar_mode", (void*) &lv_obj_set_scrollbar_mode, "", "(lv.lv_obj)i" }, { "set_size", (void*) &lv_obj_set_size, "", "(lv.lv_obj)ii" }, - { "set_style_align", (void*) &lv_obj_set_style_align, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_anim_speed", (void*) &lv_obj_set_style_anim_speed, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_anim_time", (void*) &lv_obj_set_style_anim_time, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_arc_color", (void*) &lv_obj_set_style_arc_color, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_arc_color_filtered", (void*) &lv_obj_set_style_arc_color_filtered, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_arc_img_src", (void*) &lv_obj_set_style_arc_img_src, "", "(lv.lv_obj).(lv.lv_style_selector)" }, - { "set_style_arc_opa", (void*) &lv_obj_set_style_arc_opa, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_arc_rounded", (void*) &lv_obj_set_style_arc_rounded, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_arc_width", (void*) &lv_obj_set_style_arc_width, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_base_dir", (void*) &lv_obj_set_style_base_dir, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_bg_color", (void*) &lv_obj_set_style_bg_color, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_bg_color_filtered", (void*) &lv_obj_set_style_bg_color_filtered, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_bg_grad_color", (void*) &lv_obj_set_style_bg_grad_color, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_bg_grad_color_filtered", (void*) &lv_obj_set_style_bg_grad_color_filtered, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_bg_grad_dir", (void*) &lv_obj_set_style_bg_grad_dir, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_bg_grad_stop", (void*) &lv_obj_set_style_bg_grad_stop, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_bg_img_opa", (void*) &lv_obj_set_style_bg_img_opa, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_bg_img_recolor", (void*) &lv_obj_set_style_bg_img_recolor, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_bg_img_recolor_filtered", (void*) &lv_obj_set_style_bg_img_recolor_filtered, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_bg_img_recolor_opa", (void*) &lv_obj_set_style_bg_img_recolor_opa, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_bg_img_src", (void*) &lv_obj_set_style_bg_img_src, "", "(lv.lv_obj).(lv.lv_style_selector)" }, - { "set_style_bg_img_tiled", (void*) &lv_obj_set_style_bg_img_tiled, "", "(lv.lv_obj)b(lv.lv_style_selector)" }, - { "set_style_bg_main_stop", (void*) &lv_obj_set_style_bg_main_stop, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_bg_opa", (void*) &lv_obj_set_style_bg_opa, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_blend_mode", (void*) &lv_obj_set_style_blend_mode, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_border_color", (void*) &lv_obj_set_style_border_color, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_border_color_filtered", (void*) &lv_obj_set_style_border_color_filtered, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_border_opa", (void*) &lv_obj_set_style_border_opa, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_border_post", (void*) &lv_obj_set_style_border_post, "", "(lv.lv_obj)b(lv.lv_style_selector)" }, - { "set_style_border_side", (void*) &lv_obj_set_style_border_side, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_border_width", (void*) &lv_obj_set_style_border_width, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_clip_corner", (void*) &lv_obj_set_style_clip_corner, "", "(lv.lv_obj)b(lv.lv_style_selector)" }, - { "set_style_color_filter_dsc", (void*) &lv_obj_set_style_color_filter_dsc, "", "(lv.lv_obj)(lv.lv_color_filter_dsc)(lv.lv_style_selector)" }, - { "set_style_color_filter_opa", (void*) &lv_obj_set_style_color_filter_opa, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_height", (void*) &lv_obj_set_style_height, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_img_opa", (void*) &lv_obj_set_style_img_opa, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_img_recolor", (void*) &lv_obj_set_style_img_recolor, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_img_recolor_filtered", (void*) &lv_obj_set_style_img_recolor_filtered, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_img_recolor_opa", (void*) &lv_obj_set_style_img_recolor_opa, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_layout", (void*) &lv_obj_set_style_layout, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_line_color", (void*) &lv_obj_set_style_line_color, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_line_color_filtered", (void*) &lv_obj_set_style_line_color_filtered, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_line_dash_gap", (void*) &lv_obj_set_style_line_dash_gap, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_line_dash_width", (void*) &lv_obj_set_style_line_dash_width, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_line_opa", (void*) &lv_obj_set_style_line_opa, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_line_rounded", (void*) &lv_obj_set_style_line_rounded, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_line_width", (void*) &lv_obj_set_style_line_width, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_max_height", (void*) &lv_obj_set_style_max_height, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_max_width", (void*) &lv_obj_set_style_max_width, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_min_height", (void*) &lv_obj_set_style_min_height, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_min_width", (void*) &lv_obj_set_style_min_width, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_opa", (void*) &lv_obj_set_style_opa, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_outline_color", (void*) &lv_obj_set_style_outline_color, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_outline_color_filtered", (void*) &lv_obj_set_style_outline_color_filtered, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_outline_opa", (void*) &lv_obj_set_style_outline_opa, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_outline_pad", (void*) &lv_obj_set_style_outline_pad, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_outline_width", (void*) &lv_obj_set_style_outline_width, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_pad_all", (void*) &lv_obj_set_style_pad_all, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_pad_bottom", (void*) &lv_obj_set_style_pad_bottom, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_pad_column", (void*) &lv_obj_set_style_pad_column, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_pad_gap", (void*) &lv_obj_set_style_pad_gap, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_pad_hor", (void*) &lv_obj_set_style_pad_hor, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_pad_left", (void*) &lv_obj_set_style_pad_left, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_pad_right", (void*) &lv_obj_set_style_pad_right, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_pad_row", (void*) &lv_obj_set_style_pad_row, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_pad_top", (void*) &lv_obj_set_style_pad_top, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_pad_ver", (void*) &lv_obj_set_style_pad_ver, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_radius", (void*) &lv_obj_set_style_radius, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_shadow_color", (void*) &lv_obj_set_style_shadow_color, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_shadow_color_filtered", (void*) &lv_obj_set_style_shadow_color_filtered, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_shadow_ofs_x", (void*) &lv_obj_set_style_shadow_ofs_x, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_shadow_ofs_y", (void*) &lv_obj_set_style_shadow_ofs_y, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_shadow_opa", (void*) &lv_obj_set_style_shadow_opa, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_shadow_spread", (void*) &lv_obj_set_style_shadow_spread, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_shadow_width", (void*) &lv_obj_set_style_shadow_width, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_size", (void*) &lv_obj_set_style_size, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_text_align", (void*) &lv_obj_set_style_text_align, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_text_color", (void*) &lv_obj_set_style_text_color, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_text_color_filtered", (void*) &lv_obj_set_style_text_color_filtered, "", "(lv.lv_obj)(lv.lv_color)(lv.lv_style_selector)" }, - { "set_style_text_decor", (void*) &lv_obj_set_style_text_decor, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_text_font", (void*) &lv_obj_set_style_text_font, "", "(lv.lv_obj)(lv.lv_font)(lv.lv_style_selector)" }, - { "set_style_text_letter_space", (void*) &lv_obj_set_style_text_letter_space, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_text_line_space", (void*) &lv_obj_set_style_text_line_space, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_text_opa", (void*) &lv_obj_set_style_text_opa, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_transform_angle", (void*) &lv_obj_set_style_transform_angle, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_transform_height", (void*) &lv_obj_set_style_transform_height, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_transform_width", (void*) &lv_obj_set_style_transform_width, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_transform_zoom", (void*) &lv_obj_set_style_transform_zoom, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_transition", (void*) &lv_obj_set_style_transition, "", "(lv.lv_obj)(lv.lv_style_transition_dsc)(lv.lv_style_selector)" }, - { "set_style_translate_x", (void*) &lv_obj_set_style_translate_x, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_translate_y", (void*) &lv_obj_set_style_translate_y, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_width", (void*) &lv_obj_set_style_width, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_x", (void*) &lv_obj_set_style_x, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, - { "set_style_y", (void*) &lv_obj_set_style_y, "", "(lv.lv_obj)i(lv.lv_style_selector)" }, + { "set_style_align", (void*) &lv_obj_set_style_align, "", "(lv.lv_obj)ii" }, + { "set_style_anim_speed", (void*) &lv_obj_set_style_anim_speed, "", "(lv.lv_obj)ii" }, + { "set_style_anim_time", (void*) &lv_obj_set_style_anim_time, "", "(lv.lv_obj)ii" }, + { "set_style_arc_color", (void*) &lv_obj_set_style_arc_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_arc_color_filtered", (void*) &lv_obj_set_style_arc_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_arc_img_src", (void*) &lv_obj_set_style_arc_img_src, "", "(lv.lv_obj).i" }, + { "set_style_arc_opa", (void*) &lv_obj_set_style_arc_opa, "", "(lv.lv_obj)ii" }, + { "set_style_arc_rounded", (void*) &lv_obj_set_style_arc_rounded, "", "(lv.lv_obj)ii" }, + { "set_style_arc_width", (void*) &lv_obj_set_style_arc_width, "", "(lv.lv_obj)ii" }, + { "set_style_base_dir", (void*) &lv_obj_set_style_base_dir, "", "(lv.lv_obj)ii" }, + { "set_style_bg_color", (void*) &lv_obj_set_style_bg_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_bg_color_filtered", (void*) &lv_obj_set_style_bg_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_bg_grad_color", (void*) &lv_obj_set_style_bg_grad_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_bg_grad_color_filtered", (void*) &lv_obj_set_style_bg_grad_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_bg_grad_dir", (void*) &lv_obj_set_style_bg_grad_dir, "", "(lv.lv_obj)ii" }, + { "set_style_bg_grad_stop", (void*) &lv_obj_set_style_bg_grad_stop, "", "(lv.lv_obj)ii" }, + { "set_style_bg_img_opa", (void*) &lv_obj_set_style_bg_img_opa, "", "(lv.lv_obj)ii" }, + { "set_style_bg_img_recolor", (void*) &lv_obj_set_style_bg_img_recolor, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_bg_img_recolor_filtered", (void*) &lv_obj_set_style_bg_img_recolor_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_bg_img_recolor_opa", (void*) &lv_obj_set_style_bg_img_recolor_opa, "", "(lv.lv_obj)ii" }, + { "set_style_bg_img_src", (void*) &lv_obj_set_style_bg_img_src, "", "(lv.lv_obj).i" }, + { "set_style_bg_img_tiled", (void*) &lv_obj_set_style_bg_img_tiled, "", "(lv.lv_obj)bi" }, + { "set_style_bg_main_stop", (void*) &lv_obj_set_style_bg_main_stop, "", "(lv.lv_obj)ii" }, + { "set_style_bg_opa", (void*) &lv_obj_set_style_bg_opa, "", "(lv.lv_obj)ii" }, + { "set_style_blend_mode", (void*) &lv_obj_set_style_blend_mode, "", "(lv.lv_obj)ii" }, + { "set_style_border_color", (void*) &lv_obj_set_style_border_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_border_color_filtered", (void*) &lv_obj_set_style_border_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_border_opa", (void*) &lv_obj_set_style_border_opa, "", "(lv.lv_obj)ii" }, + { "set_style_border_post", (void*) &lv_obj_set_style_border_post, "", "(lv.lv_obj)bi" }, + { "set_style_border_side", (void*) &lv_obj_set_style_border_side, "", "(lv.lv_obj)ii" }, + { "set_style_border_width", (void*) &lv_obj_set_style_border_width, "", "(lv.lv_obj)ii" }, + { "set_style_clip_corner", (void*) &lv_obj_set_style_clip_corner, "", "(lv.lv_obj)bi" }, + { "set_style_color_filter_dsc", (void*) &lv_obj_set_style_color_filter_dsc, "", "(lv.lv_obj)(lv.lv_color_filter_dsc)i" }, + { "set_style_color_filter_opa", (void*) &lv_obj_set_style_color_filter_opa, "", "(lv.lv_obj)ii" }, + { "set_style_height", (void*) &lv_obj_set_style_height, "", "(lv.lv_obj)ii" }, + { "set_style_img_opa", (void*) &lv_obj_set_style_img_opa, "", "(lv.lv_obj)ii" }, + { "set_style_img_recolor", (void*) &lv_obj_set_style_img_recolor, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_img_recolor_filtered", (void*) &lv_obj_set_style_img_recolor_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_img_recolor_opa", (void*) &lv_obj_set_style_img_recolor_opa, "", "(lv.lv_obj)ii" }, + { "set_style_layout", (void*) &lv_obj_set_style_layout, "", "(lv.lv_obj)ii" }, + { "set_style_line_color", (void*) &lv_obj_set_style_line_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_line_color_filtered", (void*) &lv_obj_set_style_line_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_line_dash_gap", (void*) &lv_obj_set_style_line_dash_gap, "", "(lv.lv_obj)ii" }, + { "set_style_line_dash_width", (void*) &lv_obj_set_style_line_dash_width, "", "(lv.lv_obj)ii" }, + { "set_style_line_opa", (void*) &lv_obj_set_style_line_opa, "", "(lv.lv_obj)ii" }, + { "set_style_line_rounded", (void*) &lv_obj_set_style_line_rounded, "", "(lv.lv_obj)ii" }, + { "set_style_line_width", (void*) &lv_obj_set_style_line_width, "", "(lv.lv_obj)ii" }, + { "set_style_max_height", (void*) &lv_obj_set_style_max_height, "", "(lv.lv_obj)ii" }, + { "set_style_max_width", (void*) &lv_obj_set_style_max_width, "", "(lv.lv_obj)ii" }, + { "set_style_min_height", (void*) &lv_obj_set_style_min_height, "", "(lv.lv_obj)ii" }, + { "set_style_min_width", (void*) &lv_obj_set_style_min_width, "", "(lv.lv_obj)ii" }, + { "set_style_opa", (void*) &lv_obj_set_style_opa, "", "(lv.lv_obj)ii" }, + { "set_style_outline_color", (void*) &lv_obj_set_style_outline_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_outline_color_filtered", (void*) &lv_obj_set_style_outline_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_outline_opa", (void*) &lv_obj_set_style_outline_opa, "", "(lv.lv_obj)ii" }, + { "set_style_outline_pad", (void*) &lv_obj_set_style_outline_pad, "", "(lv.lv_obj)ii" }, + { "set_style_outline_width", (void*) &lv_obj_set_style_outline_width, "", "(lv.lv_obj)ii" }, + { "set_style_pad_all", (void*) &lv_obj_set_style_pad_all, "", "(lv.lv_obj)ii" }, + { "set_style_pad_bottom", (void*) &lv_obj_set_style_pad_bottom, "", "(lv.lv_obj)ii" }, + { "set_style_pad_column", (void*) &lv_obj_set_style_pad_column, "", "(lv.lv_obj)ii" }, + { "set_style_pad_gap", (void*) &lv_obj_set_style_pad_gap, "", "(lv.lv_obj)ii" }, + { "set_style_pad_hor", (void*) &lv_obj_set_style_pad_hor, "", "(lv.lv_obj)ii" }, + { "set_style_pad_left", (void*) &lv_obj_set_style_pad_left, "", "(lv.lv_obj)ii" }, + { "set_style_pad_right", (void*) &lv_obj_set_style_pad_right, "", "(lv.lv_obj)ii" }, + { "set_style_pad_row", (void*) &lv_obj_set_style_pad_row, "", "(lv.lv_obj)ii" }, + { "set_style_pad_top", (void*) &lv_obj_set_style_pad_top, "", "(lv.lv_obj)ii" }, + { "set_style_pad_ver", (void*) &lv_obj_set_style_pad_ver, "", "(lv.lv_obj)ii" }, + { "set_style_radius", (void*) &lv_obj_set_style_radius, "", "(lv.lv_obj)ii" }, + { "set_style_shadow_color", (void*) &lv_obj_set_style_shadow_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_shadow_color_filtered", (void*) &lv_obj_set_style_shadow_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_shadow_ofs_x", (void*) &lv_obj_set_style_shadow_ofs_x, "", "(lv.lv_obj)ii" }, + { "set_style_shadow_ofs_y", (void*) &lv_obj_set_style_shadow_ofs_y, "", "(lv.lv_obj)ii" }, + { "set_style_shadow_opa", (void*) &lv_obj_set_style_shadow_opa, "", "(lv.lv_obj)ii" }, + { "set_style_shadow_spread", (void*) &lv_obj_set_style_shadow_spread, "", "(lv.lv_obj)ii" }, + { "set_style_shadow_width", (void*) &lv_obj_set_style_shadow_width, "", "(lv.lv_obj)ii" }, + { "set_style_size", (void*) &lv_obj_set_style_size, "", "(lv.lv_obj)ii" }, + { "set_style_text_align", (void*) &lv_obj_set_style_text_align, "", "(lv.lv_obj)ii" }, + { "set_style_text_color", (void*) &lv_obj_set_style_text_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_text_color_filtered", (void*) &lv_obj_set_style_text_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_text_decor", (void*) &lv_obj_set_style_text_decor, "", "(lv.lv_obj)ii" }, + { "set_style_text_font", (void*) &lv_obj_set_style_text_font, "", "(lv.lv_obj)(lv.lv_font)i" }, + { "set_style_text_letter_space", (void*) &lv_obj_set_style_text_letter_space, "", "(lv.lv_obj)ii" }, + { "set_style_text_line_space", (void*) &lv_obj_set_style_text_line_space, "", "(lv.lv_obj)ii" }, + { "set_style_text_opa", (void*) &lv_obj_set_style_text_opa, "", "(lv.lv_obj)ii" }, + { "set_style_transform_angle", (void*) &lv_obj_set_style_transform_angle, "", "(lv.lv_obj)ii" }, + { "set_style_transform_height", (void*) &lv_obj_set_style_transform_height, "", "(lv.lv_obj)ii" }, + { "set_style_transform_width", (void*) &lv_obj_set_style_transform_width, "", "(lv.lv_obj)ii" }, + { "set_style_transform_zoom", (void*) &lv_obj_set_style_transform_zoom, "", "(lv.lv_obj)ii" }, + { "set_style_transition", (void*) &lv_obj_set_style_transition, "", "(lv.lv_obj)(lv.lv_style_transition_dsc)i" }, + { "set_style_translate_x", (void*) &lv_obj_set_style_translate_x, "", "(lv.lv_obj)ii" }, + { "set_style_translate_y", (void*) &lv_obj_set_style_translate_y, "", "(lv.lv_obj)ii" }, + { "set_style_width", (void*) &lv_obj_set_style_width, "", "(lv.lv_obj)ii" }, + { "set_style_x", (void*) &lv_obj_set_style_x, "", "(lv.lv_obj)ii" }, + { "set_style_y", (void*) &lv_obj_set_style_y, "", "(lv.lv_obj)ii" }, { "set_user_data", (void*) &lv_obj_set_user_data, "", "(lv.lv_obj)." }, { "set_width", (void*) &lv_obj_set_width, "", "(lv.lv_obj)i" }, { "set_x", (void*) &lv_obj_set_x, "", "(lv.lv_obj)i" }, @@ -847,6 +870,7 @@ extern const bclass be_class_lv_chart; extern const bclass be_class_lv_checkbox; extern const bclass be_class_lv_color; extern const bclass be_class_lv_colorwheel; +extern const bclass be_class_lv_disp; extern const bclass be_class_lv_dropdown; extern const bclass be_class_lv_font; extern const bclass be_class_lv_group; @@ -866,6 +890,7 @@ extern const bclass be_class_lv_style; extern const bclass be_class_lv_switch; extern const bclass be_class_lv_table; extern const bclass be_class_lv_textarea; +extern const bclass be_class_lv_theme; // map of clases @@ -895,6 +920,7 @@ const lvbe_call_c_classes_t lv_classes[] = { #ifdef BE_LV_WIDGET_COLORWHEEL { "lv_colorwheel", &be_class_lv_colorwheel, lv_colorwheel_func, sizeof(lv_colorwheel_func) / sizeof(lv_colorwheel_func[0]) }, #endif // BE_LV_WIDGET_COLORWHEEL + { "lv_disp", &be_class_lv_disp, lv_disp_func, sizeof(lv_disp_func) / sizeof(lv_disp_func[0]) }, #ifdef BE_LV_WIDGET_DROPDOWN { "lv_dropdown", &be_class_lv_dropdown, lv_dropdown_func, sizeof(lv_dropdown_func) / sizeof(lv_dropdown_func[0]) }, #endif // BE_LV_WIDGET_DROPDOWN @@ -942,16 +968,19 @@ const lvbe_call_c_classes_t lv_classes[] = { #ifdef BE_LV_WIDGET_TEXTAREA { "lv_textarea", &be_class_lv_textarea, lv_textarea_func, sizeof(lv_textarea_func) / sizeof(lv_textarea_func[0]) }, #endif // BE_LV_WIDGET_TEXTAREA + { "lv_theme", &be_class_lv_theme, lv_theme_func, sizeof(lv_theme_func) / sizeof(lv_theme_func[0]) }, }; const size_t lv_classes_size = sizeof(lv_classes) / sizeof(lv_classes[0]); /* `lv_style` methods */ /* `lv_font` methods */ /* `lv_color` methods */ + /* `lv_theme` methods */ /* `lv_img` methods */ #ifdef BE_LV_WIDGET_IMG int be_ntv_lv_img_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_img_create, "+lv.lv_img", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_IMG + /* `lv_disp` methods */ /* `lv_obj` methods */ int be_ntv_lv_obj_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_obj_create, "+lv.lv_obj", "(lv.lv_obj)"); } /* `lv_group` methods */ @@ -1043,7 +1072,8 @@ const size_t lv_classes_size = sizeof(lv_classes) / sizeof(lv_classes[0]); #endif // BE_LV_WIDGET_TEXTAREA // create font either empty or from parameter on stack -int lvbe_font_create(bvm *vm) { return be_call_c_func(vm, NULL, "+lv_group", ""); } +int lvbe_font_create(bvm *vm) { return be_call_c_func(vm, NULL, "+lv_font", ""); } +int lvbe_theme_create(bvm *vm) { return be_call_c_func(vm, NULL, "+lv_theme", ""); } #ifdef __cplusplus diff --git a/tools/lv_berry/convert.py b/tools/lv_berry/convert.py index 7a31ed13f..db7394041 100644 --- a/tools/lv_berry/convert.py +++ b/tools/lv_berry/convert.py @@ -97,6 +97,7 @@ return_types = { "lv_img_src_t": "i", "lv_colorwheel_mode_t": "i", "lv_scr_load_anim_t": "i", + "lv_style_selector_t": "i", "_lv_event_dsc_t *": "i", @@ -117,6 +118,9 @@ return_types = { "lv_style_t *": "lv_style", "lv_group_t *": "lv_group", "lv_font_t *": "lv_font", + "lv_theme_t *": "lv_theme", + "lv_disp_t *": "lv_disp", + "lv_indev_t *": "lv_indev", #"lv_disp_t*": "lv_disp", #"lv_style_list_t*": "", @@ -137,10 +141,11 @@ lv_cb_types = ['lv_group_focus_cb', 'lv_event_cb', ] # list of callback types that will need each a separate C callback -# For LVGL8, need to add synthetic lv_style, lv_font, lv_color +# For LVGL8, need to add synthetic lv_style, lv_font, lv_color, lv_theme lv['style'] = [] lv['font'] = [] lv['color'] = [] +lv['theme'] = [] # standard widgets lv_widgets = ['arc', 'bar', 'btn', 'btnmatrix', 'canvas', 'checkbox', @@ -149,7 +154,7 @@ lv_widgets = ['arc', 'bar', 'btn', 'btnmatrix', 'canvas', 'checkbox', # extra widgets lv_widgets = lv_widgets + [ 'chart', 'colorwheel', 'imgbtn', 'led', 'meter', 'msgbox', 'spinbox' ] -lv_prefix = ['obj', 'group', 'style', 'indev', ] + lv_widgets +lv_prefix = ['obj', 'group', 'style', 'indev', 'disp'] + lv_widgets def try_int(s): try: @@ -383,7 +388,8 @@ for subtype, flv in lv.items(): print(""" // create font either empty or from parameter on stack -int lvbe_font_create(bvm *vm) { return be_call_c_func(vm, NULL, "+lv_group", ""); } +int lvbe_font_create(bvm *vm) { return be_call_c_func(vm, NULL, "+lv_font", ""); } +int lvbe_theme_create(bvm *vm) { return be_call_c_func(vm, NULL, "+lv_theme", ""); } """) print() @@ -425,6 +431,7 @@ extern int lvs_tostring(bvm *vm); BE_EXPORT_VARIABLE extern const bclass be_class_lv_obj; extern int lvbe_font_create(bvm *vm); +extern int lvbe_theme_create(bvm *vm); """) @@ -521,6 +528,23 @@ be_local_class(lv_indev, ); /*******************************************************************/ +/******************************************************************** +** Solidified class: lv_disp +********************************************************************/ +be_local_class(lv_disp, + 1, + NULL, + be_nested_map(4, + ( (struct bmapnode*) &(const bmapnode[]) { + { be_nested_key("init", 380752755, 4, -1), be_const_func(lv0_init) }, + { be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) }, + { be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) }, + { be_nested_key("member", 719708611, 6, 0), be_const_func(lvx_member) }, + })), + (be_nested_const_str("lv_disp", 609712084, 8)) +); +/*******************************************************************/ + /******************************************************************** ** Solidified class: lv_font ********************************************************************/ @@ -537,6 +561,22 @@ be_local_class(lv_font, ); /*******************************************************************/ +/******************************************************************** +** Solidified class: lv_theme +********************************************************************/ +be_local_class(lv_theme, + 1, + NULL, + be_nested_map(3, + ( (struct bmapnode*) &(const bmapnode[]) { + { be_nested_key("init", 380752755, 4, -1), be_const_func(lvbe_theme_create) }, + { be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) }, + { be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) }, + })), + (be_nested_const_str("lv_theme", 1550958453, 7)) +); +/*******************************************************************/ + /******************************************************************** ** Solidified class: lv_color ********************************************************************/ @@ -603,6 +643,7 @@ print("""/******************************************************************** #include "lvgl.h" #include "be_lvgl.h" +#include "lv_theme_openhasp.h" extern int lv0_member(bvm *vm); // resolve virtual members @@ -721,7 +762,7 @@ be_local_module(lv, { be_nested_key("start", 1697318111, 5, 0), be_const_func(lv0_start) }, })) ); -BE_EXPORT_VARIABLE be_define_const_native_module(lv, NULL); +BE_EXPORT_VARIABLE be_define_const_native_module(lv); #endif // USE_LVGL """) diff --git a/tools/lv_berry/lv_funcs.h b/tools/lv_berry/lv_funcs.h index b628de74f..791e0df7c 100644 --- a/tools/lv_berry/lv_funcs.h +++ b/tools/lv_berry/lv_funcs.h @@ -29,12 +29,26 @@ lv_coord_t lv_get_ver_res(void); // ../../lib/libesp32_lvgl/LVGL8/src/core/lv_disp.h +lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp) +lv_obj_t * lv_disp_get_scr_prev(lv_disp_t * disp) +void lv_disp_load_scr(lv_obj_t * scr) +lv_obj_t * lv_disp_get_layer_top(lv_disp_t * disp) +lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp) +void lv_disp_set_theme(lv_disp_t * disp, lv_theme_t * th) +lv_theme_t * lv_disp_get_theme(lv_disp_t * disp) +void lv_disp_set_bg_color(lv_disp_t * disp, lv_color_t color) +void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src) +void lv_disp_set_bg_opa(lv_disp_t * disp, lv_opa_t opa) void lv_scr_load_anim(lv_obj_t * scr, lv_scr_load_anim_t anim_type, uint32_t time, uint32_t delay, bool auto_del) +uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp) +void lv_disp_trig_activity(lv_disp_t * disp) +void lv_disp_clean_dcache(lv_disp_t * disp) static inline lv_obj_t * lv_scr_act(void) static inline lv_obj_t * lv_layer_top(void) static inline lv_obj_t * lv_layer_sys(void) static inline void lv_scr_load(lv_obj_t * scr) static inline lv_coord_t lv_dpx(lv_coord_t n) +static inline lv_coord_t lv_disp_dpx(const lv_disp_t * disp, lv_coord_t n) // ../../lib/libesp32_lvgl/LVGL8/src/core/lv_event.h lv_res_t lv_event_send(struct _lv_obj_t * obj, lv_event_code_t event_code, void * param) @@ -483,6 +497,10 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are // ../../lib/libesp32_lvgl/LVGL8/src/draw/lv_img_decoder.h +// ../../lib/libesp32_lvgl/LVGL8/src/extra/themes/default/lv_theme_default.h +lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font) +bool lv_theme_default_is_inited(void) + // ../../lib/libesp32_lvgl/LVGL8/src/extra/widgets/chart/lv_chart.h lv_obj_t * lv_chart_create(lv_obj_t * parent) void lv_chart_set_type(lv_obj_t * obj, lv_chart_type_t type) @@ -899,3 +917,7 @@ void lv_textarea_cursor_left(lv_obj_t * obj) void lv_textarea_cursor_down(lv_obj_t * obj) void lv_textarea_cursor_up(lv_obj_t * obj) +// ../../lib/libesp32_lvgl/LVGL_assets/src/lv_theme_openhasp.h +lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font) +bool lv_theme_openhasp_is_inited(void) + diff --git a/tools/lv_berry/preprocessor.py b/tools/lv_berry/preprocessor.py index 0346b8ca5..fe51dd775 100644 --- a/tools/lv_berry/preprocessor.py +++ b/tools/lv_berry/preprocessor.py @@ -59,6 +59,7 @@ lv_fun_globs = [ "extra/widgets/meter/*.h", "extra/widgets/msgbox/*.h", "extra/widgets/spinbox/*.h", + "extra/themes/default/*.h", "core/*.h", "draw/*.h", "misc/lv_style_gen.h", @@ -66,6 +67,7 @@ lv_fun_globs = [ #"**/*.h", ] headers_names = list_files(lv_src_prefix, lv_fun_globs) +headers_names += list_files("../../lib/libesp32_lvgl/LVGL_assets/src/", ["lv_theme_openhasp.h"]) # headers_names += ["lv_pre_style.h"] # for LVGL v7, add pre-generated style functions from C preprocessor # unit test @@ -143,7 +145,7 @@ for header_name in headers_names: "^lv_templ_", "^lv_imgbtn_get_src_", # LV_IMGBTN_TILED == 0 "^lv_imgbtn_set_src_tiled",# !LV_IMGBTN_TILED - "^lv_disp_", + #"^lv_disp_", "^lv_refr_get_fps_", # no LV_USE_PERF_MONITOR "^lv_img_cache_", "^lv_img_decoder_",