Merge pull request #14890 from s-hadinger/lvgl_math

lvgl add math functions
This commit is contained in:
s-hadinger 2022-02-17 13:37:46 +01:00 committed by GitHub
commit 36b4f2ca22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1102 additions and 1068 deletions

View File

@ -367,7 +367,6 @@ extern const bcstring be_const_str_draw_ctx;
extern const bcstring be_const_str_draw_line;
extern const bcstring be_const_str_draw_line_dsc;
extern const bcstring be_const_str_draw_line_dsc_init;
extern const bcstring be_const_str_due;
extern const bcstring be_const_str_dump;
extern const bcstring be_const_str_duration;
extern const bcstring be_const_str_editable;

File diff suppressed because it is too large Load Diff

View File

@ -27,6 +27,8 @@ static int lv_get_ver_res(void) {
/* `lv` methods */
const be_ntv_func_def_t lv_func[] = {
{ "atan2", { (const void*) &lv_atan2, "i", "ii" } },
{ "bezier3", { (const void*) &lv_bezier3, "i", "iiiii" } },
{ "clamp_height", { (const void*) &lv_clamp_height, "i", "iiii" } },
{ "clamp_width", { (const void*) &lv_clamp_width, "i", "iiii" } },
{ "color_black", { (const void*) &lv_color_black, "lv.lv_color", "" } },
@ -106,6 +108,7 @@ const be_ntv_func_def_t lv_func[] = {
{ "layer_sys", { (const void*) &lv_layer_sys, "lv.lv_obj", "" } },
{ "layer_top", { (const void*) &lv_layer_top, "lv.lv_obj", "" } },
{ "layout_register", { (const void*) &lv_layout_register, "i", "^lv_layout_update_cb^." } },
{ "map", { (const void*) &lv_map, "i", "iiiii" } },
{ "obj_class_create_obj", { (const void*) &lv_obj_class_create_obj, "lv.lv_obj", "(lv._lv_obj_class)(lv.lv_obj)" } },
{ "obj_del_anim_ready_cb", { (const void*) &lv_obj_del_anim_ready_cb, "", "(lv.lv_anim)" } },
{ "obj_draw_dsc_init", { (const void*) &lv_obj_draw_dsc_init, "", "(lv.lv_obj_draw_part_dsc)(lv.lv_draw_ctx)" } },
@ -121,11 +124,13 @@ const be_ntv_func_def_t lv_func[] = {
{ "qrcode_create", { (const void*) &lv_qrcode_create, "lv.lv_obj", "(lv.lv_obj)i(lv.lv_color)(lv.lv_color)" } },
{ "qrcode_delete", { (const void*) &lv_qrcode_delete, "", "(lv.lv_obj)" } },
{ "qrcode_update", { (const void*) &lv_qrcode_update, "i", "(lv.lv_obj).i" } },
{ "rand", { (const void*) &lv_rand, "i", "ii" } },
{ "refr_now", { (const void*) &lv_refr_now, "", "(lv.lv_disp)" } },
{ "refr_obj", { (const void*) &lv_refr_obj, "", "(lv.lv_draw_ctx)(lv.lv_obj)" } },
{ "scr_act", { (const void*) &lv_scr_act, "lv.lv_obj", "" } },
{ "scr_load", { (const void*) &lv_scr_load, "", "(lv.lv_obj)" } },
{ "scr_load_anim", { (const void*) &lv_scr_load_anim, "", "(lv.lv_obj)iiib" } },
{ "sqrt", { (const void*) &lv_sqrt, "", "i(lv.lv_sqrt_res)i" } },
{ "style_prop_get_default", { (const void*) &lv_style_prop_get_default, "i", "i" } },
{ "style_register_prop", { (const void*) &lv_style_register_prop, "i", "" } },
{ "style_transition_dsc_init", { (const void*) &lv_style_transition_dsc_init, "", "(lv.lv_style_transition_dsc)(lv.lv_style_prop)^lv_anim_path_cb^ii." } },
@ -145,6 +150,8 @@ const be_ntv_func_def_t lv_func[] = {
{ "theme_openhasp_is_inited", { (const void*) &lv_theme_openhasp_is_inited, "b", "" } },
{ "theme_set_apply_cb", { (const void*) &lv_theme_set_apply_cb, "", "(lv.lv_theme)^lv_theme_apply_cb^" } },
{ "theme_set_parent", { (const void*) &lv_theme_set_parent, "", "(lv.lv_theme)(lv.lv_theme)" } },
{ "trigo_cos", { (const void*) &lv_trigo_cos, "i", "i" } },
{ "trigo_sin", { (const void*) &lv_trigo_sin, "i", "i" } },
};
const size_t lv_func_size = sizeof(lv_func) / sizeof(lv_func[0]);

View File

@ -736,6 +736,15 @@ static inline lv_color_t lv_color_black(void)
lv_color_t lv_palette_lighten(lv_palette_t p, uint8_t lvl)
lv_color_t lv_palette_darken(lv_palette_t p, uint8_t lvl)
// ../../lvgl/src/misc/lv_math.h
int16_t lv_trigo_sin(int16_t angle)
static inline int16_t lv_trigo_cos(int16_t angle)
uint32_t lv_bezier3(uint32_t t, uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3)
uint16_t lv_atan2(int x, int y)
void lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask)
int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out)
uint32_t lv_rand(uint32_t min, uint32_t max)
// ../../lvgl/src/misc/lv_style.h
void lv_style_init(lv_style_t * style)
void lv_style_reset(lv_style_t * style)

View File

@ -551,6 +551,15 @@ const be_ctypes_structure_t be_lv_event = {
{ "user_data", 12, 0, 0, ctypes_ptr32, 0 },
}};
const be_ctypes_structure_t be_lv_sqrt_res = {
4, /* size in bytes */
2, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[2]) {
{ "f", 2, 0, 0, ctypes_u16, 0 },
{ "i", 0, 0, 0, ctypes_u16, 0 },
}};
const be_ctypes_structure_t be_lv_img_header = {
4, /* size in bytes */
5, /* number of elements */
@ -564,13 +573,12 @@ const be_ctypes_structure_t be_lv_img_header = {
}};
const be_ctypes_structure_t be_lv_img_dsc = {
16, /* size in bytes */
8, /* number of elements */
12, /* size in bytes */
7, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[8]) {
{ "cf", 4, 0, 5, ctypes_bf, 0 },
{ "data", 12, 0, 0, ctypes_ptr32, 0 },
{ "data_size", 8, 0, 0, ctypes_u32, 0 },
(const be_ctypes_structure_item_t[7]) {
{ "data", 8, 0, 0, ctypes_ptr32, 0 },
{ "data_size", 4, 0, 0, ctypes_u32, 0 },
{ "header_always_zero", 0, 5, 3, ctypes_bf, 0 },
{ "header_cf", 0, 0, 5, ctypes_bf, 0 },
{ "header_h", 2, 5, 11, ctypes_bf, 0 },
@ -693,6 +701,7 @@ static be_define_ctypes_class(lv_meter_indicator_scale_lines, &be_lv_meter_indic
static be_define_ctypes_class(lv_meter_scale, &be_lv_meter_scale, &be_class_ctypes, "lv_meter_scale");
static be_define_ctypes_class(lv_obj_class, &be_lv_obj_class, &be_class_ctypes, "lv_obj_class");
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_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");
@ -736,6 +745,7 @@ void be_load_ctypes_lvgl_definitions_lib(bvm *vm) {
ctypes_register_class(vm, &be_class_lv_meter_scale, &be_lv_meter_scale);
ctypes_register_class(vm, &be_class_lv_obj_class, &be_lv_obj_class);
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_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);
@ -780,6 +790,7 @@ be_ctypes_class_by_name_t be_ctypes_lvgl_classes[] = {
{ "lv_meter_scale", &be_class_lv_meter_scale },
{ "lv_obj_class", &be_class_lv_obj_class },
{ "lv_point", &be_class_lv_point },
{ "lv_sqrt_res", &be_class_lv_sqrt_res },
{ "lv_style_transition_dsc", &be_class_lv_style_transition_dsc },
{ "lv_timer", &be_class_lv_timer },
{ "lv_ts_calibration", &be_class_lv_ts_calibration },

View File

@ -455,6 +455,12 @@ lv_event = [ # valid LVGL8.2
]
lv_event = ctypes.structure(lv_event, "lv_event")
lv_sqrt_res = [ # valid LVGL8.2
[uint16_t, "i"],
[uint16_t, "f"],
]
lv_sqrt_res = ctypes.structure(lv_sqrt_res, "lv_sqrt_res")
#######################################################################
# lv_img structures
lv_img_header = [ # valid LVGL8.2

View File

@ -27,6 +27,7 @@ parse_arg = re.compile("(\w+\s+)?(\w+)([\*\s]+)(\w+)(\[\])?")
return_types = {
"void": "",
"bool": "b",
"int": "i",
"uint8_t": "i",
"uint16_t": "i",
"int16_t": "i",
@ -144,6 +145,7 @@ return_types = {
"lv_draw_ctx_t *": "lv_draw_ctx",
"_lv_draw_ctx_t *": "lv_draw_ctx",
"lv_grad_dsc_t *": "lv_grad_dsc",
"lv_sqrt_res_t *": "lv_sqrt_res",
# "lv_color_hsv_t *": "lv_color_hsv",
"lv_color_filter_dsc_t *": "lv_color_filter_dsc",
"lv_timer_t *": "lv_timer",

View File

@ -70,6 +70,7 @@ lv_fun_globs = [
"misc/lv_style_gen.h",
"misc/lv_color.h",
"misc/lv_style.h",
"misc/lv_math.h"
#"misc/lv_area.h",
#"**/*.h",
]
@ -162,6 +163,7 @@ for header_name in headers_names:
"^lv_img_cf_",
"^lv_img_buf_",
"^lv_indev_scroll_",
"^lv_pow",
"^lv_keyboard_def_event_cb", # need to fix conditional include
"^lv_event_get_", # event_getters not needed
"^lv_refr_reset_fps_counter",