LVGL add support for lv_anim

This commit is contained in:
Stephan Hadinger 2022-03-08 22:22:57 +01:00
parent a927ddfd9f
commit 575beba882
15 changed files with 1500 additions and 1159 deletions

View File

@ -572,6 +572,7 @@ extern const bcstring be_const_str_lv_point_arr;
extern const bcstring be_const_str_lv_signal_arcs; extern const bcstring be_const_str_lv_signal_arcs;
extern const bcstring be_const_str_lv_signal_bars; extern const bcstring be_const_str_lv_signal_bars;
extern const bcstring be_const_str_lv_solidified; extern const bcstring be_const_str_lv_solidified;
extern const bcstring be_const_str_lv_style_prop_arr;
extern const bcstring be_const_str_lv_timer_cb; extern const bcstring be_const_str_lv_timer_cb;
extern const bcstring be_const_str_lv_wifi_arcs; extern const bcstring be_const_str_lv_wifi_arcs;
extern const bcstring be_const_str_lv_wifi_arcs_icon; extern const bcstring be_const_str_lv_wifi_arcs_icon;
@ -807,6 +808,7 @@ extern const bcstring be_const_str_strftime;
extern const bcstring be_const_str_string; extern const bcstring be_const_str_string;
extern const bcstring be_const_str_strip; extern const bcstring be_const_str_strip;
extern const bcstring be_const_str_strptime; extern const bcstring be_const_str_strptime;
extern const bcstring be_const_str_style_prop_arr;
extern const bcstring be_const_str_subscribe; extern const bcstring be_const_str_subscribe;
extern const bcstring be_const_str_success; extern const bcstring be_const_str_success;
extern const bcstring be_const_str_super; extern const bcstring be_const_str_super;

File diff suppressed because it is too large Load Diff

View File

@ -34,6 +34,7 @@
* - `COLOR_WHITE` int value * - `COLOR_WHITE` int value
* - `$SYMBOL_OK"` string pointer * - `$SYMBOL_OK"` string pointer
* - `&seg7_font` comptr * - `&seg7_font` comptr
* - `@func` Berry native function
* - `*my_func` native function - the function is called and return value passed back. * - `*my_func` native function - the function is called and return value passed back.
* This allows to create dynamic virtual members that are the result of a call. * This allows to create dynamic virtual members that are the result of a call.
* *
@ -55,9 +56,12 @@ static bbool be_const_member_dual(bvm *vm, const be_const_member_t * definitions
case '$': // string case '$': // string
be_pushstring(vm, (const char*) definitions[idx].value); be_pushstring(vm, (const char*) definitions[idx].value);
break; break;
case '&': // native function case '@': // native function
be_pushntvfunction(vm, (bntvfunc) definitions[idx].value); be_pushntvfunction(vm, (bntvfunc) definitions[idx].value);
break; break;
case '&': // pointer
be_pushcomptr(vm, (void*) definitions[idx].value);
break;
case '*': // call to a native function case '*': // call to a native function
{ {
bntvfunc f = (bntvfunc) definitions[idx].value; bntvfunc f = (bntvfunc) definitions[idx].value;

View File

@ -716,6 +716,33 @@ const be_ntv_func_def_t lv_spinner_func[] = {
}; };
#endif // BE_LV_WIDGET_SPINNER #endif // BE_LV_WIDGET_SPINNER
/* `lv_anim` methods */
const be_ntv_func_def_t lv_anim_func[] = {
{ "custom_del", { (const void*) &lv_anim_custom_del, "b", "(lv.lv_anim)c" } },
{ "custom_get", { (const void*) &lv_anim_custom_get, "lv.lv_anim", "(lv.lv_anim)c" } },
{ "get_delay", { (const void*) &lv_anim_get_delay, "i", "(lv.lv_anim)" } },
{ "get_playtime", { (const void*) &lv_anim_get_playtime, "i", "(lv.lv_anim)" } },
{ "get_user_data", { (const void*) &lv_anim_get_user_data, ".", "(lv.lv_anim)" } },
{ "init", { (const void*) &lv_anim_init, "", "(lv.lv_anim)" } },
{ "set_custom_exec_cb", { (const void*) &lv_anim_set_custom_exec_cb, "", "(lv.lv_anim)c" } },
{ "set_delay", { (const void*) &lv_anim_set_delay, "", "(lv.lv_anim)i" } },
{ "set_early_apply", { (const void*) &lv_anim_set_early_apply, "", "(lv.lv_anim)b" } },
{ "set_exec_cb", { (const void*) &lv_anim_set_exec_cb, "", "(lv.lv_anim)c" } },
{ "set_get_value_cb", { (const void*) &lv_anim_set_get_value_cb, "", "(lv.lv_anim)c" } },
{ "set_path_cb", { (const void*) &lv_anim_set_path_cb, "", "(lv.lv_anim)c" } },
{ "set_playback_delay", { (const void*) &lv_anim_set_playback_delay, "", "(lv.lv_anim)i" } },
{ "set_playback_time", { (const void*) &lv_anim_set_playback_time, "", "(lv.lv_anim)i" } },
{ "set_ready_cb", { (const void*) &lv_anim_set_ready_cb, "", "(lv.lv_anim)c" } },
{ "set_repeat_count", { (const void*) &lv_anim_set_repeat_count, "", "(lv.lv_anim)i" } },
{ "set_repeat_delay", { (const void*) &lv_anim_set_repeat_delay, "", "(lv.lv_anim)i" } },
{ "set_start_cb", { (const void*) &lv_anim_set_start_cb, "", "(lv.lv_anim)c" } },
{ "set_time", { (const void*) &lv_anim_set_time, "", "(lv.lv_anim)i" } },
{ "set_user_data", { (const void*) &lv_anim_set_user_data, "", "(lv.lv_anim)." } },
{ "set_values", { (const void*) &lv_anim_set_values, "", "(lv.lv_anim)ii" } },
{ "set_var", { (const void*) &lv_anim_set_var, "", "(lv.lv_anim)." } },
{ "start", { (const void*) &lv_anim_start, "lv.lv_anim", "(lv.lv_anim)" } },
};
/* `lv_timer` methods */ /* `lv_timer` methods */
const be_ntv_func_def_t lv_timer_func[] = { const be_ntv_func_def_t lv_timer_func[] = {
{ "del", { (const void*) &lv_timer_del, "", "(lv.lv_timer)" } }, { "del", { (const void*) &lv_timer_del, "", "(lv.lv_timer)" } },
@ -980,6 +1007,7 @@ const be_ntv_func_def_t lv_textarea_func[] = {
}; };
#endif // BE_LV_WIDGET_TEXTAREA #endif // BE_LV_WIDGET_TEXTAREA
extern const bclass be_class_lv_anim;
extern const bclass be_class_lv_arc; extern const bclass be_class_lv_arc;
extern const bclass be_class_lv_bar; extern const bclass be_class_lv_bar;
extern const bclass be_class_lv_btn; extern const bclass be_class_lv_btn;
@ -1016,6 +1044,7 @@ extern const bclass be_class_lv_timer;
// map of clases // map of clases
const be_ntv_class_def_t lv_classes[] = { const be_ntv_class_def_t lv_classes[] = {
{ "lv_anim", &be_class_lv_anim, lv_anim_func, sizeof(lv_anim_func) / sizeof(lv_anim_func[0]) },
#ifdef BE_LV_WIDGET_ARC #ifdef BE_LV_WIDGET_ARC
{ "lv_arc", &be_class_lv_arc, lv_arc_func, sizeof(lv_arc_func) / sizeof(lv_arc_func[0]) }, { "lv_arc", &be_class_lv_arc, lv_arc_func, sizeof(lv_arc_func) / sizeof(lv_arc_func[0]) },
#endif // BE_LV_WIDGET_ARC #endif // BE_LV_WIDGET_ARC
@ -1143,6 +1172,7 @@ const size_t lv_classes_size = sizeof(lv_classes) / sizeof(lv_classes[0]);
#ifdef BE_LV_WIDGET_SPINNER #ifdef BE_LV_WIDGET_SPINNER
int be_ntv_lv_spinner_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_spinner_create, "+_p", "(lv.lv_obj)ii"); } int be_ntv_lv_spinner_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_spinner_create, "+_p", "(lv.lv_obj)ii"); }
#endif // BE_LV_WIDGET_SPINNER #endif // BE_LV_WIDGET_SPINNER
/* `lv_anim` methods */
/* `lv_timer` methods */ /* `lv_timer` methods */
/* `lv_arc` methods */ /* `lv_arc` methods */
#ifdef BE_LV_WIDGET_ARC #ifdef BE_LV_WIDGET_ARC

View File

@ -27,6 +27,12 @@ static int lv_get_ver_res(void) {
/* `lv` methods */ /* `lv` methods */
const be_ntv_func_def_t lv_func[] = { const be_ntv_func_def_t lv_func[] = {
{ "anim_count_running", { (const void*) &lv_anim_count_running, "i", "" } },
{ "anim_del", { (const void*) &lv_anim_del, "b", ".c" } },
{ "anim_del_all", { (const void*) &lv_anim_del_all, "", "" } },
{ "anim_get", { (const void*) &lv_anim_get, "lv.lv_anim", ".c" } },
{ "anim_refr_now", { (const void*) &lv_anim_refr_now, "", "" } },
{ "anim_speed_to_time", { (const void*) &lv_anim_speed_to_time, "i", "iii" } },
{ "area_align", { (const void*) &lv_area_align, "", "(lv.lv_area)(lv.lv_area)iii" } }, { "area_align", { (const void*) &lv_area_align, "", "(lv.lv_area)(lv.lv_area)iii" } },
{ "area_copy", { (const void*) &lv_area_copy, "", "(lv.lv_area)(lv.lv_area)" } }, { "area_copy", { (const void*) &lv_area_copy, "", "(lv.lv_area)(lv.lv_area)" } },
{ "area_get_height", { (const void*) &lv_area_get_height, "i", "(lv.lv_area)" } }, { "area_get_height", { (const void*) &lv_area_get_height, "i", "(lv.lv_area)" } },
@ -144,7 +150,7 @@ const be_ntv_func_def_t lv_func[] = {
{ "sqrt", { (const void*) &lv_sqrt, "", "i(lv.lv_sqrt_res)i" } }, { "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_prop_get_default", { (const void*) &lv_style_prop_get_default, "i", "i" } },
{ "style_register_prop", { (const void*) &lv_style_register_prop, "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." } }, { "style_transition_dsc_init", { (const void*) &lv_style_transition_dsc_init, "", "(lv.lv_style_transition_dsc)(lv.lv_style_prop)cii." } },
{ "task_handler", { (const void*) &lv_task_handler, "i", "" } }, { "task_handler", { (const void*) &lv_task_handler, "i", "" } },
{ "theme_apply", { (const void*) &lv_theme_apply, "", "(lv.lv_obj)" } }, { "theme_apply", { (const void*) &lv_theme_apply, "", "(lv.lv_obj)" } },
{ "theme_default_get", { (const void*) &lv_theme_default_get, "lv.lv_theme", "" } }, { "theme_default_get", { (const void*) &lv_theme_default_get, "lv.lv_theme", "" } },
@ -799,7 +805,14 @@ const be_const_member_t lv0_constants[] = {
{ "TEXT_FLAG_FIT", be_cconst_int(LV_TEXT_FLAG_FIT) }, { "TEXT_FLAG_FIT", be_cconst_int(LV_TEXT_FLAG_FIT) },
{ "TEXT_FLAG_NONE", be_cconst_int(LV_TEXT_FLAG_NONE) }, { "TEXT_FLAG_NONE", be_cconst_int(LV_TEXT_FLAG_NONE) },
{ "TEXT_FLAG_RECOLOR", be_cconst_int(LV_TEXT_FLAG_RECOLOR) }, { "TEXT_FLAG_RECOLOR", be_cconst_int(LV_TEXT_FLAG_RECOLOR) },
{ "&load_font", be_cconst_ptr(&lv0_load_font) }, { "&anim_path_bounce", be_cconst_ptr(&lv_anim_path_bounce) },
{ "&anim_path_ease_in", be_cconst_ptr(&lv_anim_path_ease_in) },
{ "&anim_path_ease_in_out", be_cconst_ptr(&lv_anim_path_ease_in_out) },
{ "&anim_path_ease_out", be_cconst_ptr(&lv_anim_path_ease_out) },
{ "&anim_path_linear", be_cconst_ptr(&lv_anim_path_linear) },
{ "&anim_path_overshoot", be_cconst_ptr(&lv_anim_path_overshoot) },
{ "&anim_path_step", be_cconst_ptr(&lv_anim_path_step) },
{ "@load_font", be_cconst_ptr(&lv0_load_font) },
}; };

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_x_tostring(bvm *vm); // generic function
extern int lv_be_style_init(bvm *vm); extern int lv_be_style_init(bvm *vm);
extern int lv_be_anim_init(bvm *vm);
extern int lv_x_tostring(bvm *vm); extern int lv_x_tostring(bvm *vm);
BE_EXPORT_VARIABLE extern const bclass be_class_lv_obj; BE_EXPORT_VARIABLE extern const bclass be_class_lv_obj;
@ -693,6 +694,31 @@ extern int lvbe_spinbox_decrement(bvm *vm);
/* `lv_spinner` external functions definitions */ /* `lv_spinner` external functions definitions */
extern int lvbe_spinner_create(bvm *vm); extern int lvbe_spinner_create(bvm *vm);
/* `lv_anim` external functions definitions */
extern int lvbe_anim_init(bvm *vm);
extern int lvbe_anim_set_var(bvm *vm);
extern int lvbe_anim_set_exec_cb(bvm *vm);
extern int lvbe_anim_set_time(bvm *vm);
extern int lvbe_anim_set_delay(bvm *vm);
extern int lvbe_anim_set_values(bvm *vm);
extern int lvbe_anim_set_custom_exec_cb(bvm *vm);
extern int lvbe_anim_set_path_cb(bvm *vm);
extern int lvbe_anim_set_start_cb(bvm *vm);
extern int lvbe_anim_set_get_value_cb(bvm *vm);
extern int lvbe_anim_set_ready_cb(bvm *vm);
extern int lvbe_anim_set_playback_time(bvm *vm);
extern int lvbe_anim_set_playback_delay(bvm *vm);
extern int lvbe_anim_set_repeat_count(bvm *vm);
extern int lvbe_anim_set_repeat_delay(bvm *vm);
extern int lvbe_anim_set_early_apply(bvm *vm);
extern int lvbe_anim_set_user_data(bvm *vm);
extern int lvbe_anim_start(bvm *vm);
extern int lvbe_anim_get_delay(bvm *vm);
extern int lvbe_anim_get_playtime(bvm *vm);
extern int lvbe_anim_get_user_data(bvm *vm);
extern int lvbe_anim_custom_del(bvm *vm);
extern int lvbe_anim_custom_get(bvm *vm);
/* `lv_timer` external functions definitions */ /* `lv_timer` external functions definitions */
extern int lvbe_timer_del(bvm *vm); extern int lvbe_timer_del(bvm *vm);
extern int lvbe_timer_pause(bvm *vm); extern int lvbe_timer_pause(bvm *vm);
@ -930,6 +956,7 @@ extern int be_ntv_lv_meter_init(bvm *vm);
extern int be_ntv_lv_msgbox_init(bvm *vm); extern int be_ntv_lv_msgbox_init(bvm *vm);
extern int be_ntv_lv_spinbox_init(bvm *vm); extern int be_ntv_lv_spinbox_init(bvm *vm);
extern int be_ntv_lv_spinner_init(bvm *vm); extern int be_ntv_lv_spinner_init(bvm *vm);
extern int be_ntv_lv_anim_init(bvm *vm);
extern int be_ntv_lv_timer_init(bvm *vm); extern int be_ntv_lv_timer_init(bvm *vm);
extern int be_ntv_lv_arc_init(bvm *vm); extern int be_ntv_lv_arc_init(bvm *vm);
extern int be_ntv_lv_bar_init(bvm *vm); extern int be_ntv_lv_bar_init(bvm *vm);
@ -946,6 +973,7 @@ extern int be_ntv_lv_switch_init(bvm *vm);
extern int be_ntv_lv_table_init(bvm *vm); extern int be_ntv_lv_table_init(bvm *vm);
extern int be_ntv_lv_textarea_init(bvm *vm); extern int be_ntv_lv_textarea_init(bvm *vm);
extern const bclass be_class_lv_anim;
extern const bclass be_class_lv_arc; extern const bclass be_class_lv_arc;
extern const bclass be_class_lv_bar; extern const bclass be_class_lv_bar;
extern const bclass be_class_lv_btn; extern const bclass be_class_lv_btn;
@ -1083,6 +1111,23 @@ be_local_class(lv_timer,
); );
/*******************************************************************/ /*******************************************************************/
/********************************************************************
** Solidified class: lv_anim
********************************************************************/
be_local_class(lv_anim,
1,
NULL,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lv_be_anim_init) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lv_x_tostring) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lv_x_member) },
})),
be_str_literal("lv_anim")
);
/*******************************************************************/
/******************************************************************** /********************************************************************
** Solidified class: lv_font ** Solidified class: lv_font
********************************************************************/ ********************************************************************/
@ -1378,6 +1423,12 @@ void be_load_lv_spinner_class(bvm *vm) {
be_pop(vm, 1); be_pop(vm, 1);
} }
void be_load_lv_anim_class(bvm *vm) {
be_pushntvclass(vm, &be_class_lv_anim);
be_setglobal(vm, "lv_anim");
be_pop(vm, 1);
}
void be_load_lv_timer_class(bvm *vm) { void be_load_lv_timer_class(bvm *vm) {
be_pushntvclass(vm, &be_class_lv_timer); be_pushntvclass(vm, &be_class_lv_timer);
be_setglobal(vm, "lv_timer"); be_setglobal(vm, "lv_timer");

View File

@ -2,7 +2,16 @@
// Functions // Functions
// ====================================================================== // ======================================================================
load_font=&lv0_load_font load_font=@lv0_load_font
// lv_anim_path_functions
anim_path_bounce=&lv_anim_path_bounce
anim_path_ease_in=&lv_anim_path_ease_in
anim_path_ease_in_out=&lv_anim_path_ease_in_out
anim_path_ease_out=&lv_anim_path_ease_out
anim_path_linear=&lv_anim_path_linear
anim_path_overshoot=&lv_anim_path_overshoot
anim_path_step=&lv_anim_path_step
// ====================================================================== // ======================================================================
// Colors // Colors

View File

@ -708,6 +708,37 @@ 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)
// ../../lvgl/src/misc/lv_anim.h
void lv_anim_init(lv_anim_t * a)
static inline void lv_anim_set_var(lv_anim_t * a, void * var)
static inline void lv_anim_set_exec_cb(lv_anim_t * a, lv_anim_exec_xcb_t exec_cb)
static inline void lv_anim_set_time(lv_anim_t * a, uint32_t duration)
static inline void lv_anim_set_delay(lv_anim_t * a, uint32_t delay)
static inline void lv_anim_set_values(lv_anim_t * a, int32_t start, int32_t end)
static inline void lv_anim_set_custom_exec_cb(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb)
static inline void lv_anim_set_path_cb(lv_anim_t * a, lv_anim_path_cb_t path_cb)
static inline void lv_anim_set_start_cb(lv_anim_t * a, lv_anim_start_cb_t start_cb)
static inline void lv_anim_set_get_value_cb(lv_anim_t * a, lv_anim_get_value_cb_t get_value_cb)
static inline void lv_anim_set_ready_cb(lv_anim_t * a, lv_anim_ready_cb_t ready_cb)
static inline void lv_anim_set_playback_time(lv_anim_t * a, uint32_t time)
static inline void lv_anim_set_playback_delay(lv_anim_t * a, uint32_t delay)
static inline void lv_anim_set_repeat_count(lv_anim_t * a, uint16_t cnt)
static inline void lv_anim_set_repeat_delay(lv_anim_t * a, uint32_t delay)
static inline void lv_anim_set_early_apply(lv_anim_t * a, bool en)
static inline void lv_anim_set_user_data(lv_anim_t * a, void * user_data)
lv_anim_t * lv_anim_start(const lv_anim_t * a)
static inline uint32_t lv_anim_get_delay(lv_anim_t * a)
uint32_t lv_anim_get_playtime(lv_anim_t * a)
static inline void * lv_anim_get_user_data(lv_anim_t * a)
bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb)
void lv_anim_del_all(void)
lv_anim_t * lv_anim_get(void * var, lv_anim_exec_xcb_t exec_cb)
static inline bool lv_anim_custom_del(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb)
static inline lv_anim_t * lv_anim_custom_get(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb)
uint16_t lv_anim_count_running(void)
uint32_t lv_anim_speed_to_time(uint32_t speed, int32_t start, int32_t end)
void lv_anim_refr_now(void)
// ../../lvgl/src/misc/lv_area.h // ../../lvgl/src/misc/lv_area.h
void lv_area_set(lv_area_t * area_p, lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2) void lv_area_set(lv_area_t * area_p, lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2)
inline static void lv_area_copy(lv_area_t * dest, const lv_area_t * src) inline static void lv_area_copy(lv_area_t * dest, const lv_area_t * src)

View File

@ -3,6 +3,51 @@
*******************************************************************/ *******************************************************************/
#include "be_constobj.h" #include "be_constobj.h"
/********************************************************************
** Solidified function: _anonymous_
********************************************************************/
be_local_closure(lv_extra__anonymous_, /* name */
be_nested_proto(
4, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 8]) { /* constants */
/* K0 */ be_nested_str(global),
/* K1 */ be_nested_str(lv),
/* K2 */ be_nested_str(lv_coord_arr),
/* K3 */ be_nested_str(lv_point_arr),
/* K4 */ be_nested_str(coord_arr),
/* K5 */ be_nested_str(point_arr),
/* K6 */ be_nested_str(style_prop_arr),
/* K7 */ be_nested_str(lv_style_prop_arr),
}),
&be_const_str__anonymous_,
&be_const_str_solidified,
( &(const binstruction[13]) { /* code */
0xA4060000, // 0000 IMPORT R1 K0
0x88080301, // 0001 GETMBR R2 R1 K1
0x880C0102, // 0002 GETMBR R3 R0 K2
0x900A0403, // 0003 SETMBR R2 K2 R3
0x880C0103, // 0004 GETMBR R3 R0 K3
0x900A0603, // 0005 SETMBR R2 K3 R3
0x880C0102, // 0006 GETMBR R3 R0 K2
0x900A0803, // 0007 SETMBR R2 K4 R3
0x880C0103, // 0008 GETMBR R3 R0 K3
0x900A0A03, // 0009 SETMBR R2 K5 R3
0x880C0107, // 000A GETMBR R3 R0 K7
0x900A0C03, // 000B SETMBR R2 K6 R3
0x80040000, // 000C RET 1 R0
})
)
);
/*******************************************************************/
/******************************************************************** /********************************************************************
** Solidified function: init ** Solidified function: init
********************************************************************/ ********************************************************************/
@ -10,7 +55,7 @@ be_local_closure(lv_coord_arr_init, /* name */
be_nested_proto( be_nested_proto(
8, /* nstack */ 8, /* nstack */
2, /* argc */ 2, /* argc */
0, /* varg */ 2, /* varg */
0, /* has upvals */ 0, /* has upvals */
NULL, /* no upvals */ NULL, /* no upvals */
0, /* has sup protos */ 0, /* has sup protos */
@ -92,7 +137,7 @@ be_local_closure(lv_point_arr_init, /* name */
be_nested_proto( be_nested_proto(
8, /* nstack */ 8, /* nstack */
2, /* argc */ 2, /* argc */
0, /* varg */ 2, /* varg */
0, /* has upvals */ 0, /* has upvals */
NULL, /* no upvals */ NULL, /* no upvals */
0, /* has sup protos */ 0, /* has sup protos */
@ -188,56 +233,98 @@ be_local_class(lv_point_arr,
); );
/******************************************************************** /********************************************************************
** Solidified function: _anonymous_ ** Solidified function: init
********************************************************************/ ********************************************************************/
be_local_closure(lv_extra__anonymous_, /* name */ be_local_closure(lv_style_prop_arr_init, /* name */
be_nested_proto( be_nested_proto(
4, /* nstack */ 8, /* nstack */
1, /* argc */ 2, /* argc */
0, /* varg */ 2, /* varg */
0, /* has upvals */ 0, /* has upvals */
NULL, /* no upvals */ NULL, /* no upvals */
0, /* has sup protos */ 0, /* has sup protos */
NULL, /* no sub protos */ NULL, /* no sub protos */
1, /* has constants */ 1, /* has constants */
( &(const bvalue[ 6]) { /* constants */ ( &(const bvalue[ 6]) { /* constants */
/* K0 */ be_nested_str(global), /* K0 */ be_nested_str(instance),
/* K1 */ be_nested_str(lv), /* K1 */ be_nested_str(value_error),
/* K2 */ be_nested_str(lv_coord_arr), /* K2 */ be_nested_str(argument_X20must_X20be_X20a_X20list),
/* K3 */ be_nested_str(lv_point_arr), /* K3 */ be_nested_str(init),
/* K4 */ be_nested_str(coord_arr), /* K4 */ be_nested_str(add),
/* K5 */ be_nested_str(point_arr), /* K5 */ be_nested_str(stop_iteration),
}), }),
&be_const_str__anonymous_, &be_const_str_init,
&be_const_str_solidified, &be_const_str_solidified,
( &(const binstruction[11]) { /* code */ ( &(const binstruction[38]) { /* code */
0xA4060000, // 0000 IMPORT R1 K0 0x60080004, // 0000 GETGBL R2 G4
0x88080301, // 0001 GETMBR R2 R1 K1 0x5C0C0200, // 0001 MOVE R3 R1
0x880C0102, // 0002 GETMBR R3 R0 K2 0x7C080200, // 0002 CALL R2 1
0x900A0403, // 0003 SETMBR R2 K2 R3 0x20080500, // 0003 NE R2 R2 K0
0x880C0103, // 0004 GETMBR R3 R0 K3 0x740A0004, // 0004 JMPT R2 #000A
0x900A0603, // 0005 SETMBR R2 K3 R3 0x6008000F, // 0005 GETGBL R2 G15
0x880C0102, // 0006 GETMBR R3 R0 K2 0x5C0C0200, // 0006 MOVE R3 R1
0x900A0803, // 0007 SETMBR R2 K4 R3 0x60100012, // 0007 GETGBL R4 G18
0x880C0103, // 0008 GETMBR R3 R0 K3 0x7C080400, // 0008 CALL R2 2
0x900A0A03, // 0009 SETMBR R2 K5 R3 0x740A0000, // 0009 JMPT R2 #000B
0x80040000, // 000A RET 1 R0 0xB0060302, // 000A RAISE 1 K1 K2
0x60080003, // 000B GETGBL R2 G3
0x5C0C0000, // 000C MOVE R3 R0
0x7C080200, // 000D CALL R2 1
0x8C080503, // 000E GETMET R2 R2 K3
0x6010000C, // 000F GETGBL R4 G12
0x5C140200, // 0010 MOVE R5 R1
0x7C100200, // 0011 CALL R4 1
0x54160003, // 0012 LDINT R5 4
0x08100805, // 0013 MUL R4 R4 R5
0x7C080400, // 0014 CALL R2 2
0x60080010, // 0015 GETGBL R2 G16
0x5C0C0200, // 0016 MOVE R3 R1
0x7C080200, // 0017 CALL R2 1
0xA8020008, // 0018 EXBLK 0 #0022
0x5C0C0400, // 0019 MOVE R3 R2
0x7C0C0000, // 001A CALL R3 0
0x8C100104, // 001B GETMET R4 R0 K4
0x60180009, // 001C GETGBL R6 G9
0x5C1C0600, // 001D MOVE R7 R3
0x7C180200, // 001E CALL R6 1
0x541E0003, // 001F LDINT R7 4
0x7C100600, // 0020 CALL R4 3
0x7001FFF6, // 0021 JMP #0019
0x58080005, // 0022 LDCONST R2 K5
0xAC080200, // 0023 CATCH R2 1 0
0xB0080000, // 0024 RAISE 2 R0 R0
0x80000000, // 0025 RET 0
}) })
) )
); );
/*******************************************************************/ /*******************************************************************/
/********************************************************************
** Solidified class: lv_style_prop_arr
********************************************************************/
extern const bclass be_class_bytes;
be_local_class(lv_style_prop_arr,
0,
&be_class_bytes,
be_nested_map(1,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(init, -1), be_const_closure(lv_style_prop_arr_init_closure) },
})),
be_str_literal("lv_style_prop_arr")
);
/******************************************************************** /********************************************************************
** Solidified module: lv_extra ** Solidified module: lv_extra
********************************************************************/ ********************************************************************/
be_local_module(lv_extra, be_local_module(lv_extra,
"lv_extra", "lv_extra",
be_nested_map(3, be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) { ( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(init, -1), be_const_closure(lv_extra__anonymous__closure) }, { be_const_key(lv_style_prop_arr, -1), be_const_class(be_class_lv_style_prop_arr) },
{ be_const_key(lv_coord_arr, -1), be_const_class(be_class_lv_coord_arr) },
{ be_const_key(lv_point_arr, -1), be_const_class(be_class_lv_point_arr) }, { be_const_key(lv_point_arr, -1), be_const_class(be_class_lv_point_arr) },
{ be_const_key(lv_coord_arr, 1), be_const_class(be_class_lv_coord_arr) }, { be_const_key(init, 0), be_const_closure(lv_extra__anonymous__closure) },
})) }))
); );
BE_EXPORT_VARIABLE be_define_const_native_module(lv_extra); BE_EXPORT_VARIABLE be_define_const_native_module(lv_extra);

View File

@ -517,6 +517,36 @@ lv_timer = [ # valid LVGL8.2
] ]
lv_timer = ctypes.structure(lv_timer, "lv_timer") lv_timer = ctypes.structure(lv_timer, "lv_timer")
# #######################################################################
# # lv_anim
# lv_anim = [ # valid LVGL8.2
# [ptr, "var"],
# [ptr, "exec_cb"],
# [ptr, "start_cb"],
# [ptr, "ready_cb"],
# [ptr, "get_value_cb"],
# [ptr, "user_data"],
# [ptr, "path_cb"],
# [int32_t, "start_value"],
# [int32_t, "current_value"],
# [int32_t, "end_value"],
# [int32_t, "time"],
# [int32_t, "act_time"],
# [uint32_t, "playback_delay"],
# [uint32_t, "playback_time"],
# [uint32_t, "repeat_delay"],
# [uint32_t, "repeat_cnt"],
# [uint8_t_1, "early_apply"],
# [uint8_t_1, "playback_now"],
# [uint8_t_1, "run_round"],
# [uint8_t_1, "start_cb_called"],
# ]
# lv_anim = ctypes.structure(lv_anim, "lv_anim")
####################################################################### #######################################################################
# lv_draw_ctc # lv_draw_ctc
lv_draw_ctx = [ # valid LVGL8.2 lv_draw_ctx = [ # valid LVGL8.2

View File

@ -28,8 +28,21 @@ class lv_point_arr : bytes
end end
end end
class lv_style_prop_arr : bytes
def init(l)
if type(l) != 'instance' || !isinstance(l, list) raise "value_error", "argument must be a list" end
# size of the array is 2x number of elements
super(self).init(size(l) * 4)
for e: l
self.add(int(e), 4)
end
end
end
lv_extra.lv_coord_arr = lv_coord_arr lv_extra.lv_coord_arr = lv_coord_arr
lv_extra.lv_point_arr = lv_point_arr lv_extra.lv_point_arr = lv_point_arr
lv_extra.lv_style_prop_arr = lv_style_prop_arr
lv_extra.init = def (m) lv_extra.init = def (m)
import global import global
@ -39,6 +52,7 @@ lv_extra.init = def (m)
lv.lv_point_arr = m.lv_point_arr lv.lv_point_arr = m.lv_point_arr
lv.coord_arr = m.lv_coord_arr lv.coord_arr = m.lv_coord_arr
lv.point_arr = m.lv_point_arr lv.point_arr = m.lv_point_arr
lv.style_prop_arr = m.lv_style_prop_arr
return m return m
end end

View File

@ -86,6 +86,34 @@ int lv_be_style_init(bvm *vm) {
be_return_nil(vm); be_return_nil(vm);
} }
/*********************************************************************************************\
* Support for lv_anim `init()`
*
* Either encapsulate the pointer passed as `comptr` as arg1
* Or allocate a new empty style structure in memory. In this case, it is never freed.
\*********************************************************************************************/
int lv_be_anim_init(bvm *vm) {
int argc = be_top(vm);
lv_anim_t * anim = NULL;
if (argc > 1) {
anim = (lv_anim_t*) be_convert_single_elt(vm, 2, NULL, NULL);
}
if (anim == NULL) {
// if no valid pointer passed, allocate a new empty style
anim = (lv_anim_t*) be_malloc(vm, sizeof(lv_anim_t));
if (anim == NULL) {
be_throw(vm, BE_MALLOC_FAIL);
}
if (anim != NULL) {
lv_anim_init(anim);
}
}
be_pushcomptr(vm, anim);
be_setmember(vm, 1, "_p");
be_return_nil(vm);
}
// native closure to call `be_call_c_func` // native closure to call `be_call_c_func`
int lv_x_call_c(bvm *vm) { int lv_x_call_c(bvm *vm) {
// berry_log_C("lv_x_call_c enter"); // berry_log_C("lv_x_call_c enter");

View File

@ -110,7 +110,15 @@ return_types = {
"lv_grid_align_t": "i", "lv_grid_align_t": "i",
"_lv_event_dsc_t *": "i", "_lv_event_dsc_t *": "i",
# lv_anim
"lv_anim_t *": "lv_anim",
"lv_anim_enable_t": "i", "lv_anim_enable_t": "i",
"lv_anim_exec_xcb_t": "c",
"lv_anim_custom_exec_cb_t": "c",
"lv_anim_get_value_cb_t": "c",
"lv_anim_path_cb_t": "c",
"lv_anim_ready_cb_t": "c",
"lv_anim_start_cb_t": "c",
# arrays # arrays
"char * []": "str_arr", "char * []": "str_arr",
@ -181,7 +189,7 @@ lv_widgets = ['arc', 'bar', 'btn', 'btnmatrix', 'canvas', 'checkbox',
# extra widgets # extra widgets
lv_widgets = lv_widgets + [ 'chart', 'colorwheel', 'imgbtn', 'led', 'meter', 'msgbox', 'spinbox', 'spinner' ] lv_widgets = lv_widgets + [ 'chart', 'colorwheel', 'imgbtn', 'led', 'meter', 'msgbox', 'spinbox', 'spinner' ]
lv_prefix = ['obj', 'group', 'style', 'indev', 'disp', 'timer'] + lv_widgets lv_prefix = ['obj', 'group', 'style', 'indev', 'disp', 'timer', 'anim'] + lv_widgets
# define here widget inheritance because it's hard to deduce from source # define here widget inheritance because it's hard to deduce from source
lv_widget_inheritance = { lv_widget_inheritance = {
@ -234,7 +242,7 @@ with open(lv_widgets_file) as f:
# convert return type # convert return type
c_ret = c_convert_ret_type(ret_type) c_ret = c_convert_ret_type(ret_type)
elif ret_type_without_t in lv_cb_types: elif ret_type_without_t in lv_cb_types:
c_ret = "c" # general callback, if not already captured by explicit type c_ret = "C" # general callback, if not already captured by explicit type
else: else:
print(f" // Skipping unsupported return type: {ret_type}") print(f" // Skipping unsupported return type: {ret_type}")
continue continue
@ -267,7 +275,7 @@ with open(lv_widgets_file) as f:
ga_type = re.sub(r"_t$", "", ga_type) ga_type = re.sub(r"_t$", "", ga_type)
# if the type is a single letter, we just add it # if the type is a single letter, we just add it
if len(ga_type) == 1 and ga_type != 'c': # callbacks are different if len(ga_type) == 1 and ga_type != 'C': # callbacks are different
c_args += ga_type c_args += ga_type
else: else:
if ga_type.endswith("_cb"): if ga_type.endswith("_cb"):
@ -477,6 +485,7 @@ extern int lv_x_member(bvm *vm);
extern int lv_x_tostring(bvm *vm); // generic function extern int lv_x_tostring(bvm *vm); // generic function
extern int lv_be_style_init(bvm *vm); extern int lv_be_style_init(bvm *vm);
extern int lv_be_anim_init(bvm *vm);
extern int lv_x_tostring(bvm *vm); extern int lv_x_tostring(bvm *vm);
BE_EXPORT_VARIABLE extern const bclass be_class_lv_obj; BE_EXPORT_VARIABLE extern const bclass be_class_lv_obj;
@ -618,6 +627,23 @@ be_local_class(lv_timer,
); );
/*******************************************************************/ /*******************************************************************/
/********************************************************************
** Solidified class: lv_anim
********************************************************************/
be_local_class(lv_anim,
1,
NULL,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lv_be_anim_init) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lv_x_tostring) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lv_x_member) },
})),
be_str_literal("lv_anim")
);
/*******************************************************************/
/******************************************************************** /********************************************************************
** Solidified class: lv_font ** Solidified class: lv_font
********************************************************************/ ********************************************************************/
@ -803,6 +829,7 @@ for k in sorted(lv_module2):
v_macro = "be_cconst_int" v_macro = "be_cconst_int"
if v[0] == '"': v_prefix = "$"; v_macro = "be_cconst_string" if v[0] == '"': v_prefix = "$"; v_macro = "be_cconst_string"
if v[0] == '&': v_prefix = "&"; v_macro = "be_cconst_ptr" if v[0] == '&': v_prefix = "&"; v_macro = "be_cconst_ptr"
if v[0] == '@': v_prefix = "@"; v_macro = "be_cconst_ptr"; v = "&" + v[1:]
print(f" {{ \"{v_prefix}{k}\", {v_macro}({v}) }},") print(f" {{ \"{v_prefix}{k}\", {v_macro}({v}) }},")
else: else:
print(f" {{ \"{k}\", be_cconst_int(LV_{k}) }},") print(f" {{ \"{k}\", be_cconst_int(LV_{k}) }},")

View File

@ -67,6 +67,7 @@ lv_fun_globs = [
"extra/libs/qrcode/lv_qrcode.h", "extra/libs/qrcode/lv_qrcode.h",
"core/*.h", "core/*.h",
"draw/*.h", "draw/*.h",
"misc/lv_anim.h",
"misc/lv_style_gen.h", "misc/lv_style_gen.h",
"misc/lv_color.h", "misc/lv_color.h",
"misc/lv_style.h", "misc/lv_style.h",
@ -169,6 +170,7 @@ for header_name in headers_names:
"^lv_event_get_", # event_getters not needed "^lv_event_get_", # event_getters not needed
"^lv_refr_reset_fps_counter", "^lv_refr_reset_fps_counter",
"^lv_refr_get_fps_avg", "^lv_refr_get_fps_avg",
"^lv_anim_path_", # callbacks for animation are moved to constants
]: ]:
if re.search(exclude_pattern, fun_name): exclude = True if re.search(exclude_pattern, fun_name): exclude = True
if exclude: continue if exclude: continue
@ -200,7 +202,16 @@ print("""// ====================================================================
// Functions // Functions
// ====================================================================== // ======================================================================
load_font=&lv0_load_font load_font=@lv0_load_font
// lv_anim_path_functions
anim_path_bounce=&lv_anim_path_bounce
anim_path_ease_in=&lv_anim_path_ease_in
anim_path_ease_in_out=&lv_anim_path_ease_in_out
anim_path_ease_out=&lv_anim_path_ease_out
anim_path_linear=&lv_anim_path_linear
anim_path_overshoot=&lv_anim_path_overshoot
anim_path_step=&lv_anim_path_step
// ====================================================================== // ======================================================================
// Colors // Colors

View File

@ -30,6 +30,7 @@ const char berry_prog[] =
#ifdef USE_BERRY_PYTHON_COMPAT #ifdef USE_BERRY_PYTHON_COMPAT
// enable python syntax compatibility mode // enable python syntax compatibility mode
"import python_compat " "import python_compat "
"import cb "
#endif #endif
#ifdef USE_ENERGY_SENSOR #ifdef USE_ENERGY_SENSOR