LVGL add support for lv_timer and lv_coord_t * return value (#14465)

* LVGL add support for lv_timer and lv_coord_t * return value

* Patch for char **

* fix LV_ATTRIBUTE_TIMER_HANDLER

* Comptr is 'c'
This commit is contained in:
s-hadinger 2022-01-16 15:05:14 +01:00 committed by GitHub
parent 361f74cc12
commit d123f8dbc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 48 additions and 4 deletions

View File

@ -147,7 +147,7 @@ int be_find_global_or_module_member(bvm *vm, const char * name) {
* 'b' be_bool * 'b' be_bool
* 's' be_string * 's' be_string
* 'f' be_real (float) * 'f' be_real (float)
* 'c' C callback * 'c' C comptr (general pointer)
* '-': skip argument and ignore * '-': skip argument and ignore
* '~': send the length of the previous bytes() buffer (or raise an exception if no length known) * '~': send the length of the previous bytes() buffer (or raise an exception if no length known)
* 'lv_obj' be_instance of type or subtype * 'lv_obj' be_instance of type or subtype
@ -455,6 +455,7 @@ int be_call_c_func(bvm *vm, void * func, const char * return_type, const char *
case '.': // fallback next case '.': // fallback next
case 'i': be_pushint(vm, ret); break; case 'i': be_pushint(vm, ret); break;
case 'b': be_pushbool(vm, ret); break; case 'b': be_pushbool(vm, ret); break;
case 'c': be_pushcomptr(vm, (void*) ret); break;
case 's': be_pushstring(vm, (const char*) ret); break; case 's': be_pushstring(vm, (const char*) ret); break;
case '&': be_pushbytes(vm, (void*) ret, return_len); break; case '&': be_pushbytes(vm, (void*) ret, return_len); break;
default: be_raise(vm, "internal_error", "Unsupported return type"); break; default: be_raise(vm, "internal_error", "Unsupported return type"); break;

View File

@ -272,7 +272,9 @@ const be_ntv_func_def_t lv_obj_func[] = {
{ "get_style_grid_cell_x_align", (void*) &lv_obj_get_style_grid_cell_x_align, "i", "(lv.lv_obj)i" }, { "get_style_grid_cell_x_align", (void*) &lv_obj_get_style_grid_cell_x_align, "i", "(lv.lv_obj)i" },
{ "get_style_grid_cell_y_align", (void*) &lv_obj_get_style_grid_cell_y_align, "i", "(lv.lv_obj)i" }, { "get_style_grid_cell_y_align", (void*) &lv_obj_get_style_grid_cell_y_align, "i", "(lv.lv_obj)i" },
{ "get_style_grid_column_align", (void*) &lv_obj_get_style_grid_column_align, "i", "(lv.lv_obj)i" }, { "get_style_grid_column_align", (void*) &lv_obj_get_style_grid_column_align, "i", "(lv.lv_obj)i" },
{ "get_style_grid_column_dsc_array", (void*) &lv_obj_get_style_grid_column_dsc_array, "c", "(lv.lv_obj)i" },
{ "get_style_grid_row_align", (void*) &lv_obj_get_style_grid_row_align, "i", "(lv.lv_obj)i" }, { "get_style_grid_row_align", (void*) &lv_obj_get_style_grid_row_align, "i", "(lv.lv_obj)i" },
{ "get_style_grid_row_dsc_array", (void*) &lv_obj_get_style_grid_row_dsc_array, "c", "(lv.lv_obj)i" },
{ "get_style_height", (void*) &lv_obj_get_style_height, "i", "(lv.lv_obj)i" }, { "get_style_height", (void*) &lv_obj_get_style_height, "i", "(lv.lv_obj)i" },
{ "get_style_img_opa", (void*) &lv_obj_get_style_img_opa, "i", "(lv.lv_obj)i" }, { "get_style_img_opa", (void*) &lv_obj_get_style_img_opa, "i", "(lv.lv_obj)i" },
{ "get_style_img_recolor", (void*) &lv_obj_get_style_img_recolor, "lv.lv_color", "(lv.lv_obj)i" }, { "get_style_img_recolor", (void*) &lv_obj_get_style_img_recolor, "lv.lv_color", "(lv.lv_obj)i" },
@ -573,7 +575,9 @@ const be_ntv_func_def_t lv_chart_func[] = {
{ "get_pressed_point", (void*) &lv_chart_get_pressed_point, "i", "(lv.lv_obj)" }, { "get_pressed_point", (void*) &lv_chart_get_pressed_point, "i", "(lv.lv_obj)" },
{ "get_series_next", (void*) &lv_chart_get_series_next, "lv.lv_chart_series", "(lv.lv_obj)(lv.lv_chart_series)" }, { "get_series_next", (void*) &lv_chart_get_series_next, "lv.lv_chart_series", "(lv.lv_obj)(lv.lv_chart_series)" },
{ "get_type", (void*) &lv_chart_get_type, "i", "(lv.lv_obj)" }, { "get_type", (void*) &lv_chart_get_type, "i", "(lv.lv_obj)" },
{ "get_x_array", (void*) &lv_chart_get_x_array, "c", "(lv.lv_obj)(lv.lv_chart_series)" },
{ "get_x_start_point", (void*) &lv_chart_get_x_start_point, "i", "(lv.lv_obj)(lv.lv_chart_series)" }, { "get_x_start_point", (void*) &lv_chart_get_x_start_point, "i", "(lv.lv_obj)(lv.lv_chart_series)" },
{ "get_y_array", (void*) &lv_chart_get_y_array, "c", "(lv.lv_obj)(lv.lv_chart_series)" },
{ "get_zoom_x", (void*) &lv_chart_get_zoom_x, "i", "(lv.lv_obj)" }, { "get_zoom_x", (void*) &lv_chart_get_zoom_x, "i", "(lv.lv_obj)" },
{ "get_zoom_y", (void*) &lv_chart_get_zoom_y, "i", "(lv.lv_obj)" }, { "get_zoom_y", (void*) &lv_chart_get_zoom_y, "i", "(lv.lv_obj)" },
{ "hide_series", (void*) &lv_chart_hide_series, "", "(lv.lv_obj)(lv.lv_chart_series)b" }, { "hide_series", (void*) &lv_chart_hide_series, "", "(lv.lv_obj)(lv.lv_chart_series)b" },
@ -745,6 +749,7 @@ const be_ntv_func_def_t lv_btnmatrix_func[] = {
{ "clear_btn_ctrl", (void*) &lv_btnmatrix_clear_btn_ctrl, "", "(lv.lv_obj)i(lv.lv_btnmatrix_ctrl)" }, { "clear_btn_ctrl", (void*) &lv_btnmatrix_clear_btn_ctrl, "", "(lv.lv_obj)i(lv.lv_btnmatrix_ctrl)" },
{ "clear_btn_ctrl_all", (void*) &lv_btnmatrix_clear_btn_ctrl_all, "", "(lv.lv_obj)(lv.lv_btnmatrix_ctrl)" }, { "clear_btn_ctrl_all", (void*) &lv_btnmatrix_clear_btn_ctrl_all, "", "(lv.lv_obj)(lv.lv_btnmatrix_ctrl)" },
{ "get_btn_text", (void*) &lv_btnmatrix_get_btn_text, "s", "(lv.lv_obj)i" }, { "get_btn_text", (void*) &lv_btnmatrix_get_btn_text, "s", "(lv.lv_obj)i" },
{ "get_map", (void*) &lv_btnmatrix_get_map, "c", "(lv.lv_obj)" },
{ "get_one_checked", (void*) &lv_btnmatrix_get_one_checked, "b", "(lv.lv_obj)" }, { "get_one_checked", (void*) &lv_btnmatrix_get_one_checked, "b", "(lv.lv_obj)" },
{ "get_selected_btn", (void*) &lv_btnmatrix_get_selected_btn, "i", "(lv.lv_obj)" }, { "get_selected_btn", (void*) &lv_btnmatrix_get_selected_btn, "i", "(lv.lv_obj)" },
{ "has_btn_ctrl", (void*) &lv_btnmatrix_has_btn_ctrl, "b", "(lv.lv_obj)i(lv.lv_btnmatrix_ctrl)" }, { "has_btn_ctrl", (void*) &lv_btnmatrix_has_btn_ctrl, "b", "(lv.lv_obj)i(lv.lv_btnmatrix_ctrl)" },

View File

@ -95,6 +95,7 @@ const be_ntv_func_def_t lv_func[] = {
{ "img_src_get_type", (void*) &lv_img_src_get_type, "i", "." }, { "img_src_get_type", (void*) &lv_img_src_get_type, "i", "." },
{ "indev_get_act", (void*) &lv_indev_get_act, "lv.lv_indev", "" }, { "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_get_obj_act", (void*) &lv_indev_get_obj_act, "lv.lv_obj", "" },
{ "indev_get_read_timer", (void*) &lv_indev_get_read_timer, "lv.lv_timer", "(lv.lv_disp)" },
{ "indev_read_timer_cb", (void*) &lv_indev_read_timer_cb, "", "(lv.lv_timer)" }, { "indev_read_timer_cb", (void*) &lv_indev_read_timer_cb, "", "(lv.lv_timer)" },
{ "is_initialized", (void*) &lv_is_initialized, "b", "" }, { "is_initialized", (void*) &lv_is_initialized, "b", "" },
{ "layer_sys", (void*) &lv_layer_sys, "lv.lv_obj", "" }, { "layer_sys", (void*) &lv_layer_sys, "lv.lv_obj", "" },
@ -116,6 +117,7 @@ const be_ntv_func_def_t lv_func[] = {
{ "scr_act", (void*) &lv_scr_act, "lv.lv_obj", "" }, { "scr_act", (void*) &lv_scr_act, "lv.lv_obj", "" },
{ "scr_load", (void*) &lv_scr_load, "", "(lv.lv_obj)" }, { "scr_load", (void*) &lv_scr_load, "", "(lv.lv_obj)" },
{ "scr_load_anim", (void*) &lv_scr_load_anim, "", "(lv.lv_obj)iiib" }, { "scr_load_anim", (void*) &lv_scr_load_anim, "", "(lv.lv_obj)iiib" },
{ "task_handler", (void*) &lv_task_handler, "i", "" },
{ "theme_apply", (void*) &lv_theme_apply, "", "(lv.lv_obj)" }, { "theme_apply", (void*) &lv_theme_apply, "", "(lv.lv_obj)" },
{ "theme_default_get", (void*) &lv_theme_default_get, "lv.lv_theme", "" }, { "theme_default_get", (void*) &lv_theme_default_get, "lv.lv_theme", "" },
{ "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_init", (void*) &lv_theme_default_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" },

View File

@ -511,6 +511,8 @@ extern int lvbe_obj_set_style_grid_cell_row_pos(bvm *vm);
extern int lvbe_obj_set_style_grid_cell_row_span(bvm *vm); extern int lvbe_obj_set_style_grid_cell_row_span(bvm *vm);
extern int lvbe_obj_set_style_grid_cell_x_align(bvm *vm); extern int lvbe_obj_set_style_grid_cell_x_align(bvm *vm);
extern int lvbe_obj_set_style_grid_cell_y_align(bvm *vm); extern int lvbe_obj_set_style_grid_cell_y_align(bvm *vm);
extern int lvbe_obj_get_style_grid_row_dsc_array(bvm *vm);
extern int lvbe_obj_get_style_grid_column_dsc_array(bvm *vm);
extern int lvbe_obj_get_style_grid_row_align(bvm *vm); extern int lvbe_obj_get_style_grid_row_align(bvm *vm);
extern int lvbe_obj_get_style_grid_column_align(bvm *vm); extern int lvbe_obj_get_style_grid_column_align(bvm *vm);
extern int lvbe_obj_get_style_grid_cell_column_pos(bvm *vm); extern int lvbe_obj_get_style_grid_cell_column_pos(bvm *vm);
@ -597,6 +599,8 @@ extern int lvbe_chart_set_value_by_id(bvm *vm);
extern int lvbe_chart_set_value_by_id2(bvm *vm); extern int lvbe_chart_set_value_by_id2(bvm *vm);
extern int lvbe_chart_set_ext_y_array(bvm *vm); extern int lvbe_chart_set_ext_y_array(bvm *vm);
extern int lvbe_chart_set_ext_x_array(bvm *vm); extern int lvbe_chart_set_ext_x_array(bvm *vm);
extern int lvbe_chart_get_y_array(bvm *vm);
extern int lvbe_chart_get_x_array(bvm *vm);
extern int lvbe_chart_get_pressed_point(bvm *vm); extern int lvbe_chart_get_pressed_point(bvm *vm);
/* `lv_colorwheel` external functions definitions */ /* `lv_colorwheel` external functions definitions */
@ -718,6 +722,7 @@ extern int lvbe_btnmatrix_set_btn_ctrl_all(bvm *vm);
extern int lvbe_btnmatrix_clear_btn_ctrl_all(bvm *vm); extern int lvbe_btnmatrix_clear_btn_ctrl_all(bvm *vm);
extern int lvbe_btnmatrix_set_btn_width(bvm *vm); extern int lvbe_btnmatrix_set_btn_width(bvm *vm);
extern int lvbe_btnmatrix_set_one_checked(bvm *vm); extern int lvbe_btnmatrix_set_one_checked(bvm *vm);
extern int lvbe_btnmatrix_get_map(bvm *vm);
extern int lvbe_btnmatrix_get_selected_btn(bvm *vm); extern int lvbe_btnmatrix_get_selected_btn(bvm *vm);
extern int lvbe_btnmatrix_get_btn_text(bvm *vm); extern int lvbe_btnmatrix_get_btn_text(bvm *vm);
extern int lvbe_btnmatrix_has_btn_ctrl(bvm *vm); extern int lvbe_btnmatrix_has_btn_ctrl(bvm *vm);

View File

@ -688,7 +688,7 @@ void lv_spinbox_decrement(lv_obj_t * obj)
lv_obj_t * lv_spinner_create(lv_obj_t * parent, uint32_t time, uint32_t arc_length) lv_obj_t * lv_spinner_create(lv_obj_t * parent, uint32_t time, uint32_t arc_length)
// ../../lvgl/src/lv_api_map.h // ../../lvgl/src/lv_api_map.h
static inline LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_task_handler(void) static inline uint32_t lv_task_handler(void)
static inline void lv_obj_move_foreground(lv_obj_t * obj) static inline void lv_obj_move_foreground(lv_obj_t * obj)
static inline void lv_obj_move_background(lv_obj_t * obj) static inline void lv_obj_move_background(lv_obj_t * obj)
static inline uint32_t lv_obj_get_child_id(const struct _lv_obj_t * obj) static inline uint32_t lv_obj_get_child_id(const struct _lv_obj_t * obj)

View File

@ -511,6 +511,19 @@ const be_ctypes_structure_t be_lv_color_filter_dsc = {
{ "user_data", 4, 0, 0, ctypes_ptr32, 0 }, { "user_data", 4, 0, 0, ctypes_ptr32, 0 },
}}; }};
const be_ctypes_structure_t be_lv_timer = {
21, /* size in bytes */
6, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[6]) {
{ "last_run", 4, 0, 0, ctypes_u32, 0 },
{ "paused", 20, 0, 1, ctypes_bf, 0 },
{ "period", 0, 0, 0, ctypes_u32, 0 },
{ "repeat_count", 16, 0, 0, ctypes_i32, 0 },
{ "timer_cb", 8, 0, 0, ctypes_ptr32, 0 },
{ "user_data", 12, 0, 0, ctypes_ptr32, 0 },
}};
const be_ctypes_structure_t be_lv_ts_calibration = { const be_ctypes_structure_t be_lv_ts_calibration = {
12, /* size in bytes */ 12, /* size in bytes */
5, /* number of elements */ 5, /* number of elements */
@ -560,6 +573,7 @@ static be_define_ctypes_class(lv_obj_class, &be_lv_obj_class, &be_class_ctypes,
static be_define_ctypes_class(lv_point, &be_lv_point, &be_class_ctypes, "lv_point"); static be_define_ctypes_class(lv_point, &be_lv_point, &be_class_ctypes, "lv_point");
static be_define_ctypes_class(lv_sqrt_res, &be_lv_sqrt_res, &be_class_ctypes, "lv_sqrt_res"); static be_define_ctypes_class(lv_sqrt_res, &be_lv_sqrt_res, &be_class_ctypes, "lv_sqrt_res");
static be_define_ctypes_class(lv_style_transition_dsc, &be_lv_style_transition_dsc, &be_class_ctypes, "lv_style_transition_dsc"); static be_define_ctypes_class(lv_style_transition_dsc, &be_lv_style_transition_dsc, &be_class_ctypes, "lv_style_transition_dsc");
static be_define_ctypes_class(lv_timer, &be_lv_timer, &be_class_ctypes, "lv_timer");
static be_define_ctypes_class(lv_ts_calibration, &be_lv_ts_calibration, &be_class_ctypes, "lv_ts_calibration"); static be_define_ctypes_class(lv_ts_calibration, &be_lv_ts_calibration, &be_class_ctypes, "lv_ts_calibration");
void be_load_ctypes_lvgl_definitions_lib(bvm *vm) { void be_load_ctypes_lvgl_definitions_lib(bvm *vm) {
@ -595,6 +609,7 @@ void be_load_ctypes_lvgl_definitions_lib(bvm *vm) {
ctypes_register_class(vm, &be_class_lv_point, &be_lv_point); ctypes_register_class(vm, &be_class_lv_point, &be_lv_point);
ctypes_register_class(vm, &be_class_lv_sqrt_res, &be_lv_sqrt_res); ctypes_register_class(vm, &be_class_lv_sqrt_res, &be_lv_sqrt_res);
ctypes_register_class(vm, &be_class_lv_style_transition_dsc, &be_lv_style_transition_dsc); ctypes_register_class(vm, &be_class_lv_style_transition_dsc, &be_lv_style_transition_dsc);
ctypes_register_class(vm, &be_class_lv_timer, &be_lv_timer);
ctypes_register_class(vm, &be_class_lv_ts_calibration, &be_lv_ts_calibration); ctypes_register_class(vm, &be_class_lv_ts_calibration, &be_lv_ts_calibration);
} }
@ -631,6 +646,7 @@ be_ctypes_class_by_name_t be_ctypes_lvgl_classes[] = {
{ "lv_point", &be_class_lv_point }, { "lv_point", &be_class_lv_point },
{ "lv_sqrt_res", &be_class_lv_sqrt_res }, { "lv_sqrt_res", &be_class_lv_sqrt_res },
{ "lv_style_transition_dsc", &be_class_lv_style_transition_dsc }, { "lv_style_transition_dsc", &be_class_lv_style_transition_dsc },
{ "lv_timer", &be_class_lv_timer },
{ "lv_ts_calibration", &be_class_lv_ts_calibration }, { "lv_ts_calibration", &be_class_lv_ts_calibration },
}; };
const size_t be_ctypes_lvgl_classes_size = sizeof(be_ctypes_lvgl_classes)/sizeof(be_ctypes_lvgl_classes[0]); const size_t be_ctypes_lvgl_classes_size = sizeof(be_ctypes_lvgl_classes)/sizeof(be_ctypes_lvgl_classes[0]);

View File

@ -439,6 +439,18 @@ lv_color_filter_dsc = [ # valid LVGL8
] ]
lv_color_filter_dsc = ctypes.structure(lv_color_filter_dsc, "lv_color_filter_dsc") lv_color_filter_dsc = ctypes.structure(lv_color_filter_dsc, "lv_color_filter_dsc")
#######################################################################
# lv_timer
lv_timer = [ # valid LVGL8
[uint32_t, "period"],
[uint32_t, "last_run"],
[ptr, "timer_cb"],
[ptr, "user_data"],
[int32_t, "repeat_count"],
[uint8_t_1, "paused"],
]
lv_timer = ctypes.structure(lv_timer, "lv_timer")
####################################################################### #######################################################################
# Special structure used to calibrate resistive touchscreens # Special structure used to calibrate resistive touchscreens
####################################################################### #######################################################################

View File

@ -141,8 +141,9 @@ return_types = {
"lv_style_transition_dsc_t *": "lv_style_transition_dsc", "lv_style_transition_dsc_t *": "lv_style_transition_dsc",
# "lv_color_hsv_t *": "lv_color_hsv", # "lv_color_hsv_t *": "lv_color_hsv",
"lv_color_filter_dsc_t *": "lv_color_filter_dsc", "lv_color_filter_dsc_t *": "lv_color_filter_dsc",
#"lv_disp_t*": "lv_disp", "lv_timer_t *": "lv_timer",
#"lv_style_list_t*": "", "lv_coord_t *": "c", # treat as a simple pointer, decoding needs to be done at Berry level
"char **": "c", # treat as a simple pointer, decoding needs to be done at Berry level
# callbacks # callbacks
"lv_group_focus_cb_t": "lv_group_focus_cb", "lv_group_focus_cb_t": "lv_group_focus_cb",

View File

@ -133,6 +133,8 @@ for header_name in headers_names:
for fun in fun_defs: for fun in fun_defs:
# remove LV_ATTRIBUTE_FAST_MEM # remove LV_ATTRIBUTE_FAST_MEM
fun = re.sub('LV_ATTRIBUTE_FAST_MEM ', '', fun) fun = re.sub('LV_ATTRIBUTE_FAST_MEM ', '', fun)
# remove LV_ATTRIBUTE_TIMER_HANDLER
fun = re.sub('LV_ATTRIBUTE_TIMER_HANDLER ', '', fun)
exclude = False exclude = False
for exclude_prefix in ["typedef", "_LV_", "LV_"]: for exclude_prefix in ["typedef", "_LV_", "LV_"]:
if fun.startswith(exclude_prefix): exclude = True if fun.startswith(exclude_prefix): exclude = True