LVGL add helper functions (#20968)

This commit is contained in:
s-hadinger 2024-03-16 23:50:03 +01:00 committed by GitHub
parent e218550447
commit 130c3f83f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 79 additions and 12 deletions

View File

@ -117,8 +117,6 @@ point_set|comptr, int, int||[lv_point_set](https://docs.lvgl.io/9.0/search.html?
point_swap|comptr, comptr||[lv_point_swap](https://docs.lvgl.io/9.0/search.html?q=lv_point_swap)
point_transform|comptr, int, int, int, comptr, bool||[lv_point_transform](https://docs.lvgl.io/9.0/search.html?q=lv_point_transform)
refr_now|lv.display||[lv_refr_now](https://docs.lvgl.io/9.0/search.html?q=lv_refr_now)
scale_section_set_range|comptr, int, int||[lv_scale_section_set_range](https://docs.lvgl.io/9.0/search.html?q=lv_scale_section_set_range)
scale_section_set_style|comptr, int, lv.style||[lv_scale_section_set_style](https://docs.lvgl.io/9.0/search.html?q=lv_scale_section_set_style)
scr_act||lv.obj|[lv_screen_active](https://docs.lvgl.io/9.0/search.html?q=lv_screen_active)
scr_load|lv.obj||[lv_screen_load](https://docs.lvgl.io/9.0/search.html?q=lv_screen_load)
scr_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)
@ -1166,6 +1164,8 @@ set_text_static|string||[lv_label_set_text_static](https://docs.lvgl.io/9.0/sear
Method|Arguments|Return type|LVGL equivalent
:---|:---|:---|:---
get_points||comptr|[lv_line_get_points](https://docs.lvgl.io/9.0/search.html?q=lv_line_get_points)
get_points_num||int|[lv_line_get_points_num](https://docs.lvgl.io/9.0/search.html?q=lv_line_get_points_num)
get_y_invert||bool|[lv_line_get_y_invert](https://docs.lvgl.io/9.0/search.html?q=lv_line_get_y_invert)
set_points|lv.point_arr, int||[lv_line_set_points](https://docs.lvgl.io/9.0/search.html?q=lv_line_set_points)
set_y_invert|bool||[lv_line_set_y_invert](https://docs.lvgl.io/9.0/search.html?q=lv_line_set_y_invert)
@ -1303,11 +1303,18 @@ get_style||lv.style|[lv_span_get_style](https://docs.lvgl.io/9.0/search.html?q=l
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_section`
Method|Arguments|Return type|LVGL equivalent
:---|:---|:---|:---
set_range|int, int||[lv_scale_section_set_range](https://docs.lvgl.io/9.0/search.html?q=lv_scale_section_set_range)
set_style|int, lv.style||[lv_scale_section_set_style](https://docs.lvgl.io/9.0/search.html?q=lv_scale_section_set_style)
### widget `lv.scale`
Method|Arguments|Return type|LVGL equivalent
:---|:---|:---|:---
add_section||comptr|[lv_scale_add_section](https://docs.lvgl.io/9.0/search.html?q=lv_scale_add_section)
add_section||lv.scale_section|[lv_scale_add_section](https://docs.lvgl.io/9.0/search.html?q=lv_scale_add_section)
get_angle_range||int|[lv_scale_get_angle_range](https://docs.lvgl.io/9.0/search.html?q=lv_scale_get_angle_range)
get_label_show||bool|[lv_scale_get_label_show](https://docs.lvgl.io/9.0/search.html?q=lv_scale_get_label_show)
get_major_tick_every||int|[lv_scale_get_major_tick_every](https://docs.lvgl.io/9.0/search.html?q=lv_scale_get_major_tick_every)

View File

@ -1074,6 +1074,8 @@ const be_ntv_func_def_t lv_led_func[] = {
/* `lv_line` methods */
#ifdef BE_LV_WIDGET_LINE
const be_ntv_func_def_t lv_line_func[] = {
{ "get_points", { (const void*) &lv_line_get_points, "c", "(lv.obj)" } },
{ "get_points_num", { (const void*) &lv_line_get_points_num, "i", "(lv.obj)" } },
{ "get_y_invert", { (const void*) &lv_line_get_y_invert, "b", "(lv.obj)" } },
{ "set_points", { (const void*) &lv_line_set_points, "", "(lv.obj)(lv.point_arr)i" } },
{ "set_y_invert", { (const void*) &lv_line_set_y_invert, "", "(lv.obj)b" } },
@ -1149,7 +1151,7 @@ const be_ntv_func_def_t lv_roller_func[] = {
/* `lv_scale` methods */
#ifdef BE_LV_WIDGET_SCALE
const be_ntv_func_def_t lv_scale_func[] = {
{ "add_section", { (const void*) &lv_scale_add_section, "c", "(lv.obj)" } },
{ "add_section", { (const void*) &lv_scale_add_section, "lv.scale_section", "(lv.obj)" } },
{ "get_angle_range", { (const void*) &lv_scale_get_angle_range, "i", "(lv.obj)" } },
{ "get_label_show", { (const void*) &lv_scale_get_label_show, "b", "(lv.obj)" } },
{ "get_major_tick_every", { (const void*) &lv_scale_get_major_tick_every, "i", "(lv.obj)" } },
@ -1172,6 +1174,14 @@ const be_ntv_func_def_t lv_scale_func[] = {
};
#endif // BE_LV_WIDGET_SCALE
/* `lv_scale_section` methods */
#ifdef BE_LV_WIDGET_SCALE_SECTION
const be_ntv_func_def_t lv_scale_section_func[] = {
{ "set_range", { (const void*) &lv_scale_section_set_range, "", "(lv.scale_section)ii" } },
{ "set_style", { (const void*) &lv_scale_section_set_style, "", "(lv.scale_section)i(lv.style)" } },
};
#endif // BE_LV_WIDGET_SCALE_SECTION
/* `lv_slider` methods */
#ifdef BE_LV_WIDGET_SLIDER
const be_ntv_func_def_t lv_slider_func[] = {
@ -1384,6 +1394,7 @@ extern const bclass be_class_lv_obj;
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_scale_section;
extern const bclass be_class_lv_slider;
extern const bclass be_class_lv_span;
extern const bclass be_class_lv_spangroup;
@ -1477,6 +1488,9 @@ const be_ntv_class_def_t lv_classes[] = {
#ifdef BE_LV_WIDGET_SCALE
{ "lv_scale", &be_class_lv_scale, lv_scale_func, sizeof(lv_scale_func) / sizeof(lv_scale_func[0]) },
#endif // BE_LV_WIDGET_SCALE
#ifdef BE_LV_WIDGET_SCALE_SECTION
{ "lv_scale_section", &be_class_lv_scale_section, lv_scale_section_func, sizeof(lv_scale_section_func) / sizeof(lv_scale_section_func[0]) },
#endif // BE_LV_WIDGET_SCALE_SECTION
#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
@ -1634,6 +1648,10 @@ const size_t lv_classes_size = sizeof(lv_classes) / sizeof(lv_classes[0]);
#ifdef BE_LV_WIDGET_SCALE
int be_ntv_lv_scale_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_scale_create, "+_p", "(lv.obj)"); }
#endif // BE_LV_WIDGET_SCALE
/* `lv_scale_section` methods */
#ifdef BE_LV_WIDGET_SCALE_SECTION
int be_ntv_lv_scale_section_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_scale_section_set_style, "+_p", "(lv.scale_section)i(lv.style)"); }
#endif // BE_LV_WIDGET_SCALE_SECTION
/* `lv_slider` methods */
#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)"); }

View File

@ -139,8 +139,6 @@ const be_ntv_func_def_t lv_func[] = {
{ "point_swap", { (const void*) &lv_point_swap, "", "cc" } },
{ "point_transform", { (const void*) &lv_point_transform, "", "ciiicb" } },
{ "refr_now", { (const void*) &lv_refr_now, "", "(lv.display)" } },
{ "scale_section_set_range", { (const void*) &lv_scale_section_set_range, "", "cii" } },
{ "scale_section_set_style", { (const void*) &lv_scale_section_set_style, "", "ci(lv.style)" } },
{ "scr_act", { (const void*) &lv_screen_active, "lv.obj", "" } },
{ "scr_load", { (const void*) &lv_screen_load, "", "(lv.obj)" } },
{ "scr_load_anim", { (const void*) &lv_screen_load_anim, "", "(lv.obj)iiib" } },

View File

@ -20,6 +20,7 @@ extern int lv_x_member(bvm *vm);
extern int lv_x_tostring(bvm *vm); // generic function
extern int lv_be_style_init(bvm *vm);
extern int lv_be_style_del(bvm *vm);
extern int lv_be_anim_init(bvm *vm);
extern int lv_x_tostring(bvm *vm);
@ -62,6 +63,7 @@ extern int be_ntv_lv_menu_init(bvm *vm);
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_scale_section_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);
@ -103,6 +105,7 @@ extern const bclass be_class_lv_obj;
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_scale_section;
extern const bclass be_class_lv_slider;
extern const bclass be_class_lv_span;
extern const bclass be_class_lv_spangroup;
@ -126,6 +129,7 @@ extern const bclass be_class_lv_timer;
class be_class_lv_style (scope: global, name: lv_style, strings: weak) {
_p, var
init, func(lv_be_style_init)
del, func(lv_be_style_del)
tostring, func(lv_x_tostring)
member, func(lv_x_member)
}
@ -507,6 +511,16 @@ class be_class_lv_scale (scope: global, name: lv_scale, super: be_class_lv_obj,
}
@const_object_info_end */
/********************************************************************
** Solidified class: lv_scale_section
********************************************************************/
#include "be_fixed_be_class_lv_scale_section.h"
/* @const_object_info_begin
class be_class_lv_scale_section (scope: global, name: lv_scale_section, super: be_class_lv_obj, strings: weak) {
init, func(be_ntv_lv_scale_section_init)
}
@const_object_info_end */
/********************************************************************
** Solidified class: lv_slider
********************************************************************/

View File

@ -1489,4 +1489,6 @@ 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)
lv_area_t * lv_bar_get_indic_area(lv_obj_t * bar)
lv_point_t * lv_line_get_points(lv_obj_t * line)
int lv_line_get_points_num(lv_obj_t * line)

View File

@ -82,14 +82,27 @@ int lv_be_style_init(bvm *vm) {
if (style == NULL) {
be_throw(vm, BE_MALLOC_FAIL);
}
if (style != NULL) {
lv_style_init(style);
}
}
be_pushcomptr(vm, style);
be_setmember(vm, 1, "_p");
be_return_nil(vm);
}
/*********************************************************************************************\
* Delete style
*
* Use with caution, it shouldn't be referenced after this call
\*********************************************************************************************/
int lv_be_style_del(bvm *vm) {
be_getmember(vm, 1, "_p");
lv_style_t * style = be_tocomptr(vm, -1);
if (style != NULL) {
be_free(vm, style, sizeof(lv_style_t));
}
be_pushcomptr(vm, NULL);
be_setmember(vm, 1, "_p");
be_return_nil(vm);
}
/*********************************************************************************************\
* Support for lv_anim `init()`
@ -384,3 +397,10 @@ lv_style_t * lv_span_get_style(lv_span_t * span) {
lv_area_t * lv_bar_get_indic_area(lv_obj_t * bar) {
return &((lv_bar_t*)bar)->indic_area;
}
// add accessor for lv_line points array
lv_point_t * lv_line_get_points(lv_obj_t * line) {
return &((lv_line_t*)line)->point_array[0];
}
int lv_line_get_points_num(lv_obj_t * line) {
return ((lv_line_t*)line)->point_num;
}

View File

@ -31,6 +31,10 @@ extern lv_style_t * lv_span_get_style(lv_span_t * span);
// add accessor for lv_bar->indic_area
extern lv_area_t * lv_bar_get_indic_area(lv_obj_t * bar);
// add accessor for lv_line points array
extern lv_point_t * lv_line_get_points(lv_obj_t * line);
extern int lv_line_get_points_num(lv_obj_t * line);
#ifdef __cplusplus
}
#endif

View File

@ -35,9 +35,10 @@ lv_widgets = ['obj',
'dropdown', 'image', 'label', 'line', 'roller', 'slider',
'switch', 'table', 'textarea',
# added in LVGL 9
'spangroup', 'span', 'scale',
'spangroup', 'span',
'scale_section', 'scale', # 'scale_section' needs to be before 'scale' to capture more selective first
]
lv_widgets_no_class = ['span'] # widgets that don't have a lv_obj class
lv_widgets_no_class = ['span', 'scale_section'] # 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']
@ -349,7 +350,6 @@ class type_mapper_class:
"lv_span_mode_t": "i",
"lv_vector_path_t *": "c", # treat as opaque pointer
"lv_vector_dsc_t *": "c", # treat as opaque pointer
"lv_scale_section_t *": "c", # treat as opaque pointer
"lv_point_t *": "c", # treat as opaque pointer
"lv_hit_test_info_t *": "c", # treat as opaque pointer
"lv_screen_load_anim_t": "i",
@ -424,6 +424,7 @@ class type_mapper_class:
"lv_indev_t *": "lv_indev",
"lv_point_t []": "lv_point_arr",
"lv_span_t *": "lv_span",
"lv_scale_section_t *": "lv_scale_section", # treat as opaque pointer
# "lv_image_header_t *": "lv_image_header",
"lv_image_dsc_t *": "lv_image_dsc",
"lv_ts_calibration_t *": "lv_ts_calibration",
@ -890,6 +891,7 @@ extern int lv_x_member(bvm *vm);
extern int lv_x_tostring(bvm *vm); // generic function
extern int lv_be_style_init(bvm *vm);
extern int lv_be_style_del(bvm *vm);
extern int lv_be_anim_init(bvm *vm);
extern int lv_x_tostring(bvm *vm);
@ -922,6 +924,7 @@ print("""
class be_class_lv_style (scope: global, name: lv_style, strings: weak) {
_p, var
init, func(lv_be_style_init)
del, func(lv_be_style_del)
tostring, func(lv_x_tostring)
member, func(lv_x_member)
}

View File

@ -1241,6 +1241,7 @@ https://rya.nc/tasmota-fingerprint.html"
#define BE_LV_WIDGET_MSGBOX
#define BE_LV_WIDGET_QRCODE
#define BE_LV_WIDGET_SCALE
#define BE_LV_WIDGET_SCALE_SECTION
// #define BE_LV_WIDGET_SPINBOX
#define BE_LV_WIDGET_SPINNER
#define BE_LV_WIDGET_SPANGROUP