From a6e0e96d3c1300cde04ac1bd378e86e7f7278fde Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sat, 23 Apr 2022 18:55:03 +0200 Subject: [PATCH] LVGL improved qrcode intergation as actual class --- .../generate/be_lv_c_mapping.h | 16 +++++++++++++ .../generate/be_lvgl_module.c | 3 --- .../generate/be_lvgl_widgets_lib.c | 23 +++++++++++++++++++ .../lv_binding_berry/tools/convert.py | 5 +++- tasmota/my_user_config.h | 2 ++ 5 files changed, 45 insertions(+), 4 deletions(-) diff --git a/lib/libesp32_lvgl/lv_binding_berry/generate/be_lv_c_mapping.h b/lib/libesp32_lvgl/lv_binding_berry/generate/be_lv_c_mapping.h index 067690b9b..3b18a9a2a 100644 --- a/lib/libesp32_lvgl/lv_binding_berry/generate/be_lv_c_mapping.h +++ b/lib/libesp32_lvgl/lv_binding_berry/generate/be_lv_c_mapping.h @@ -583,6 +583,14 @@ const be_ntv_func_def_t lv_indev_func[] = { { "wait_release", { (const void*) &lv_indev_wait_release, "", "(lv.lv_indev)" } }, }; +/* `lv_qrcode` methods */ +#ifdef BE_LV_WIDGET_QRCODE +const be_ntv_func_def_t lv_qrcode_func[] = { + { "delete", { (const void*) &lv_qrcode_delete, "", "(lv.lv_obj)" } }, + { "update", { (const void*) &lv_qrcode_update, "i", "(lv.lv_obj).i" } }, +}; +#endif // BE_LV_WIDGET_QRCODE + /* `lv_chart` methods */ #ifdef BE_LV_WIDGET_CHART const be_ntv_func_def_t lv_chart_func[] = { @@ -1030,6 +1038,7 @@ extern const bclass be_class_lv_line; extern const bclass be_class_lv_meter; extern const bclass be_class_lv_msgbox; 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_slider; extern const bclass be_class_lv_spinbox; @@ -1099,6 +1108,9 @@ const be_ntv_class_def_t lv_classes[] = { { "lv_msgbox", &be_class_lv_msgbox, lv_msgbox_func, sizeof(lv_msgbox_func) / sizeof(lv_msgbox_func[0]) }, #endif // BE_LV_WIDGET_MSGBOX { "lv_obj", &be_class_lv_obj, lv_obj_func, sizeof(lv_obj_func) / sizeof(lv_obj_func[0]) }, +#ifdef BE_LV_WIDGET_QRCODE + { "lv_qrcode", &be_class_lv_qrcode, lv_qrcode_func, sizeof(lv_qrcode_func) / sizeof(lv_qrcode_func[0]) }, +#endif // BE_LV_WIDGET_QRCODE #ifdef BE_LV_WIDGET_ROLLER { "lv_roller", &be_class_lv_roller, lv_roller_func, sizeof(lv_roller_func) / sizeof(lv_roller_func[0]) }, #endif // BE_LV_WIDGET_ROLLER @@ -1140,6 +1152,10 @@ const size_t lv_classes_size = sizeof(lv_classes) / sizeof(lv_classes[0]); /* `lv_group` methods */ int be_ntv_lv_group_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_group_create, "+_p", ""); } /* `lv_indev` methods */ + /* `lv_qrcode` methods */ +#ifdef BE_LV_WIDGET_QRCODE + int be_ntv_lv_qrcode_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_qrcode_create, "+_p", "(lv.lv_obj)i(lv.lv_color)(lv.lv_color)"); } +#endif // BE_LV_WIDGET_QRCODE /* `lv_chart` methods */ #ifdef BE_LV_WIDGET_CHART int be_ntv_lv_chart_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_chart_create, "+_p", "(lv.lv_obj)"); } diff --git a/lib/libesp32_lvgl/lv_binding_berry/generate/be_lvgl_module.c b/lib/libesp32_lvgl/lv_binding_berry/generate/be_lvgl_module.c index 29ef33819..14707d20b 100644 --- a/lib/libesp32_lvgl/lv_binding_berry/generate/be_lvgl_module.c +++ b/lib/libesp32_lvgl/lv_binding_berry/generate/be_lvgl_module.c @@ -141,9 +141,6 @@ const be_ntv_func_def_t lv_func[] = { { "palette_lighten", { (const void*) &lv_palette_lighten, "lv.lv_color", "ii" } }, { "palette_main", { (const void*) &lv_palette_main, "lv.lv_color", "i" } }, { "pct", { (const void*) &lv_pct, "i", "i" } }, - { "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)" } }, diff --git a/lib/libesp32_lvgl/lv_binding_berry/generate/be_lvgl_widgets_lib.c b/lib/libesp32_lvgl/lv_binding_berry/generate/be_lvgl_widgets_lib.c index 6629dcc78..f2811fe5c 100644 --- a/lib/libesp32_lvgl/lv_binding_berry/generate/be_lvgl_widgets_lib.c +++ b/lib/libesp32_lvgl/lv_binding_berry/generate/be_lvgl_widgets_lib.c @@ -585,6 +585,11 @@ extern int lvbe_indev_get_vect(bvm *vm); extern int lvbe_indev_wait_release(bvm *vm); extern int lvbe_indev_search_obj(bvm *vm); +/* `lv_qrcode` external functions definitions */ +extern int lvbe_qrcode_create(bvm *vm); +extern int lvbe_qrcode_update(bvm *vm); +extern int lvbe_qrcode_delete(bvm *vm); + /* `lv_chart` external functions definitions */ extern int lvbe_chart_create(bvm *vm); extern int lvbe_chart_set_type(bvm *vm); @@ -948,6 +953,7 @@ extern int be_ntv_lv_disp_init(bvm *vm); extern int be_ntv_lv_obj_init(bvm *vm); extern int be_ntv_lv_group_init(bvm *vm); extern int be_ntv_lv_indev_init(bvm *vm); +extern int be_ntv_lv_qrcode_init(bvm *vm); extern int be_ntv_lv_chart_init(bvm *vm); extern int be_ntv_lv_colorwheel_init(bvm *vm); extern int be_ntv_lv_imgbtn_init(bvm *vm); @@ -996,6 +1002,7 @@ extern const bclass be_class_lv_line; extern const bclass be_class_lv_meter; extern const bclass be_class_lv_msgbox; 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_slider; extern const bclass be_class_lv_spinbox; @@ -1193,6 +1200,22 @@ be_local_class(lv_img, ); /*******************************************************************/ +/******************************************************************** +** Solidified class: lv_qrcode +********************************************************************/ +extern const bclass be_class_lv_obj; +be_local_class(lv_qrcode, + 0, + &be_class_lv_obj, + be_nested_map(2, + ( (struct bmapnode*) &(const bmapnode[]) { + { be_const_key(_class, -1), be_const_comptr(&lv_qrcode_class) }, + { be_const_key(init, -1), be_const_func(be_ntv_lv_qrcode_init) }, + })), + (be_str_literal("lv_qrcode")) +); +/*******************************************************************/ + /******************************************************************** ** Solidified class: lv_chart ********************************************************************/ diff --git a/lib/libesp32_lvgl/lv_binding_berry/tools/convert.py b/lib/libesp32_lvgl/lv_binding_berry/tools/convert.py index 2e33c9a83..bb36141e3 100644 --- a/lib/libesp32_lvgl/lv_binding_berry/tools/convert.py +++ b/lib/libesp32_lvgl/lv_binding_berry/tools/convert.py @@ -188,8 +188,11 @@ lv_widgets = ['arc', 'bar', 'btn', 'btnmatrix', 'canvas', 'checkbox', 'dropdown', 'img', 'label', 'line', 'roller', 'slider', 'switch', 'table', 'textarea' ] # extra widgets - lv_widgets = lv_widgets + [ 'chart', 'colorwheel', 'imgbtn', 'led', 'meter', 'msgbox', 'spinbox', 'spinner' ] + +# add qrcode +lv_widgets = lv_widgets + [ 'qrcode' ] + lv_prefix = ['obj', 'group', 'style', 'indev', 'disp', 'timer', 'anim'] + lv_widgets # define here widget inheritance because it's hard to deduce from source diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index c934ffde7..6a197c5d5 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -1081,6 +1081,8 @@ #define BE_LV_WIDGET_SPINBOX #define BE_LV_WIDGET_SPINNER + #define BE_LV_WIDGET_QRCODE + #endif // ESP32 /*********************************************************************************************\