Merge pull request #15098 from s-hadinger/lv_optim

LVGL optimizations
This commit is contained in:
s-hadinger 2022-03-10 21:09:52 +01:00 committed by GitHub
commit 76345c3234
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 585 additions and 505 deletions

View File

@ -615,7 +615,7 @@ const be_ntv_func_def_t lv_chart_func[] = {
{ "set_range", { (const void*) &lv_chart_set_range, "", "(lv.lv_obj)iii" } },
{ "set_series_color", { (const void*) &lv_chart_set_series_color, "", "(lv.lv_obj)(lv.lv_chart_series)(lv.lv_color)" } },
{ "set_type", { (const void*) &lv_chart_set_type, "", "(lv.lv_obj)i" } },
{ "set_update_mode", { (const void*) &lv_chart_set_update_mode, "", "(lv.lv_obj)(lv.lv_chart_update_mode)" } },
{ "set_update_mode", { (const void*) &lv_chart_set_update_mode, "", "(lv.lv_obj)i" } },
{ "set_value_by_id", { (const void*) &lv_chart_set_value_by_id, "", "(lv.lv_obj)(lv.lv_chart_series)ii" } },
{ "set_value_by_id2", { (const void*) &lv_chart_set_value_by_id2, "", "(lv.lv_obj)(lv.lv_chart_series)iii" } },
{ "set_x_start_point", { (const void*) &lv_chart_set_x_start_point, "", "(lv.lv_obj)(lv.lv_chart_series)i" } },

View File

@ -33,7 +33,7 @@ const be_ctypes_structure_t be_lv_area = {
}};
const be_ctypes_structure_t be_lv_gradient_stop = {
3, /* size in bytes */
4, /* size in bytes */
2, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[2]) {
@ -42,7 +42,7 @@ const be_ctypes_structure_t be_lv_gradient_stop = {
}};
const be_ctypes_structure_t be_lv_grad_dsc = {
9, /* size in bytes */
12, /* size in bytes */
7, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[7]) {
@ -56,7 +56,7 @@ const be_ctypes_structure_t be_lv_grad_dsc = {
}};
const be_ctypes_structure_t be_lv_draw_rect_dsc = {
59, /* size in bytes */
60, /* size in bytes */
32, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[32]) {
@ -95,7 +95,7 @@ const be_ctypes_structure_t be_lv_draw_rect_dsc = {
}};
const be_ctypes_structure_t be_lv_draw_line_dsc = {
10, /* size in bytes */
12, /* size in bytes */
9, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[9]) {
@ -111,7 +111,7 @@ const be_ctypes_structure_t be_lv_draw_line_dsc = {
}};
const be_ctypes_structure_t be_lv_draw_arc_dsc = {
14, /* size in bytes */
16, /* size in bytes */
8, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[8]) {
@ -126,7 +126,7 @@ const be_ctypes_structure_t be_lv_draw_arc_dsc = {
}};
const be_ctypes_structure_t be_lv_draw_img_dsc = {
21, /* size in bytes */
24, /* size in bytes */
10, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[10]) {
@ -142,8 +142,33 @@ const be_ctypes_structure_t be_lv_draw_img_dsc = {
{ "zoom", 2, 0, 0, ctypes_u16, 0 },
}};
const be_ctypes_structure_t be_lv_obj_draw_part_dsc = {
72, /* size in bytes */
18, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[18]) {
{ "arc_dsc", 32, 0, 0, ctypes_ptr32, 0 },
{ "class_p", 4, 0, 0, ctypes_ptr32, 0 },
{ "draw_area", 12, 0, 0, ctypes_ptr32, 0 },
{ "draw_ctx", 0, 0, 0, ctypes_ptr32, 0 },
{ "id", 56, 0, 0, ctypes_u32, 0 },
{ "img_dsc", 28, 0, 0, ctypes_ptr32, 0 },
{ "label_dsc", 20, 0, 0, ctypes_ptr32, 0 },
{ "line_dsc", 24, 0, 0, ctypes_ptr32, 0 },
{ "p1", 36, 0, 0, ctypes_ptr32, 0 },
{ "p2", 40, 0, 0, ctypes_ptr32, 0 },
{ "part", 52, 0, 0, ctypes_u32, 0 },
{ "radius", 60, 0, 0, ctypes_i16, 0 },
{ "rect_dsc", 16, 0, 0, ctypes_ptr32, 0 },
{ "sub_part_ptr", 68, 0, 0, ctypes_ptr32, 0 },
{ "text", 44, 0, 0, ctypes_ptr32, 0 },
{ "text_length", 48, 0, 0, ctypes_u32, 0 },
{ "type", 8, 0, 0, ctypes_u32, 0 },
{ "value", 64, 0, 0, ctypes_i32, 0 },
}};
const be_ctypes_structure_t be_lv_draw_mask_common_dsc = {
5, /* size in bytes */
8, /* size in bytes */
2, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[2]) {
@ -152,7 +177,7 @@ const be_ctypes_structure_t be_lv_draw_mask_common_dsc = {
}};
const be_ctypes_structure_t be_lv_draw_mask_line_param_cfg = {
9, /* size in bytes */
12, /* size in bytes */
5, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[5]) {
@ -164,7 +189,7 @@ const be_ctypes_structure_t be_lv_draw_mask_line_param_cfg = {
}};
const be_ctypes_structure_t be_lv_draw_mask_line_param = {
41, /* size in bytes */
44, /* size in bytes */
15, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[15]) {
@ -241,7 +266,7 @@ const be_ctypes_structure_t be_lv_draw_mask_angle_param = {
}};
const be_ctypes_structure_t be_lv_draw_mask_radius_param_cfg = {
11, /* size in bytes */
12, /* size in bytes */
6, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[6]) {
@ -254,7 +279,7 @@ const be_ctypes_structure_t be_lv_draw_mask_radius_param_cfg = {
}};
const be_ctypes_structure_t be_lv_draw_mask_radius_circle_dsc = {
26, /* size in bytes */
28, /* size in bytes */
7, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[7]) {
@ -268,7 +293,7 @@ const be_ctypes_structure_t be_lv_draw_mask_radius_circle_dsc = {
}};
const be_ctypes_structure_t be_lv_draw_mask_radius_param = {
46, /* size in bytes */
48, /* size in bytes */
15, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[15]) {
@ -290,7 +315,7 @@ const be_ctypes_structure_t be_lv_draw_mask_radius_param = {
}};
const be_ctypes_structure_t be_lv_draw_mask_fade_param_cfg = {
14, /* size in bytes */
16, /* size in bytes */
8, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[8]) {
@ -305,7 +330,7 @@ const be_ctypes_structure_t be_lv_draw_mask_fade_param_cfg = {
}};
const be_ctypes_structure_t be_lv_draw_mask_fade_param = {
22, /* size in bytes */
24, /* size in bytes */
10, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[10]) {
@ -348,7 +373,7 @@ const be_ctypes_structure_t be_lv_draw_mask_map_param = {
}};
const be_ctypes_structure_t be_lv_draw_mask_polygon_param_cfg = {
6, /* size in bytes */
8, /* size in bytes */
2, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[2]) {
@ -357,7 +382,7 @@ const be_ctypes_structure_t be_lv_draw_mask_polygon_param_cfg = {
}};
const be_ctypes_structure_t be_lv_draw_mask_polygon_param = {
14, /* size in bytes */
16, /* size in bytes */
4, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[4]) {
@ -377,7 +402,7 @@ const be_ctypes_structure_t be_lv_draw_mask_saved = {
}};
const be_ctypes_structure_t be_lv_meter_scale = {
34, /* size in bytes */
36, /* size in bytes */
15, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[15]) {
@ -429,7 +454,7 @@ const be_ctypes_structure_t be_lv_meter_indicator_needle_img = {
}};
const be_ctypes_structure_t be_lv_meter_indicator_needle_line = {
22, /* size in bytes */
24, /* size in bytes */
8, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[8]) {
@ -460,7 +485,7 @@ const be_ctypes_structure_t be_lv_meter_indicator_arc = {
}};
const be_ctypes_structure_t be_lv_meter_indicator_scale_lines = {
23, /* size in bytes */
24, /* size in bytes */
9, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[9]) {
@ -476,7 +501,7 @@ const be_ctypes_structure_t be_lv_meter_indicator_scale_lines = {
}};
const be_ctypes_structure_t be_lv_chart_series = {
13, /* size in bytes */
16, /* size in bytes */
9, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[9]) {
@ -492,7 +517,7 @@ const be_ctypes_structure_t be_lv_chart_series = {
}};
const be_ctypes_structure_t be_lv_chart_cursor = {
14, /* size in bytes */
16, /* size in bytes */
7, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[7]) {
@ -506,7 +531,7 @@ const be_ctypes_structure_t be_lv_chart_cursor = {
}};
const be_ctypes_structure_t be_lv_chart_tick_dsc = {
10, /* size in bytes */
12, /* size in bytes */
6, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[6]) {
@ -519,7 +544,7 @@ const be_ctypes_structure_t be_lv_chart_tick_dsc = {
}};
const be_ctypes_structure_t be_lv_obj_class = {
27, /* size in bytes */
28, /* size in bytes */
10, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[10]) {
@ -536,7 +561,7 @@ const be_ctypes_structure_t be_lv_obj_class = {
}};
const be_ctypes_structure_t be_lv_event = {
25, /* size in bytes */
28, /* size in bytes */
9, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[9]) {
@ -608,7 +633,7 @@ const be_ctypes_structure_t be_lv_color_filter_dsc = {
}};
const be_ctypes_structure_t be_lv_timer = {
21, /* size in bytes */
24, /* size in bytes */
6, /* number of elements */
be_ctypes_instance_mappings,
(const be_ctypes_structure_item_t[6]) {
@ -700,6 +725,7 @@ static be_define_ctypes_class(lv_meter_indicator_needle_line, &be_lv_meter_indic
static be_define_ctypes_class(lv_meter_indicator_scale_lines, &be_lv_meter_indicator_scale_lines, &be_class_ctypes, "lv_meter_indicator_scale_lines");
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_obj_draw_part_dsc, &be_lv_obj_draw_part_dsc, &be_class_ctypes, "lv_obj_draw_part_dsc");
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");
@ -744,6 +770,7 @@ void be_load_ctypes_lvgl_definitions_lib(bvm *vm) {
ctypes_register_class(vm, &be_class_lv_meter_indicator_scale_lines, &be_lv_meter_indicator_scale_lines);
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_obj_draw_part_dsc, &be_lv_obj_draw_part_dsc);
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);
@ -789,6 +816,7 @@ be_ctypes_class_by_name_t be_ctypes_lvgl_classes[] = {
{ "lv_meter_indicator_scale_lines", &be_class_lv_meter_indicator_scale_lines },
{ "lv_meter_scale", &be_class_lv_meter_scale },
{ "lv_obj_class", &be_class_lv_obj_class },
{ "lv_obj_draw_part_dsc", &be_class_lv_obj_draw_part_dsc },
{ "lv_point", &be_class_lv_point },
{ "lv_sqrt_res", &be_class_lv_sqrt_res },
{ "lv_style_transition_dsc", &be_class_lv_style_transition_dsc },

File diff suppressed because it is too large Load Diff

View File

@ -289,8 +289,14 @@ class structure
self.size_bytes = self.cur_offset
if name != nil
var size_aligned = self.size_bytes
# as a final structure, we align to 2/4 bytes boundaries
if size_aligned >= 3
size_aligned = ((size_aligned + 3)/4)*4
end
print(string.format("const be_ctypes_structure_t be_%s = {", name))
print(string.format(" %i, /* size in bytes */", self.size_bytes))
print(string.format(" %i, /* size in bytes */", size_aligned))
print(string.format(" %i, /* number of elements */", size(self.mapping)))
print(string.format(" be_ctypes_instance_mappings,"))
print(string.format(" (const be_ctypes_structure_item_t[%i]) {", size(self.mapping)))

View File

@ -152,6 +152,28 @@ lv_draw_img_dsc = [ # valid LVGL8.2
]
lv_draw_img_dsc = ctypes.structure(lv_draw_img_dsc, "lv_draw_img_dsc")
lv_obj_draw_part_dsc = [ # valid LVGL8.2
[ptr, "draw_ctx"],
[ptr, "class_p"],
[uint32_t, "type"],
[ptr, "draw_area"],
[ptr, "rect_dsc"],
[ptr, "label_dsc"],
[ptr, "line_dsc"],
[ptr, "img_dsc"],
[ptr, "arc_dsc"],
[ptr, "p1"],
[ptr, "p2"],
[ptr, "text"],
[uint32_t, "text_length"],
[uint32_t, "part"],
[uint32_t, "id"],
[lv_coord, "radius"],
[int32_t, "value"],
[ptr, "sub_part_ptr"],
]
lv_obj_draw_part_dsc = ctypes.structure(lv_obj_draw_part_dsc, "lv_obj_draw_part_dsc")
#- --------- lv_mask --------- -#
lv_draw_mask_xcb = ptr # callback
lv_draw_mask_type = ctypes.u8
@ -548,7 +570,7 @@ lv_timer = ctypes.structure(lv_timer, "lv_timer")
# lv_anim = ctypes.structure(lv_anim, "lv_anim")
#######################################################################
# lv_draw_ctc
# lv_draw_ctx
lv_draw_ctx = [ # valid LVGL8.2
[ptr, "buf"],
[lv_area, "buf_area"],

View File

@ -8,6 +8,7 @@ class LVGL_glob
var cb_event_closure # mapping for event closures per LVGL native pointer (int)
var event_cb # native callback for lv.lv_event
var timer_cb # native callback for lv.lv_timer
var event # keep aroud the current lv_event to avoid repeated allocation
#- below are native callbacks mapped to a closure to a method of this instance -#
var null_cb # cb called if type is not supported
@ -41,16 +42,19 @@ class LVGL_glob
end
end
def lvgl_event_dispatch(event_ptr)
def lvgl_event_dispatch(event_ptr_i)
import introspect
var event_ptr = introspect.toptr(event_ptr_i)
var event = lv.lv_event(introspect.toptr(event_ptr))
if self.event self.event._change_buffer(event_ptr)
else self.event = lv.lv_event(event_ptr)
end
var target = event.target
var target = self.event.target
var f = self.cb_event_closure[target]
var obj = self.get_object_from_ptr(target)
#print('>> lvgl_event_dispatch', f, obj, event)
f(obj, event)
f(obj, self.event)
end
def lvgl_timer_dispatch(timer_int)

View File

@ -104,6 +104,7 @@ return_types = {
"lv_palette_t": "i",
"lv_style_prop_t": "i",
"lv_dither_mode_t": "i",
"lv_chart_update_mode_t": "i",
# layouts
"lv_flex_align_t": "i",
"lv_flex_flow_t": "i",

View File

@ -289,8 +289,14 @@ class structure
self.size_bytes = self.cur_offset
if name != nil
var size_aligned = self.size_bytes
# as a final structure, we align to 2/4 bytesboundaries
if size_aligned >= 3
size_aligned = ((size_aligned + 3)/4)*4
end
print(string.format("const be_ctypes_structure_t be_%s = {", name))
print(string.format(" %i, /* size in bytes */", self.size_bytes))
print(string.format(" %i, /* size in bytes */", size_aligned))
print(string.format(" %i, /* number of elements */", size(self.mapping)))
print(string.format(" be_ctypes_instance_mappings,"))
print(string.format(" (const be_ctypes_structure_item_t[%i]) {", size(self.mapping)))