HASPmota support for spangroup (styled text) (#20852)

This commit is contained in:
s-hadinger 2024-03-03 10:53:21 +01:00 committed by GitHub
parent 6a35795178
commit 27ccf0490b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 5639 additions and 4868 deletions

View File

@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
## [13.4.0.2]
### Added
- Berry `path.rename()` (#20840)
- HASPmota support for spangroup (styled text)
### Breaking Changed
- Drop support for old (insecure) fingerprint format (#20842)

File diff suppressed because it is too large Load Diff

View File

@ -125,8 +125,6 @@ scr_load_anim|lv.obj, int, int, int, bool||[lv_screen_load_anim](https://docs.lv
screen_active||lv.obj|[lv_screen_active](https://docs.lvgl.io/9.0/search.html?q=lv_screen_active)
screen_load|lv.obj||[lv_screen_load](https://docs.lvgl.io/9.0/search.html?q=lv_screen_load)
screen_load_anim|lv.obj, int, int, int, bool||[lv_screen_load_anim](https://docs.lvgl.io/9.0/search.html?q=lv_screen_load_anim)
span_set_text|lv.spangroup, string||[lv_span_set_text](https://docs.lvgl.io/9.0/search.html?q=lv_span_set_text)
span_set_text_static|lv.spangroup, string||[lv_span_set_text_static](https://docs.lvgl.io/9.0/search.html?q=lv_span_set_text_static)
span_stack_deinit|||[lv_span_stack_deinit](https://docs.lvgl.io/9.0/search.html?q=lv_span_stack_deinit)
span_stack_init|||[lv_span_stack_init](https://docs.lvgl.io/9.0/search.html?q=lv_span_stack_init)
style_get_num_custom_props||int|[lv_style_get_num_custom_props](https://docs.lvgl.io/9.0/search.html?q=lv_style_get_num_custom_props)
@ -1275,9 +1273,9 @@ text_is_selected||bool|[lv_textarea_text_is_selected](https://docs.lvgl.io/9.0/s
Method|Arguments|Return type|LVGL equivalent
:---|:---|:---|:---
delete_span|lv.spangroup||[lv_spangroup_delete_span](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_delete_span)
delete_span|lv.span||[lv_spangroup_delete_span](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_delete_span)
get_align||int|[lv_spangroup_get_align](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_get_align)
get_child|int|lv.spangroup|[lv_spangroup_get_child](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_get_child)
get_child|int|lv.span|[lv_spangroup_get_child](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_get_child)
get_expand_height|int|int|[lv_spangroup_get_expand_height](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_get_expand_height)
get_expand_width|int|int|[lv_spangroup_get_expand_width](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_get_expand_width)
get_indent||int|[lv_spangroup_get_indent](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_get_indent)
@ -1286,7 +1284,7 @@ get_max_lines||int|[lv_spangroup_get_max_lines](https://docs.lvgl.io/9.0/search.
get_mode||int|[lv_spangroup_get_mode](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_get_mode)
get_overflow||int|[lv_spangroup_get_overflow](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_get_overflow)
get_span_count||int|[lv_spangroup_get_span_count](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_get_span_count)
new_span||lv.spangroup|[lv_spangroup_new_span](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_new_span)
new_span||lv.span|[lv_spangroup_new_span](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_new_span)
refr_mode|||[lv_spangroup_refr_mode](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_refr_mode)
set_align|int||[lv_spangroup_set_align](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_set_align)
set_indent|int||[lv_spangroup_set_indent](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_set_indent)
@ -1294,6 +1292,14 @@ set_max_lines|int||[lv_spangroup_set_max_lines](https://docs.lvgl.io/9.0/search.
set_mode|int||[lv_spangroup_set_mode](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_set_mode)
set_overflow|int||[lv_spangroup_set_overflow](https://docs.lvgl.io/9.0/search.html?q=lv_spangroup_set_overflow)
### widget `lv.span`
Method|Arguments|Return type|LVGL equivalent
:---|:---|:---|:---
get_style||lv.style|[lv_span_get_style](https://docs.lvgl.io/9.0/search.html?q=lv_span_get_style)
set_text|string||[lv_span_set_text](https://docs.lvgl.io/9.0/search.html?q=lv_span_set_text)
set_text_static|string||[lv_span_set_text_static](https://docs.lvgl.io/9.0/search.html?q=lv_span_set_text_static)
### widget `lv.scale`
Method|Arguments|Return type|LVGL equivalent

View File

@ -158,39 +158,6 @@ const be_ntv_func_def_t lv_color_func[] = {
const be_ntv_func_def_t lv_theme_func[] = {
};
/* `lv_image` methods */
#ifdef BE_LV_WIDGET_IMAGE
const be_ntv_func_def_t lv_image_func[] = {
{ "get_angle", { (const void*) &lv_image_get_rotation, "i", "(lv.obj)" } },
{ "get_antialias", { (const void*) &lv_image_get_antialias, "b", "(lv.obj)" } },
{ "get_blend_mode", { (const void*) &lv_image_get_blend_mode, "i", "(lv.obj)" } },
{ "get_inner_align", { (const void*) &lv_image_get_inner_align, "i", "(lv.obj)" } },
{ "get_offset_x", { (const void*) &lv_image_get_offset_x, "i", "(lv.obj)" } },
{ "get_offset_y", { (const void*) &lv_image_get_offset_y, "i", "(lv.obj)" } },
{ "get_pivot", { (const void*) &lv_image_get_pivot, "", "(lv.obj)c" } },
{ "get_rotation", { (const void*) &lv_image_get_rotation, "i", "(lv.obj)" } },
{ "get_scale", { (const void*) &lv_image_get_scale, "i", "(lv.obj)" } },
{ "get_scale_x", { (const void*) &lv_image_get_scale_x, "i", "(lv.obj)" } },
{ "get_scale_y", { (const void*) &lv_image_get_scale_y, "i", "(lv.obj)" } },
{ "get_src", { (const void*) &lv_image_get_src, "c", "(lv.obj)" } },
{ "get_zoom", { (const void*) &lv_image_get_scale, "i", "(lv.obj)" } },
{ "set_angle", { (const void*) &lv_image_set_rotation, "", "(lv.obj)i" } },
{ "set_antialias", { (const void*) &lv_image_set_antialias, "", "(lv.obj)b" } },
{ "set_blend_mode", { (const void*) &lv_image_set_blend_mode, "", "(lv.obj)i" } },
{ "set_inner_align", { (const void*) &lv_image_set_inner_align, "", "(lv.obj)i" } },
{ "set_offset_x", { (const void*) &lv_image_set_offset_x, "", "(lv.obj)i" } },
{ "set_offset_y", { (const void*) &lv_image_set_offset_y, "", "(lv.obj)i" } },
{ "set_pivot", { (const void*) &lv_image_set_pivot, "", "(lv.obj)ii" } },
{ "set_rotation", { (const void*) &lv_image_set_rotation, "", "(lv.obj)i" } },
{ "set_scale", { (const void*) &lv_image_set_scale, "", "(lv.obj)i" } },
{ "set_scale_x", { (const void*) &lv_image_set_scale_x, "", "(lv.obj)i" } },
{ "set_scale_y", { (const void*) &lv_image_set_scale_y, "", "(lv.obj)i" } },
{ "set_src", { (const void*) &lv_image_set_src, "", "(lv.obj)." } },
{ "set_tasmota_logo", { (const void*) &lv_image_set_tasmota_logo, "", "(lv.obj)" } },
{ "set_zoom", { (const void*) &lv_image_set_scale, "", "(lv.obj)i" } },
};
#endif // BE_LV_WIDGET_IMAGE
/* `lv_group` methods */
const be_ntv_func_def_t lv_group_func[] = {
{ "add_obj", { (const void*) &lv_group_add_obj, "", "(lv.group)(lv.obj)" } },
@ -1014,6 +981,39 @@ const be_ntv_func_def_t lv_dropdown_func[] = {
};
#endif // BE_LV_WIDGET_DROPDOWN
/* `lv_image` methods */
#ifdef BE_LV_WIDGET_IMAGE
const be_ntv_func_def_t lv_image_func[] = {
{ "get_angle", { (const void*) &lv_image_get_rotation, "i", "(lv.obj)" } },
{ "get_antialias", { (const void*) &lv_image_get_antialias, "b", "(lv.obj)" } },
{ "get_blend_mode", { (const void*) &lv_image_get_blend_mode, "i", "(lv.obj)" } },
{ "get_inner_align", { (const void*) &lv_image_get_inner_align, "i", "(lv.obj)" } },
{ "get_offset_x", { (const void*) &lv_image_get_offset_x, "i", "(lv.obj)" } },
{ "get_offset_y", { (const void*) &lv_image_get_offset_y, "i", "(lv.obj)" } },
{ "get_pivot", { (const void*) &lv_image_get_pivot, "", "(lv.obj)c" } },
{ "get_rotation", { (const void*) &lv_image_get_rotation, "i", "(lv.obj)" } },
{ "get_scale", { (const void*) &lv_image_get_scale, "i", "(lv.obj)" } },
{ "get_scale_x", { (const void*) &lv_image_get_scale_x, "i", "(lv.obj)" } },
{ "get_scale_y", { (const void*) &lv_image_get_scale_y, "i", "(lv.obj)" } },
{ "get_src", { (const void*) &lv_image_get_src, "c", "(lv.obj)" } },
{ "get_zoom", { (const void*) &lv_image_get_scale, "i", "(lv.obj)" } },
{ "set_angle", { (const void*) &lv_image_set_rotation, "", "(lv.obj)i" } },
{ "set_antialias", { (const void*) &lv_image_set_antialias, "", "(lv.obj)b" } },
{ "set_blend_mode", { (const void*) &lv_image_set_blend_mode, "", "(lv.obj)i" } },
{ "set_inner_align", { (const void*) &lv_image_set_inner_align, "", "(lv.obj)i" } },
{ "set_offset_x", { (const void*) &lv_image_set_offset_x, "", "(lv.obj)i" } },
{ "set_offset_y", { (const void*) &lv_image_set_offset_y, "", "(lv.obj)i" } },
{ "set_pivot", { (const void*) &lv_image_set_pivot, "", "(lv.obj)ii" } },
{ "set_rotation", { (const void*) &lv_image_set_rotation, "", "(lv.obj)i" } },
{ "set_scale", { (const void*) &lv_image_set_scale, "", "(lv.obj)i" } },
{ "set_scale_x", { (const void*) &lv_image_set_scale_x, "", "(lv.obj)i" } },
{ "set_scale_y", { (const void*) &lv_image_set_scale_y, "", "(lv.obj)i" } },
{ "set_src", { (const void*) &lv_image_set_src, "", "(lv.obj)." } },
{ "set_tasmota_logo", { (const void*) &lv_image_set_tasmota_logo, "", "(lv.obj)" } },
{ "set_zoom", { (const void*) &lv_image_set_scale, "", "(lv.obj)i" } },
};
#endif // BE_LV_WIDGET_IMAGE
/* `lv_imagebutton` methods */
#ifdef BE_LV_WIDGET_IMAGEBUTTON
const be_ntv_func_def_t lv_imagebutton_func[] = {
@ -1188,12 +1188,21 @@ const be_ntv_func_def_t lv_slider_func[] = {
};
#endif // BE_LV_WIDGET_SLIDER
/* `lv_span` methods */
#ifdef BE_LV_WIDGET_SPAN
const be_ntv_func_def_t lv_span_func[] = {
{ "get_style", { (const void*) &lv_span_get_style, "lv.style", "(lv.span)" } },
{ "set_text", { (const void*) &lv_span_set_text, "", "(lv.span)s" } },
{ "set_text_static", { (const void*) &lv_span_set_text_static, "", "(lv.span)s" } },
};
#endif // BE_LV_WIDGET_SPAN
/* `lv_spangroup` methods */
#ifdef BE_LV_WIDGET_SPANGROUP
const be_ntv_func_def_t lv_spangroup_func[] = {
{ "delete_span", { (const void*) &lv_spangroup_delete_span, "", "(lv.obj)(lv.spangroup)" } },
{ "delete_span", { (const void*) &lv_spangroup_delete_span, "", "(lv.obj)(lv.span)" } },
{ "get_align", { (const void*) &lv_spangroup_get_align, "i", "(lv.obj)" } },
{ "get_child", { (const void*) &lv_spangroup_get_child, "lv.spangroup", "(lv.obj)i" } },
{ "get_child", { (const void*) &lv_spangroup_get_child, "lv.span", "(lv.obj)i" } },
{ "get_expand_height", { (const void*) &lv_spangroup_get_expand_height, "i", "(lv.obj)i" } },
{ "get_expand_width", { (const void*) &lv_spangroup_get_expand_width, "i", "(lv.obj)i" } },
{ "get_indent", { (const void*) &lv_spangroup_get_indent, "i", "(lv.obj)" } },
@ -1202,7 +1211,7 @@ const be_ntv_func_def_t lv_spangroup_func[] = {
{ "get_mode", { (const void*) &lv_spangroup_get_mode, "i", "(lv.obj)" } },
{ "get_overflow", { (const void*) &lv_spangroup_get_overflow, "i", "(lv.obj)" } },
{ "get_span_count", { (const void*) &lv_spangroup_get_span_count, "i", "(lv.obj)" } },
{ "new_span", { (const void*) &lv_spangroup_new_span, "lv.spangroup", "(lv.obj)" } },
{ "new_span", { (const void*) &lv_spangroup_new_span, "lv.span", "(lv.obj)" } },
{ "refr_mode", { (const void*) &lv_spangroup_refr_mode, "", "(lv.obj)" } },
{ "set_align", { (const void*) &lv_spangroup_set_align, "", "(lv.obj)i" } },
{ "set_indent", { (const void*) &lv_spangroup_set_indent, "", "(lv.obj)i" } },
@ -1375,6 +1384,7 @@ extern const bclass be_class_lv_qrcode;
extern const bclass be_class_lv_roller;
extern const bclass be_class_lv_scale;
extern const bclass be_class_lv_slider;
extern const bclass be_class_lv_span;
extern const bclass be_class_lv_spangroup;
extern const bclass be_class_lv_spinbox;
extern const bclass be_class_lv_spinner;
@ -1469,6 +1479,9 @@ const be_ntv_class_def_t lv_classes[] = {
#ifdef BE_LV_WIDGET_SLIDER
{ "lv_slider", &be_class_lv_slider, lv_slider_func, sizeof(lv_slider_func) / sizeof(lv_slider_func[0]) },
#endif // BE_LV_WIDGET_SLIDER
#ifdef BE_LV_WIDGET_SPAN
{ "lv_span", &be_class_lv_span, lv_span_func, sizeof(lv_span_func) / sizeof(lv_span_func[0]) },
#endif // BE_LV_WIDGET_SPAN
#ifdef BE_LV_WIDGET_SPANGROUP
{ "lv_spangroup", &be_class_lv_spangroup, lv_spangroup_func, sizeof(lv_spangroup_func) / sizeof(lv_spangroup_func[0]) },
#endif // BE_LV_WIDGET_SPANGROUP
@ -1503,10 +1516,6 @@ const size_t lv_classes_size = sizeof(lv_classes) / sizeof(lv_classes[0]);
/* `lv_font` methods */
/* `lv_color` methods */
/* `lv_theme` methods */
/* `lv_image` methods */
#ifdef BE_LV_WIDGET_IMAGE
int be_ntv_lv_image_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_image_create, "+_p", "(lv.obj)"); }
#endif // BE_LV_WIDGET_IMAGE
/* `lv_group` methods */
int be_ntv_lv_group_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_group_create, "+_p", ""); }
/* `lv_obj` methods */
@ -1568,6 +1577,10 @@ const size_t lv_classes_size = sizeof(lv_classes) / sizeof(lv_classes[0]);
#ifdef BE_LV_WIDGET_DROPDOWN
int be_ntv_lv_dropdown_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_dropdown_create, "+_p", "(lv.obj)"); }
#endif // BE_LV_WIDGET_DROPDOWN
/* `lv_image` methods */
#ifdef BE_LV_WIDGET_IMAGE
int be_ntv_lv_image_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_image_create, "+_p", "(lv.obj)"); }
#endif // BE_LV_WIDGET_IMAGE
/* `lv_imagebutton` methods */
#ifdef BE_LV_WIDGET_IMAGEBUTTON
int be_ntv_lv_imagebutton_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_imagebutton_create, "+_p", "(lv.obj)"); }
@ -1624,6 +1637,10 @@ const size_t lv_classes_size = sizeof(lv_classes) / sizeof(lv_classes[0]);
#ifdef BE_LV_WIDGET_SLIDER
int be_ntv_lv_slider_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_slider_create, "+_p", "(lv.obj)"); }
#endif // BE_LV_WIDGET_SLIDER
/* `lv_span` methods */
#ifdef BE_LV_WIDGET_SPAN
int be_ntv_lv_span_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_span_set_text_static, "+_p", "(lv.span)s"); }
#endif // BE_LV_WIDGET_SPAN
/* `lv_spangroup` methods */
#ifdef BE_LV_WIDGET_SPANGROUP
int be_ntv_lv_spangroup_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_spangroup_create, "+_p", "(lv.obj)"); }

View File

@ -147,8 +147,6 @@ const be_ntv_func_def_t lv_func[] = {
{ "screen_active", { (const void*) &lv_screen_active, "lv.obj", "" } },
{ "screen_load", { (const void*) &lv_screen_load, "", "(lv.obj)" } },
{ "screen_load_anim", { (const void*) &lv_screen_load_anim, "", "(lv.obj)iiib" } },
{ "span_set_text", { (const void*) &lv_span_set_text, "", "(lv.spangroup)s" } },
{ "span_set_text_static", { (const void*) &lv_span_set_text_static, "", "(lv.spangroup)s" } },
{ "span_stack_deinit", { (const void*) &lv_span_stack_deinit, "", "" } },
{ "span_stack_init", { (const void*) &lv_span_stack_init, "", "" } },
{ "style_get_num_custom_props", { (const void*) &lv_style_get_num_custom_props, "i", "" } },

View File

@ -169,40 +169,6 @@ extern int lvbe_style_set_y(bvm *vm);
/* `lv_theme` external functions definitions */
/* `lv_image` external functions definitions */
extern int lvbe_image_create(bvm *vm);
extern int lvbe_image_get_rotation(bvm *vm);
extern int lvbe_image_get_antialias(bvm *vm);
extern int lvbe_image_get_blend_mode(bvm *vm);
extern int lvbe_image_get_inner_align(bvm *vm);
extern int lvbe_image_get_offset_x(bvm *vm);
extern int lvbe_image_get_offset_x(bvm *vm);
extern int lvbe_image_get_offset_y(bvm *vm);
extern int lvbe_image_get_offset_y(bvm *vm);
extern int lvbe_image_get_pivot(bvm *vm);
extern int lvbe_image_get_rotation(bvm *vm);
extern int lvbe_image_get_rotation(bvm *vm);
extern int lvbe_image_get_scale(bvm *vm);
extern int lvbe_image_get_scale_x(bvm *vm);
extern int lvbe_image_get_scale_y(bvm *vm);
extern int lvbe_image_get_src(bvm *vm);
extern int lvbe_image_get_scale(bvm *vm);
extern int lvbe_image_set_rotation(bvm *vm);
extern int lvbe_image_set_antialias(bvm *vm);
extern int lvbe_image_set_blend_mode(bvm *vm);
extern int lvbe_image_set_inner_align(bvm *vm);
extern int lvbe_image_set_offset_x(bvm *vm);
extern int lvbe_image_set_offset_y(bvm *vm);
extern int lvbe_image_set_pivot(bvm *vm);
extern int lvbe_image_set_rotation(bvm *vm);
extern int lvbe_image_set_rotation(bvm *vm);
extern int lvbe_image_set_scale(bvm *vm);
extern int lvbe_image_set_scale_x(bvm *vm);
extern int lvbe_image_set_scale_y(bvm *vm);
extern int lvbe_image_set_src(bvm *vm);
extern int lvbe_image_set_tasmota_logo(bvm *vm);
extern int lvbe_image_set_scale(bvm *vm);
/* `lv_group` external functions definitions */
extern int lvbe_group_add_obj(bvm *vm);
extern int lvbe_group_create(bvm *vm);
@ -1005,6 +971,40 @@ extern int lvbe_dropdown_set_selected_highlight(bvm *vm);
extern int lvbe_dropdown_set_symbol(bvm *vm);
extern int lvbe_dropdown_set_text(bvm *vm);
/* `lv_image` external functions definitions */
extern int lvbe_image_create(bvm *vm);
extern int lvbe_image_get_rotation(bvm *vm);
extern int lvbe_image_get_antialias(bvm *vm);
extern int lvbe_image_get_blend_mode(bvm *vm);
extern int lvbe_image_get_inner_align(bvm *vm);
extern int lvbe_image_get_offset_x(bvm *vm);
extern int lvbe_image_get_offset_x(bvm *vm);
extern int lvbe_image_get_offset_y(bvm *vm);
extern int lvbe_image_get_offset_y(bvm *vm);
extern int lvbe_image_get_pivot(bvm *vm);
extern int lvbe_image_get_rotation(bvm *vm);
extern int lvbe_image_get_rotation(bvm *vm);
extern int lvbe_image_get_scale(bvm *vm);
extern int lvbe_image_get_scale_x(bvm *vm);
extern int lvbe_image_get_scale_y(bvm *vm);
extern int lvbe_image_get_src(bvm *vm);
extern int lvbe_image_get_scale(bvm *vm);
extern int lvbe_image_set_rotation(bvm *vm);
extern int lvbe_image_set_antialias(bvm *vm);
extern int lvbe_image_set_blend_mode(bvm *vm);
extern int lvbe_image_set_inner_align(bvm *vm);
extern int lvbe_image_set_offset_x(bvm *vm);
extern int lvbe_image_set_offset_y(bvm *vm);
extern int lvbe_image_set_pivot(bvm *vm);
extern int lvbe_image_set_rotation(bvm *vm);
extern int lvbe_image_set_rotation(bvm *vm);
extern int lvbe_image_set_scale(bvm *vm);
extern int lvbe_image_set_scale_x(bvm *vm);
extern int lvbe_image_set_scale_y(bvm *vm);
extern int lvbe_image_set_src(bvm *vm);
extern int lvbe_image_set_tasmota_logo(bvm *vm);
extern int lvbe_image_set_scale(bvm *vm);
/* `lv_imagebutton` external functions definitions */
extern int lvbe_imagebutton_create(bvm *vm);
extern int lvbe_imagebutton_set_src(bvm *vm);
@ -1151,6 +1151,11 @@ extern int lvbe_slider_set_mode(bvm *vm);
extern int lvbe_slider_set_range(bvm *vm);
extern int lvbe_slider_set_value(bvm *vm);
/* `lv_span` external functions definitions */
extern int lvbe_span_get_style(bvm *vm);
extern int lvbe_span_set_text(bvm *vm);
extern int lvbe_span_set_text_static(bvm *vm);
/* `lv_spangroup` external functions definitions */
extern int lvbe_spangroup_create(bvm *vm);
extern int lvbe_spangroup_delete_span(bvm *vm);
@ -1287,7 +1292,6 @@ 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_image_init(bvm *vm);
extern int be_ntv_lv_group_init(bvm *vm);
extern int be_ntv_lv_obj_init(bvm *vm);
extern int be_ntv_lv_event_init(bvm *vm);
@ -1306,6 +1310,7 @@ extern int be_ntv_lv_canvas_init(bvm *vm);
extern int be_ntv_lv_chart_init(bvm *vm);
extern int be_ntv_lv_checkbox_init(bvm *vm);
extern int be_ntv_lv_dropdown_init(bvm *vm);
extern int be_ntv_lv_image_init(bvm *vm);
extern int be_ntv_lv_imagebutton_init(bvm *vm);
extern int be_ntv_lv_keyboard_init(bvm *vm);
extern int be_ntv_lv_label_init(bvm *vm);
@ -1317,6 +1322,7 @@ extern int be_ntv_lv_msgbox_init(bvm *vm);
extern int be_ntv_lv_roller_init(bvm *vm);
extern int be_ntv_lv_scale_init(bvm *vm);
extern int be_ntv_lv_slider_init(bvm *vm);
extern int be_ntv_lv_span_init(bvm *vm);
extern int be_ntv_lv_spangroup_init(bvm *vm);
extern int be_ntv_lv_spinbox_init(bvm *vm);
extern int be_ntv_lv_spinner_init(bvm *vm);
@ -1357,6 +1363,7 @@ extern const bclass be_class_lv_qrcode;
extern const bclass be_class_lv_roller;
extern const bclass be_class_lv_scale;
extern const bclass be_class_lv_slider;
extern const bclass be_class_lv_span;
extern const bclass be_class_lv_spangroup;
extern const bclass be_class_lv_spinbox;
extern const bclass be_class_lv_spinner;
@ -1517,25 +1524,14 @@ extern void arc_anim_start_angle(void * obj, int32_t v);
extern void arc_anim_end_angle(void * obj, int32_t v);
/********************************************************************
** Solidified class: lv_image
********************************************************************/
#include "be_fixed_be_class_lv_image.h"
/* @const_object_info_begin
class be_class_lv_image (scope: global, name: lv_image, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_image_class)
init, func(be_ntv_lv_image_init)
}
@const_object_info_end */
/********************************************************************
** Solidified class: lv_qrcode
********************************************************************/
#include "be_fixed_be_class_lv_qrcode.h"
/* @const_object_info_begin
class be_class_lv_qrcode (scope: global, name: lv_qrcode, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_qrcode_class)
init, func(be_ntv_lv_qrcode_init)
_class, comptr(&lv_qrcode_class)
}
@const_object_info_end */
@ -1545,8 +1541,8 @@ class be_class_lv_qrcode (scope: global, name: lv_qrcode, super: be_class_lv_obj
#include "be_fixed_be_class_lv_animimg.h"
/* @const_object_info_begin
class be_class_lv_animimg (scope: global, name: lv_animimg, super: be_class_lv_image, strings: weak) {
_class, comptr(&lv_animimg_class)
init, func(be_ntv_lv_animimg_init)
_class, comptr(&lv_animimg_class)
}
@const_object_info_end */
@ -1556,8 +1552,8 @@ class be_class_lv_animimg (scope: global, name: lv_animimg, super: be_class_lv_i
#include "be_fixed_be_class_lv_arc.h"
/* @const_object_info_begin
class be_class_lv_arc (scope: global, name: lv_arc, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_arc_class)
init, func(be_ntv_lv_arc_init)
_class, comptr(&lv_arc_class)
}
@const_object_info_end */
@ -1567,8 +1563,8 @@ class be_class_lv_arc (scope: global, name: lv_arc, super: be_class_lv_obj, stri
#include "be_fixed_be_class_lv_bar.h"
/* @const_object_info_begin
class be_class_lv_bar (scope: global, name: lv_bar, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_bar_class)
init, func(be_ntv_lv_bar_init)
_class, comptr(&lv_bar_class)
}
@const_object_info_end */
@ -1578,8 +1574,8 @@ class be_class_lv_bar (scope: global, name: lv_bar, super: be_class_lv_obj, stri
#include "be_fixed_be_class_lv_button.h"
/* @const_object_info_begin
class be_class_lv_button (scope: global, name: lv_button, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_button_class)
init, func(be_ntv_lv_button_init)
_class, comptr(&lv_button_class)
}
@const_object_info_end */
@ -1589,8 +1585,8 @@ class be_class_lv_button (scope: global, name: lv_button, super: be_class_lv_obj
#include "be_fixed_be_class_lv_buttonmatrix.h"
/* @const_object_info_begin
class be_class_lv_buttonmatrix (scope: global, name: lv_buttonmatrix, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_buttonmatrix_class)
init, func(be_ntv_lv_buttonmatrix_init)
_class, comptr(&lv_buttonmatrix_class)
}
@const_object_info_end */
@ -1600,8 +1596,8 @@ class be_class_lv_buttonmatrix (scope: global, name: lv_buttonmatrix, super: be_
#include "be_fixed_be_class_lv_calendar.h"
/* @const_object_info_begin
class be_class_lv_calendar (scope: global, name: lv_calendar, super: be_class_lv_buttonmatrix, strings: weak) {
_class, comptr(&lv_calendar_class)
init, func(be_ntv_lv_calendar_init)
_class, comptr(&lv_calendar_class)
}
@const_object_info_end */
@ -1611,8 +1607,8 @@ class be_class_lv_calendar (scope: global, name: lv_calendar, super: be_class_lv
#include "be_fixed_be_class_lv_canvas.h"
/* @const_object_info_begin
class be_class_lv_canvas (scope: global, name: lv_canvas, super: be_class_lv_image, strings: weak) {
_class, comptr(&lv_canvas_class)
init, func(be_ntv_lv_canvas_init)
_class, comptr(&lv_canvas_class)
}
@const_object_info_end */
@ -1622,8 +1618,8 @@ class be_class_lv_canvas (scope: global, name: lv_canvas, super: be_class_lv_ima
#include "be_fixed_be_class_lv_chart.h"
/* @const_object_info_begin
class be_class_lv_chart (scope: global, name: lv_chart, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_chart_class)
init, func(be_ntv_lv_chart_init)
_class, comptr(&lv_chart_class)
}
@const_object_info_end */
@ -1633,8 +1629,8 @@ class be_class_lv_chart (scope: global, name: lv_chart, super: be_class_lv_obj,
#include "be_fixed_be_class_lv_checkbox.h"
/* @const_object_info_begin
class be_class_lv_checkbox (scope: global, name: lv_checkbox, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_checkbox_class)
init, func(be_ntv_lv_checkbox_init)
_class, comptr(&lv_checkbox_class)
}
@const_object_info_end */
@ -1644,8 +1640,19 @@ class be_class_lv_checkbox (scope: global, name: lv_checkbox, super: be_class_lv
#include "be_fixed_be_class_lv_dropdown.h"
/* @const_object_info_begin
class be_class_lv_dropdown (scope: global, name: lv_dropdown, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_dropdown_class)
init, func(be_ntv_lv_dropdown_init)
_class, comptr(&lv_dropdown_class)
}
@const_object_info_end */
/********************************************************************
** Solidified class: lv_image
********************************************************************/
#include "be_fixed_be_class_lv_image.h"
/* @const_object_info_begin
class be_class_lv_image (scope: global, name: lv_image, super: be_class_lv_obj, strings: weak) {
init, func(be_ntv_lv_image_init)
_class, comptr(&lv_image_class)
}
@const_object_info_end */
@ -1655,8 +1662,8 @@ class be_class_lv_dropdown (scope: global, name: lv_dropdown, super: be_class_lv
#include "be_fixed_be_class_lv_imagebutton.h"
/* @const_object_info_begin
class be_class_lv_imagebutton (scope: global, name: lv_imagebutton, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_imagebutton_class)
init, func(be_ntv_lv_imagebutton_init)
_class, comptr(&lv_imagebutton_class)
}
@const_object_info_end */
@ -1666,8 +1673,8 @@ class be_class_lv_imagebutton (scope: global, name: lv_imagebutton, super: be_cl
#include "be_fixed_be_class_lv_keyboard.h"
/* @const_object_info_begin
class be_class_lv_keyboard (scope: global, name: lv_keyboard, super: be_class_lv_buttonmatrix, strings: weak) {
_class, comptr(&lv_keyboard_class)
init, func(be_ntv_lv_keyboard_init)
_class, comptr(&lv_keyboard_class)
}
@const_object_info_end */
@ -1677,8 +1684,8 @@ class be_class_lv_keyboard (scope: global, name: lv_keyboard, super: be_class_lv
#include "be_fixed_be_class_lv_label.h"
/* @const_object_info_begin
class be_class_lv_label (scope: global, name: lv_label, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_label_class)
init, func(be_ntv_lv_label_init)
_class, comptr(&lv_label_class)
}
@const_object_info_end */
@ -1688,8 +1695,8 @@ class be_class_lv_label (scope: global, name: lv_label, super: be_class_lv_obj,
#include "be_fixed_be_class_lv_led.h"
/* @const_object_info_begin
class be_class_lv_led (scope: global, name: lv_led, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_led_class)
init, func(be_ntv_lv_led_init)
_class, comptr(&lv_led_class)
}
@const_object_info_end */
@ -1699,8 +1706,8 @@ class be_class_lv_led (scope: global, name: lv_led, super: be_class_lv_obj, stri
#include "be_fixed_be_class_lv_line.h"
/* @const_object_info_begin
class be_class_lv_line (scope: global, name: lv_line, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_line_class)
init, func(be_ntv_lv_line_init)
_class, comptr(&lv_line_class)
}
@const_object_info_end */
@ -1710,8 +1717,8 @@ class be_class_lv_line (scope: global, name: lv_line, super: be_class_lv_obj, st
#include "be_fixed_be_class_lv_list.h"
/* @const_object_info_begin
class be_class_lv_list (scope: global, name: lv_list, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_list_class)
init, func(be_ntv_lv_list_init)
_class, comptr(&lv_list_class)
}
@const_object_info_end */
@ -1721,8 +1728,8 @@ class be_class_lv_list (scope: global, name: lv_list, super: be_class_lv_obj, st
#include "be_fixed_be_class_lv_menu.h"
/* @const_object_info_begin
class be_class_lv_menu (scope: global, name: lv_menu, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_menu_class)
init, func(be_ntv_lv_menu_init)
_class, comptr(&lv_menu_class)
}
@const_object_info_end */
@ -1732,8 +1739,8 @@ class be_class_lv_menu (scope: global, name: lv_menu, super: be_class_lv_obj, st
#include "be_fixed_be_class_lv_msgbox.h"
/* @const_object_info_begin
class be_class_lv_msgbox (scope: global, name: lv_msgbox, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_msgbox_class)
init, func(be_ntv_lv_msgbox_init)
_class, comptr(&lv_msgbox_class)
}
@const_object_info_end */
@ -1743,8 +1750,8 @@ class be_class_lv_msgbox (scope: global, name: lv_msgbox, super: be_class_lv_obj
#include "be_fixed_be_class_lv_roller.h"
/* @const_object_info_begin
class be_class_lv_roller (scope: global, name: lv_roller, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_roller_class)
init, func(be_ntv_lv_roller_init)
_class, comptr(&lv_roller_class)
}
@const_object_info_end */
@ -1754,8 +1761,8 @@ class be_class_lv_roller (scope: global, name: lv_roller, super: be_class_lv_obj
#include "be_fixed_be_class_lv_scale.h"
/* @const_object_info_begin
class be_class_lv_scale (scope: global, name: lv_scale, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_scale_class)
init, func(be_ntv_lv_scale_init)
_class, comptr(&lv_scale_class)
}
@const_object_info_end */
@ -1765,8 +1772,21 @@ class be_class_lv_scale (scope: global, name: lv_scale, super: be_class_lv_obj,
#include "be_fixed_be_class_lv_slider.h"
/* @const_object_info_begin
class be_class_lv_slider (scope: global, name: lv_slider, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_slider_class)
init, func(be_ntv_lv_slider_init)
_class, comptr(&lv_slider_class)
}
@const_object_info_end */
/********************************************************************
** Solidified class: lv_span
********************************************************************/
#include "be_fixed_be_class_lv_span.h"
/* @const_object_info_begin
class be_class_lv_span (scope: global, name: lv_span, strings: weak) {
_p, var
tostring, func(lv_x_tostring)
member, func(lv_x_member)
init, func(be_ntv_lv_span_init)
}
@const_object_info_end */
@ -1776,8 +1796,8 @@ class be_class_lv_slider (scope: global, name: lv_slider, super: be_class_lv_obj
#include "be_fixed_be_class_lv_spangroup.h"
/* @const_object_info_begin
class be_class_lv_spangroup (scope: global, name: lv_spangroup, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_spangroup_class)
init, func(be_ntv_lv_spangroup_init)
_class, comptr(&lv_spangroup_class)
}
@const_object_info_end */
@ -1787,8 +1807,8 @@ class be_class_lv_spangroup (scope: global, name: lv_spangroup, super: be_class_
#include "be_fixed_be_class_lv_spinbox.h"
/* @const_object_info_begin
class be_class_lv_spinbox (scope: global, name: lv_spinbox, super: be_class_lv_textarea, strings: weak) {
_class, comptr(&lv_spinbox_class)
init, func(be_ntv_lv_spinbox_init)
_class, comptr(&lv_spinbox_class)
}
@const_object_info_end */
@ -1798,8 +1818,8 @@ class be_class_lv_spinbox (scope: global, name: lv_spinbox, super: be_class_lv_t
#include "be_fixed_be_class_lv_spinner.h"
/* @const_object_info_begin
class be_class_lv_spinner (scope: global, name: lv_spinner, super: be_class_lv_arc, strings: weak) {
_class, comptr(&lv_spinner_class)
init, func(be_ntv_lv_spinner_init)
_class, comptr(&lv_spinner_class)
}
@const_object_info_end */
@ -1809,8 +1829,8 @@ class be_class_lv_spinner (scope: global, name: lv_spinner, super: be_class_lv_a
#include "be_fixed_be_class_lv_switch.h"
/* @const_object_info_begin
class be_class_lv_switch (scope: global, name: lv_switch, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_switch_class)
init, func(be_ntv_lv_switch_init)
_class, comptr(&lv_switch_class)
}
@const_object_info_end */
@ -1820,8 +1840,8 @@ class be_class_lv_switch (scope: global, name: lv_switch, super: be_class_lv_obj
#include "be_fixed_be_class_lv_table.h"
/* @const_object_info_begin
class be_class_lv_table (scope: global, name: lv_table, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_table_class)
init, func(be_ntv_lv_table_init)
_class, comptr(&lv_table_class)
}
@const_object_info_end */
@ -1831,8 +1851,8 @@ class be_class_lv_table (scope: global, name: lv_table, super: be_class_lv_obj,
#include "be_fixed_be_class_lv_tabview.h"
/* @const_object_info_begin
class be_class_lv_tabview (scope: global, name: lv_tabview, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_tabview_class)
init, func(be_ntv_lv_tabview_init)
_class, comptr(&lv_tabview_class)
}
@const_object_info_end */
@ -1842,8 +1862,8 @@ class be_class_lv_tabview (scope: global, name: lv_tabview, super: be_class_lv_o
#include "be_fixed_be_class_lv_textarea.h"
/* @const_object_info_begin
class be_class_lv_textarea (scope: global, name: lv_textarea, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_textarea_class)
init, func(be_ntv_lv_textarea_init)
_class, comptr(&lv_textarea_class)
}
@const_object_info_end */
@ -1853,8 +1873,8 @@ class be_class_lv_textarea (scope: global, name: lv_textarea, super: be_class_lv
#include "be_fixed_be_class_lv_tileview.h"
/* @const_object_info_begin
class be_class_lv_tileview (scope: global, name: lv_tileview, super: be_class_lv_obj, strings: weak) {
_class, comptr(&lv_tileview_class)
init, func(be_ntv_lv_tileview_init)
_class, comptr(&lv_tileview_class)
}
@const_object_info_end */

View File

@ -3,7 +3,6 @@
// Extract function signatures from LVGL APIs in headers
// Custom Tasmota functions
void lv_image_set_tasmota_logo(lv_obj_t * img);
lv_ts_calibration_t * lv_get_ts_calibration(void);
// ======================================================================
@ -1472,3 +1471,8 @@ lv_obj_t * lv_tileview_get_tile_active(lv_obj_t * obj)
lv_theme_t * lv_theme_haspmota_init(lv_display_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)
bool lv_theme_haspmota_is_inited(void)
// ../src/lv_berry.h
void be_load_lvgl_classes(bvm *vm)
void lv_image_set_tasmota_logo(lv_obj_t * img)
lv_style_t * lv_span_get_style(lv_span_t * span)

View File

@ -354,3 +354,8 @@ int lv0_member(bvm *vm) {
be_module_load(vm, be_newstr(vm, "undefined"));
be_return(vm);
}
// temporarily fix lv_span_get_style()
lv_style_t * lv_span_get_style(lv_span_t * span) {
return &span->style;
}

View File

@ -25,6 +25,8 @@ typedef struct lv_ts_calibration_t {
} lv_ts_calibration_t;
extern lv_ts_calibration_t lv_ts_calibration;
// temporarily fix lv_span_get_style()
extern lv_style_t * lv_span_get_style(lv_span_t * span);
#ifdef __cplusplus
}

View File

@ -35,8 +35,9 @@ lv_widgets = ['obj',
'dropdown', 'image', 'label', 'line', 'roller', 'slider',
'switch', 'table', 'textarea',
# added in LVGL 9
'spangroup', 'scale',
'spangroup', 'span', 'scale',
]
lv_widgets_no_class = ['span'] # widgets that don't have a lv_obj class
# extra widgets
lv_widgets = lv_widgets + [ 'chart', 'imagebutton', 'led', 'msgbox', 'spinbox', 'spinner', 'keyboard', 'tabview', 'tileview' , 'list',
'animimg', 'calendar', 'menu']
@ -44,7 +45,7 @@ lv_widgets = lv_widgets + [ 'chart', 'imagebutton', 'led', 'msgbox', 'spinbox',
# add qrcode
lv_widgets = lv_widgets + [ 'qrcode' ]
lv_prefix = ['group', 'style', 'indev', 'display', 'timer', 'anim', 'event'] + lv_widgets
lv_prefix = ['group', 'style', 'indev', 'display', 'timer', 'anim', 'event', 'span'] + lv_widgets
# define here widget inheritance because it's hard to deduce from source
lv_widget_inheritance = {
@ -58,6 +59,7 @@ lv_widget_inheritance = {
"canvas": "image",
"roller_label": "label",
"animimg": "image",
"span": None,
}
# contains any custom attribute we need to add to a widget
@ -239,6 +241,7 @@ class type_mapper_class:
# the following types are skipped without warning, because it would be too complex to adapt (so we don't map any function using or returning these types)
skipping_type = [
"bvm *", # Berry
"lv_global_t *", # reading globals is not useful in Berry
"lv_event_dsc_t *", # internal implementation, use functions instead
"lv_draw_task_t *", # skip low-level tasks for now
@ -418,7 +421,7 @@ class type_mapper_class:
'_lv_display_t *': "lv_display",
"lv_indev_t *": "lv_indev",
"lv_point_t []": "lv_point_arr",
"lv_span_t *": "lv_spangroup",
"lv_span_t *": "lv_span",
# "lv_image_header_t *": "lv_image_header",
"lv_image_dsc_t *": "lv_image_dsc",
"lv_ts_calibration_t *": "lv_ts_calibration",
@ -829,15 +832,24 @@ const size_t lv_classes_size = sizeof(lv_classes) / sizeof(lv_classes[0]);
# keep only create
for subtype, flv in lv.items():
print(f" /* `lv_{subtype}` methods */")
create_found = False # does the method contains an explicit `_create()` method
for f in sorted(flv, key=lambda x: x.be_name):
if f.c_func_name.endswith("_create"):
create_found = True
c_ret_type = "+_p" # constructor, init method does not return any value
if subtype in lv_widgets:
print(f"#ifdef BE_LV_WIDGET_{subtype.upper()}")
print(f" int be_ntv_lv_{subtype}_init(bvm *vm) {{ return be_call_c_func(vm, (void*) &{f.orig_func_name}, \"{c_ret_type}\", \"{f.c_argc}\"); }}")
print(f" int be_ntv_lv_{subtype}_init(bvm *vm) {{ return be_call_c_func(vm, (void*) &{f.orig_func_name}, \"+_p\", \"{f.c_argc}\"); }}")
print(f"#endif // BE_LV_WIDGET_{subtype.upper()}")
else:
print(f" int be_ntv_lv_{subtype}_init(bvm *vm) {{ return be_call_c_func(vm, (void*) &{f.orig_func_name}, \"{c_ret_type}\", \"{f.c_argc}\"); }}")
print(f" int be_ntv_lv_{subtype}_init(bvm *vm) {{ return be_call_c_func(vm, (void*) &{f.orig_func_name}, \"+_p\", \"{f.c_argc}\"); }}")
if not create_found and subtype in lv_widgets:
# there is no explicit create, add one
print(f"#ifdef BE_LV_WIDGET_{subtype.upper()}")
print(f" int be_ntv_lv_{subtype}_init(bvm *vm) {{ return be_call_c_func(vm, (void*) &{f.orig_func_name}, \"+_p\", \"{f.c_argc}\"); }}")
print(f"#endif // BE_LV_WIDGET_{subtype.upper()}")
print("""
// create font either empty or from parameter on stack
@ -1072,11 +1084,18 @@ for subtype, flv in lv.items():
** Solidified class: lv_{subtype}
********************************************************************/
#include "be_fixed_be_class_lv_{subtype}.h"
/* @const_object_info_begin
class be_class_lv_{subtype} (scope: global, name: lv_{subtype}, super: be_class_lv_{super_class}, strings: weak) {{
_class, comptr(&lv_{subtype}_class)
init, func(be_ntv_lv_{subtype}_init)""")
/* @const_object_info_begin""")
if super_class is not None:
print(f"class be_class_lv_{subtype} (scope: global, name: lv_{subtype}, super: be_class_lv_{super_class}, strings: weak) {{")
else:
print(f"class be_class_lv_{subtype} (scope: global, name: lv_{subtype}, strings: weak) {{")
print(f" _p, var")
print(f" tostring, func(lv_x_tostring)")
print(f" member, func(lv_x_member)")
print(f" init, func(be_ntv_lv_{subtype}_init)")
if subtype not in lv_widgets_no_class:
print(f" _class, comptr(&lv_{subtype}_class)")
if subtype in lv_widget_custom_ptr:
for k, v in lv_widget_custom_ptr[subtype].items():
print(f" {k}, {v}")

View File

@ -81,6 +81,7 @@ lv_fun_globs = [
]
headers_names = list_files(lv_src_prefix, lv_fun_globs)
headers_names += list_files("../../LVGL_assets/src/", ["lv_theme_haspmota.h"])
headers_names += list_files("../src/", ["lv_berry.h"])
output_filename = "../mapping/lv_funcs.h"
sys.stdout = open(output_filename, 'w', encoding='utf-8')
@ -90,7 +91,6 @@ print("""
// Extract function signatures from LVGL APIs in headers
// Custom Tasmota functions
void lv_image_set_tasmota_logo(lv_obj_t * img);
lv_ts_calibration_t * lv_get_ts_calibration(void);
// ======================================================================
@ -128,6 +128,8 @@ for header_name in headers_names:
fun = re.sub('LV_ATTRIBUTE_FAST_MEM ', '', fun)
# remove LV_ATTRIBUTE_TIMER_HANDLER
fun = re.sub('LV_ATTRIBUTE_TIMER_HANDLER ', '', fun)
# remove extern
fun = re.sub('extern ', '', fun)
exclude = False
for exclude_prefix in ["typedef", "_LV_", "LV_"]:
if fun.startswith(exclude_prefix): exclude = True

View File

@ -9,43 +9,22 @@
# How to solidify (needs an ESP32 with PSRAM)
#-
import path
import path
path.remove("haspmota.bec")
import solidify
var haspmota
load('haspmota.be')
var classes = [
"page", "obj", "scr",
"btn", "switch", "checkbox",
"label", "spinner", "line", "img", "roller", "btnmatrix",
"bar", "slider", "arc", "textarea", "dropdown",
"qrcode", "chart"
]
var f = open("haspmota.c", "w")
for c:classes
solidify.dump(haspmota.HASPmota.("lvh_"+c), true, f)
end
solidify.dump(haspmota, true, f)
f.close()
print("Ok")
global.solidify_haspmota()
-#
var haspmota = module("haspmota")
#################################################################################
#################################################################################
# Class `lvh_obj` encapsulating `lv_obj``
# Class `lvh_root`
#
# Provide a mapping for virtual members
# Stores the associated page and object id
# Allows to map either a `lv_obj` for LVGL or arbitrary object
#
# Adds specific virtual members used by HASPmota
#################################################################################
#################################################################################
class lvh_obj
static var _lv_class = lv.obj # _lv_class refers to the lvgl class encapsulated, and is overriden by subclasses
static var _lv_part2_selector # selector for secondary part (like knob of arc)
class lvh_root
static var _lv_class = nil # _lv_class refers to the lvgl class encapsulated, and is overriden by subclasses
# attributes to ignore when set at object level (they are managed by page)
static var _attr_ignore = [
@ -157,9 +136,8 @@ class lvh_obj
# Instance variables
var id # (int) object hasp id
var _lv_obj # native lvgl object
var _lv_label # sub-label if exists
var _page # parent page object
var _action # value of the HASPmota `action` attribute, shouldn't be called `self.action` since we want to trigger the set/member functions
var _parent_lvh # parent HASPmota object if 'parentid' was set, or 'nil'
var _meta # free form metadata
#====================================================================
@ -250,15 +228,82 @@ class lvh_obj
return lv.color(0x000000)
end
#====================================================================
# parse_font
#
# For HASPmota compatiblity, default to "robotocondensed-latin1"
# However we propose an extension to allow for other font names
#
# Arg1: (int) font size for `robotocondensed-latin1`
# or
# Arg1: (string) "font_name-font_size", ex: "montserrat-20"
#====================================================================
def parse_font(t)
var font
if type(t) == 'int'
try
font = lv.font_embedded("robotocondensed", t)
except ..
try
font = lv.font_embedded("montserrat", t)
except ..
print("HSP: Unsupported font:", t)
return nil
end
end
elif type(t) == 'string'
import string
import re
# look for 'A:name.font' style font file name
var drive_split = string.split(t, ':', 1)
var fn_split = string.split(t, '-')
var name = t
var sz = 0
var is_ttf = false
var is_binary = (size(drive_split) > 1 && size(drive_split[0]))
if size(fn_split) >= 2
sz = int(fn_split[-1])
name = fn_split[0..-2].concat('-') # rebuild the font name
end
if re.match(".*\\.ttf$", name)
# ttf font
name = string.split(name, ':')[-1] # remove A: if any
is_ttf = true
end
if is_ttf
font = lv.load_freetype_font(name, sz, 0)
elif is_binary
# font is from disk
font = lv.load_font(t)
elif sz > 0 && size(name) > 0 # looks good, let's have a try
try
font = lv.font_embedded(name, sz)
except ..
print("HSP: Unsupported font:", t)
end
end
end
if font != nil
return font
else
print("HSP: Unsupported font:", t)
end
end
#====================================================================
# init HASPmota object from its jsonl definition
#
# arg1: LVGL parent object (used to create a sub-object)
# arg2: `jline` JSONL definition of the object from HASPmota template (used in sub-classes)
# arg3: (opt) LVGL object if it already exists and was created prior to init()
# arg4: HASPmota parent object defined by `parentid`
#====================================================================
def init(parent, page, jline, obj)
def init(parent, page, jline, obj, parent_lvh)
self._page = page
self._parent_lvh = parent_lvh
if obj == nil && self._lv_class
var obj_class = self._lv_class # assign to a var to distinguish from method call
self._lv_obj = obj_class(parent) # instanciate LVGL object
@ -268,13 +313,6 @@ class lvh_obj
self.post_init()
end
#====================================================================
# post-init, to be overriden and used by certain classes
#====================================================================
def post_init()
self.register_event_cb()
end
#####################################################################
# General Setters and Getters
#####################################################################
@ -286,6 +324,283 @@ class lvh_obj
return self._lv_obj
end
#====================================================================
# 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)
end
def get_text()
return nil
end
#- ------------------------------------------------------------#
# `digits_to_style`
#
# Convert a 2 digits style descriptor to LVGL style modifier
# See https://www.openhasp.com/0.6.3/design/styling/
#
#
# 00 = main part of the object (i.e. the background)
# 10 = the indicator or needle, highlighting the the current value
# 20 = the knob which can be used the change the value
# 30 = the background of the items/buttons
# 40 = the items/buttons
# 50 = the selected item
# 60 = major ticks of the gauge object
# 70 = the text cursor
# 80 = the scrollbar
# 90 = other special part, not listed above
#
# LV_PART_MAIN = 0x000000, /**< A background like rectangle*/
# LV_PART_SCROLLBAR = 0x010000, /**< The scrollbar(s)*/
# LV_PART_INDICATOR = 0x020000, /**< Indicator, e.g. for slider, bar, switch, or the tick box of the checkbox*/
# LV_PART_KNOB = 0x030000, /**< Like handle to grab to adjust the value*/
# LV_PART_SELECTED = 0x040000, /**< Indicate the currently selected option or section*/
# LV_PART_ITEMS = 0x050000, /**< Used if the widget has multiple similar elements (e.g. table cells)*/
# LV_PART_CURSOR = 0x060000, /**< Mark a specific place e.g. for text area's cursor or on a chart*/
# LV_PART_CUSTOM_FIRST = 0x080000, /**< Extension point for custom widgets*/
# LV_PART_ANY = 0x0F0000, /**< Special value can be used in some functions to target all parts*/
#
# 00 = default styling
# 01 = styling for toggled state
# 02 = styling for pressed, not toggled state
# 03 = styling for pressed and toggled state
# 04 = styling for disabled not toggled state
# 05 = styling for disabled and toggled state
#
# LV_STATE_DEFAULT = 0x0000,
# LV_STATE_CHECKED = 0x0001,
# LV_STATE_FOCUSED = 0x0002,
# LV_STATE_FOCUS_KEY = 0x0004,
# LV_STATE_EDITED = 0x0008,
# LV_STATE_HOVERED = 0x0010,
# LV_STATE_PRESSED = 0x0020,
# LV_STATE_SCROLLED = 0x0040,
# LV_STATE_DISABLED = 0x0080,
# LV_STATE_USER_1 = 0x1000,
# LV_STATE_USER_2 = 0x2000,
# LV_STATE_USER_3 = 0x4000,
# LV_STATE_USER_4 = 0x8000,
#
#- ------------------------------------------------------------#
static var _digit2part = [
lv.PART_MAIN, # 00
lv.PART_INDICATOR, # 10
lv.PART_KNOB, # 20
lv.PART_ITEMS, # 30 TODO
lv.PART_ITEMS, # 40
lv.PART_SELECTED, # 50
lv.PART_ITEMS, # 60
lv.PART_CURSOR, # 70
lv.PART_SCROLLBAR, # 80
lv.PART_CUSTOM_FIRST, # 90
]
static var _digit2state = [
lv.STATE_DEFAULT, # 00
lv.STATE_CHECKED, # 01
lv.STATE_PRESSED, # 02
lv.STATE_CHECKED | lv.STATE_PRESSED, # 03
lv.STATE_DISABLED, # 04
lv.STATE_DISABLED | lv.STATE_PRESSED, # 05
]
def digits_to_style(digits)
if digits == nil return 0 end # lv.PART_MAIN | lv.STATE_DEFAULT
var first_digit = (digits / 10) % 10
var second_digit = digits % 10
var val = 0 # lv.PART_MAIN | lv.STATE_DEFAULT
if first_digit >= 0 && first_digit < size(self._digit2part)
val = val | self._digit2part[first_digit]
else
val = nil
end
if second_digit >= 0 && second_digit < size(self._digit2state)
val = val | self._digit2state[second_digit]
else
val = nil
end
if val == nil
raise "value_error", f"invalid style suffix {digits:02i}"
end
return val
end
#====================================================================
# Metadata
#
#====================================================================
def set_meta(t)
self._meta = t
end
def get_meta()
return self._meta
end
#====================================================================
# Rule based updates of `val` and `text`
#
# `val_rule`: rule pattern to grab a value, ex: `ESP32#Temperature`
# `val_rule_formula`: formula in Berry to transform the value
# Ex: `val * 10`
# `text_rule`: rule pattern to grab a value for text, ex: `ESP32#Temparature`
# `text_rule_format`: format used by `format()`
# Ex: `%.1f °C`
#====================================================================
def remove_val_rule()
if self._val_rule != nil
tasmota.remove_rule(self._val_rule, self)
end
end
def set_val_rule(t)
# remove previous rule if any
self.remove_val_rule()
self._val_rule = str(t)
tasmota.add_rule(self._val_rule, / val -> self.val_rule_matched(val), self)
end
def get_val_rule()
return self._val_rule
end
# text_rule
def remove_text_rule()
if self._text_rule != nil
tasmota.remove_rule(self._text_rule, self)
end
end
def set_text_rule(t)
# remove previous rule if any
self.remove_text_rule()
self._text_rule = str(t)
tasmota.add_rule(self._text_rule, / val -> self.text_rule_matched(val), self)
end
def get_text_rule()
return self._text_rule
end
def set_text_rule_format(t)
self._text_rule_format = str(t)
end
def get_text_rule_format()
return self._text_rule_format
end
# formula that gets compiled as Berry code
def set_val_rule_formula(t)
self._val_rule_formula = str(t)
var code = "return / val -> (" + self._val_rule_formula + ")"
try
var func = compile(code)
self._val_rule_function = func()
except .. as e, m
print(format("HSP: failed to compile '%s' - %s (%s)", code, e, m))
end
end
def get_val_rule_formula()
return self._val_rule_formula
end
# formula that gets compiled as Berry code
def set_text_rule_formula(t)
self._text_rule_formula = str(t)
var code = "return / val -> (" + self._text_rule_formula + ")"
try
var func = compile(code)
self._text_rule_function = func()
except .. as e, m
print(format("HSP: failed to compile '%s' - %s (%s)", code, e, m))
end
end
def get_text_rule_formula()
return self._text_rule_formula
end
# rule matched for val
def val_rule_matched(val)
# print(">> rule matched", "val=", val)
var val_n = real(val) # force float type
if val_n == nil return false end # if the matched value is not a number, ignore
var func = self._val_rule_function
if func != nil
try
val_n = func(val_n)
except .. as e, m
print(format("HSP: failed to run self._val_rule_function - %s (%s)", e, m))
end
end
self.val = int(val_n) # set value, truncate to int
return false # propagate the event further
end
# rule matched for text
def text_rule_matched(val)
# print(">> rule matched text", "val=", val)
if type(val) == 'int'
val = real(val) # force float type
end
var func = self._text_rule_function
if func != nil
try
val = func(val)
except .. as e, m
print(format("HSP: failed to run self._text_rule_function - %s (%s)", e, m))
end
end
var fmt = self._text_rule_format
if type(fmt) == 'string'
fmt = format(fmt, val)
else
fmt = ""
end
self.text = fmt
return false # propagate the event further
end
end
#################################################################################
#################################################################################
# Class `lvh_obj` encapsulating `lv_obj``
#
# Provide a mapping for virtual members
# Stores the associated page and object id
#
# Adds specific virtual members used by HASPmota
#################################################################################
#################################################################################
class lvh_obj : lvh_root
static var _lv_class = lv.obj # _lv_class refers to the lvgl class encapsulated, and is overriden by subclasses
static var _lv_part2_selector # selector for secondary part (like knob of arc)
#====================================================================
# Instance variables
var _lv_label # sub-label if exists
var _action # value of the HASPmota `action` attribute, shouldn't be called `self.action` since we want to trigger the set/member functions
#====================================================================
# init HASPmota object from its jsonl definition
#
# arg1: LVGL parent object (used to create a sub-object)
# arg2: `jline` JSONL definition of the object from HASPmota template (used in sub-classes)
# arg3: (opt) LVGL object if it already exists and was created prior to init()
# arg4: HASPmota parent object defined by `parentid`
#====================================================================
def init(parent, page, jline, obj, parent_lvh)
super(self).init(parent, page, jline, obj, parent_lvh)
end
#====================================================================
# post-init, to be overriden and used by certain classes
#====================================================================
def post_init()
self.register_event_cb()
end
#####################################################################
# General Setters and Getters
#####################################################################
#====================================================================
# Value of the `action` attribute
#====================================================================
@ -476,12 +791,10 @@ class lvh_obj
self.check_label()
self._lv_label.set_text(str(t))
end
def set_value_str(t) self.set_text(t) end
def get_text()
if self._lv_label == nil return nil end
return self._lv_label.get_text()
end
def get_value_str() return self.get_text() end
# mode
def set_mode(t)
@ -542,56 +855,9 @@ class lvh_obj
# Arg1: (string) "font_name-font_size", ex: "montserrat-20"
#====================================================================
def set_text_font(t)
# self.check_label()
var font
if type(t) == 'int'
try
font = lv.font_embedded("robotocondensed", t)
except ..
try
font = lv.font_embedded("montserrat", t)
except ..
return
end
end
elif type(t) == 'string'
import string
import re
# look for 'A:name.font' style font file name
var drive_split = string.split(t, ':', 1)
var fn_split = string.split(t, '-')
var name = t
var sz = 0
var is_ttf = false
var is_binary = (size(drive_split) > 1 && size(drive_split[0]))
if size(fn_split) >= 2
sz = int(fn_split[-1])
name = fn_split[0..-2].concat('-') # rebuild the font name
end
if re.match(".*\\.ttf$", name)
# ttf font
name = string.split(name, ':')[-1] # remove A: if any
is_ttf = true
end
if is_ttf
font = lv.load_freetype_font(name, sz, 0)
elif is_binary
# font is from disk
font = lv.load_font(t)
elif sz > 0 && size(name) > 0 # looks good, let's have a try
try
font = lv.font_embedded(name, sz)
except ..
end
end
end
var font = self.parse_font(t)
if font != nil
self._lv_obj.set_style_text_font(font, 0 #- lv.PART_MAIN | lv.STATE_DEFAULT -#)
else
print("HSP: Unsupported font:", t)
end
end
def get_text_font()
@ -705,98 +971,6 @@ class lvh_obj
end
end
#- ------------------------------------------------------------#
# `digits_to_style`
#
# Convert a 2 digits style descriptor to LVGL style modifier
# See https://www.openhasp.com/0.6.3/design/styling/
#
#
# 00 = main part of the object (i.e. the background)
# 10 = the indicator or needle, highlighting the the current value
# 20 = the knob which can be used the change the value
# 30 = the background of the items/buttons
# 40 = the items/buttons
# 50 = the selected item
# 60 = major ticks of the gauge object
# 70 = the text cursor
# 80 = the scrollbar
# 90 = other special part, not listed above
#
# LV_PART_MAIN = 0x000000, /**< A background like rectangle*/
# LV_PART_SCROLLBAR = 0x010000, /**< The scrollbar(s)*/
# LV_PART_INDICATOR = 0x020000, /**< Indicator, e.g. for slider, bar, switch, or the tick box of the checkbox*/
# LV_PART_KNOB = 0x030000, /**< Like handle to grab to adjust the value*/
# LV_PART_SELECTED = 0x040000, /**< Indicate the currently selected option or section*/
# LV_PART_ITEMS = 0x050000, /**< Used if the widget has multiple similar elements (e.g. table cells)*/
# LV_PART_CURSOR = 0x060000, /**< Mark a specific place e.g. for text area's cursor or on a chart*/
# LV_PART_CUSTOM_FIRST = 0x080000, /**< Extension point for custom widgets*/
# LV_PART_ANY = 0x0F0000, /**< Special value can be used in some functions to target all parts*/
#
# 00 = default styling
# 01 = styling for toggled state
# 02 = styling for pressed, not toggled state
# 03 = styling for pressed and toggled state
# 04 = styling for disabled not toggled state
# 05 = styling for disabled and toggled state
#
# LV_STATE_DEFAULT = 0x0000,
# LV_STATE_CHECKED = 0x0001,
# LV_STATE_FOCUSED = 0x0002,
# LV_STATE_FOCUS_KEY = 0x0004,
# LV_STATE_EDITED = 0x0008,
# LV_STATE_HOVERED = 0x0010,
# LV_STATE_PRESSED = 0x0020,
# LV_STATE_SCROLLED = 0x0040,
# LV_STATE_DISABLED = 0x0080,
# LV_STATE_USER_1 = 0x1000,
# LV_STATE_USER_2 = 0x2000,
# LV_STATE_USER_3 = 0x4000,
# LV_STATE_USER_4 = 0x8000,
#
#- ------------------------------------------------------------#
static var _digit2part = [
lv.PART_MAIN, # 00
lv.PART_INDICATOR, # 10
lv.PART_KNOB, # 20
lv.PART_ITEMS, # 30 TODO
lv.PART_ITEMS, # 40
lv.PART_SELECTED, # 50
lv.PART_ITEMS, # 60
lv.PART_CURSOR, # 70
lv.PART_SCROLLBAR, # 80
lv.PART_CUSTOM_FIRST, # 90
]
static var _digit2state = [
lv.STATE_DEFAULT, # 00
lv.STATE_CHECKED, # 01
lv.STATE_PRESSED, # 02
lv.STATE_CHECKED | lv.STATE_PRESSED, # 03
lv.STATE_DISABLED, # 04
lv.STATE_DISABLED | lv.STATE_PRESSED, # 05
]
def digits_to_style(digits)
if digits == nil return 0 end # lv.PART_MAIN | lv.STATE_DEFAULT
var first_digit = (digits / 10) % 10
var second_digit = digits % 10
var val = 0 # lv.PART_MAIN | lv.STATE_DEFAULT
if first_digit >= 0 && first_digit < size(self._digit2part)
val = val | self._digit2part[first_digit]
else
val = nil
end
if second_digit >= 0 && second_digit < size(self._digit2state)
val = val | self._digit2state[second_digit]
else
val = nil
end
if val == nil
raise "value_error", f"invalid style suffix {digits:02i}"
end
return val
end
#- ------------------------------------------------------------#
# Internal utility functions
#
@ -943,137 +1117,6 @@ class lvh_obj
end
end
#====================================================================
# Metadata
#
#====================================================================
def set_meta(t)
self._meta = t
end
def get_meta()
return self._meta
end
#====================================================================
# Rule based updates of `val` and `text`
#
# `val_rule`: rule pattern to grab a value, ex: `ESP32#Temperature`
# `val_rule_formula`: formula in Berry to transform the value
# Ex: `val * 10`
# `text_rule`: rule pattern to grab a value for text, ex: `ESP32#Temparature`
# `text_rule_format`: format used by `format()`
# Ex: `%.1f °C`
#====================================================================
def remove_val_rule()
if self._val_rule != nil
tasmota.remove_rule(self._val_rule, self)
end
end
def set_val_rule(t)
# remove previous rule if any
self.remove_val_rule()
self._val_rule = str(t)
tasmota.add_rule(self._val_rule, / val -> self.val_rule_matched(val), self)
end
def get_val_rule()
return self._val_rule
end
# text_rule
def remove_text_rule()
if self._text_rule != nil
tasmota.remove_rule(self._text_rule, self)
end
end
def set_text_rule(t)
# remove previous rule if any
self.remove_text_rule()
self._text_rule = str(t)
tasmota.add_rule(self._text_rule, / val -> self.text_rule_matched(val), self)
end
def get_text_rule()
return self._text_rule
end
def set_text_rule_format(t)
self._text_rule_format = str(t)
end
def get_text_rule_format()
return self._text_rule_format
end
# formula that gets compiled as Berry code
def set_val_rule_formula(t)
self._val_rule_formula = str(t)
var code = "return / val -> (" + self._val_rule_formula + ")"
try
var func = compile(code)
self._val_rule_function = func()
except .. as e, m
print(format("HSP: failed to compile '%s' - %s (%s)", code, e, m))
end
end
def get_val_rule_formula()
return self._val_rule_formula
end
# formula that gets compiled as Berry code
def set_text_rule_formula(t)
self._text_rule_formula = str(t)
var code = "return / val -> (" + self._text_rule_formula + ")"
try
var func = compile(code)
self._text_rule_function = func()
except .. as e, m
print(format("HSP: failed to compile '%s' - %s (%s)", code, e, m))
end
end
def get_text_rule_formula()
return self._text_rule_formula
end
# rule matched for val
def val_rule_matched(val)
# print(">> rule matched", "val=", val)
var val_n = real(val) # force float type
if val_n == nil return false end # if the matched value is not a number, ignore
var func = self._val_rule_function
if func != nil
try
val_n = func(val_n)
except .. as e, m
print(format("HSP: failed to run self._val_rule_function - %s (%s)", e, m))
end
end
self.val = int(val_n) # set value, truncate to int
return false # propagate the event further
end
# rule matched for text
def text_rule_matched(val)
# print(">> rule matched text", "val=", val)
if type(val) == 'int'
val = real(val) # force float type
end
var func = self._text_rule_function
if func != nil
try
val = func(val)
except .. as e, m
print(format("HSP: failed to run self._text_rule_function - %s (%s)", e, m))
end
end
var fmt = self._text_rule_format
if type(fmt) == 'string'
fmt = format(fmt, val)
else
fmt = ""
end
self.text = fmt
return false # propagate the event further
end
end
#################################################################################
@ -1361,6 +1404,143 @@ class lvh_bar : lvh_obj
end
end
#====================================================================
# spangroup
#====================================================================
class lvh_spangroup : lvh_obj
static _lv_class = lv.spangroup
# label do not need a sub-label
def post_init()
self._lv_obj.set_mode(lv.SPAN_MODE_BREAK) # use lv.SPAN_MODE_BREAK by default
self._lv_obj.refr_mode()
super(self).post_init() # call super -- not needed
end
# refresh mode
def refr_mode()
self._lv_obj.refr_mode()
end
end
#====================================================================
# span
#====================================================================
class lvh_span : lvh_root
static _lv_class = nil
# label do not need a sub-label
var _style # style object
def post_init()
self._lv_obj = nil # default to nil object, whatever it was initialized with
# check if it is the parent is a spangroup
if isinstance(self._parent_lvh, self._page._oh.lvh_spangroup)
# print(">>> GOOD")
self._lv_obj = self._parent_lvh._lv_obj.new_span()
self._style = self._lv_obj.get_style()
end
# super(self).post_init() # call super - not needed for lvh_root
end
#====================================================================
def set_text(t)
self._lv_obj.set_text(str(t))
end
#====================================================================
def set_text_font(t)
var font = self.parse_font(t)
if font != nil
self._style.set_text_font(font)
self._parent_lvh.refr_mode()
end
end
#- ------------------------------------------------------------#
# Internal utility functions
#
# Mapping of virtual attributes
#
#- ------------------------------------------------------------#
# There are no attributes that can be read from `lv.style``
# so we don't need virtual members
#- ------------------------------------------------------------#
# def member(k)
# import string
# import introspect
# do
# var prefix = k[0..3]
# if prefix == "set_" || prefix == "get_" return end # avoid recursion
# end
# # if attribute name is in ignore list, abort
# if self._attr_ignore.find(k) != nil return end
# # first check if there is a method named `get_X()`
# var f = introspect.get(self, "get_" + k)
# if type(f) == 'function'
# # print(f">>>: setmember local method set_{k}")
# return f(self)
# end
# # finally try any `get_XXX` within the LVGL object
# f = introspect.get(self._style, "get_" + k)
# if type(f) == 'function' # found and function, call it
# return f(self._style)
# end
# # fallback to exception if attribute unknown or not a function
# return module("undefined")
# end
#- ------------------------------------------------------------#
# `setmember` virtual setter
# trimmed down version for style only
#- ------------------------------------------------------------#
def setmember(k, v)
import string
import introspect
do
# print(">>>: span setmember", k, v)
var prefix = k[0..3]
if prefix == "set_" || prefix == "get_" return end # avoid infinite loop
end
# if attribute name is in ignore list, abort
if self._attr_ignore.find(k) != nil return end
# first check if there is a method named `set_X()`
var f = introspect.get(self, "set_" + k)
if type(f) == 'function'
# print(f">>>: setmember local method set_{k}")
f(self, v)
return
end
# simply check if a method `set_{k}` exists
f = introspect.get(self._style, "set_" + k) # look at style
# print(f">>>: span name={'set_' + k} {f=}")
if (type(f) == 'function')
# if the attribute contains 'color', convert to lv_color
if self.is_color_attribute(k)
v = self.parse_color(v)
end
# invoke
try
f(self._style, v)
self._parent_lvh.refr_mode()
except .. as e, m
raise e, m + " for " + k
end
return nil
else
print("HSP: Could not find function set_" + k)
end
end
end
#################################################################################
# Special case for lv.chart
# Adapted to getting values one after the other
@ -1620,6 +1800,8 @@ class HASPmota
var event_cb # the low-level callback for the closure to be registered
# assign lvh_page to a static attribute
static lvh_root = lvh_root
static lvh_obj = lvh_obj
static lvh_page = lvh_page
static lvh_scr = lvh_scr
# assign all classes as static attributes
@ -1629,7 +1811,6 @@ class HASPmota
static lvh_label = lvh_label
# static lvh_led = lvh_led
static lvh_spinner = lvh_spinner
static lvh_obj = lvh_obj
static lvh_line = lvh_line
static lvh_img = lvh_img
static lvh_dropdown = lvh_dropdown
@ -1645,6 +1826,8 @@ class HASPmota
# static lvh_linemeter = lvh_linemeter
# static lvh_gauge = lvh_gauge
static lvh_textarea = lvh_textarea # additional?
static lvh_spangroup = lvh_spangroup
static lvh_span = lvh_span
static lvh_qrcode = lvh_qrcode
# special cases
static lvh_chart = lvh_chart
@ -2011,8 +2194,9 @@ class HASPmota
var parent_lvgl
var parent_id = int(jline.find("parentid"))
var parent_obj
if parent_id != nil
var parent_obj = lvh_page_cur.get_obj(parent_id) # get parent object
parent_obj = lvh_page_cur.get_obj(parent_id) # get parent object
if parent_obj != nil parent_lvgl = parent_obj._lv_obj end # parent
end
if parent_lvgl == nil
@ -2049,7 +2233,7 @@ class HASPmota
end
# instanciate the object, passing the lvgl screen as parent object
obj_lvh = obj_class(parent_lvgl, page, jline, lv_instance)
obj_lvh = obj_class(parent_lvgl, page, jline, lv_instance, parent_obj)
# add object to page object
lvh_page_cur.add_obj(obj_id, obj_lvh)
@ -2102,5 +2286,55 @@ haspmota.init = def (m) # `init(m)` is called during first `import haspm
return oh()
end
#################################################################################
# Solidify
#################################################################################
def solidify_haspmota()
import path
path.remove("haspmota.bec")
import solidify
import introspect
var classes = [
"root",
"page", "obj", "scr",
"btn", "switch", "checkbox",
"label", "spinner", "line", "img", "roller", "btnmatrix",
"bar", "slider", "arc", "textarea", "dropdown",
"qrcode", "chart", "spangroup", "span",
# new internal names
"button", "image", "buttonmatrix",
]
var f = open("be_lv_haspmota.c", "w")
f.write(
'/********************************************************************\n'
' * Tasmota HASPmota solidified\n'
' *******************************************************************/\n'
'#include "be_constobj.h"\n'
'\n'
'#ifdef USE_LVGL\n'
'#ifdef USE_LVGL_HASPMOTA\n'
'\n'
)
for c:classes
f.write(f'extern const bclass be_class_lv_{c};\n')
end
for c:classes
if introspect.contains(haspmota.HASPmota, "lvh_"+c)
solidify.dump(haspmota.HASPmota.("lvh_"+c), true, f)
end
end
solidify.dump(haspmota, true, f)
f.write(
'\n'
'#endif // USE_LVGL_HASPMOTA\n'
'#endif // USE_LVGL\n'
)
f.close()
print("Ok")
end
global.haspmota = haspmota
return haspmota

View File

@ -1228,6 +1228,7 @@
#define BE_LV_WIDGET_SPINBOX
#define BE_LV_WIDGET_SPINNER
#define BE_LV_WIDGET_SPANGROUP
#define BE_LV_WIDGET_SPAN
// #define BE_LV_WIDGET_TABVIEW
// #define BE_LV_WIDGET_TILEVIEW