Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LVGL port colorwheel from LVGL 8, HASPmota cpicker and msgbox #22244

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.
## [14.2.0.6]
### Added
- Support for Sonoff SPM v1.3.0 (#13447)
- LVGL port `colorwheel` from LVGL 8
- HASPmota `cpicker` and `msgbox`

### Breaking Changed

Expand Down
53 changes: 38 additions & 15 deletions lib/libesp32_lvgl/LVGL_assets/src/lv_theme_haspmota.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ typedef struct {
#endif

#if LV_USE_MSGBOX
lv_style_t msgbox_bg, msgbox_btn_bg;
lv_style_t msgbox_bg, msgbox_btn_bg, msgbox_backdrop_bg;
#endif

#if LV_USE_KEYBOARD
Expand Down Expand Up @@ -576,6 +576,10 @@ static void style_init(void)

style_init_reset(&styles->msgbox_bg);
lv_style_set_max_width(&styles->msgbox_bg, lv_pct(100));

style_init_reset(&styles->msgbox_backdrop_bg);
lv_style_set_bg_color(&styles->msgbox_backdrop_bg, lv_palette_main(LV_PALETTE_GREY));
lv_style_set_bg_opa(&styles->msgbox_backdrop_bg, LV_OPA_50);
#endif
#if LV_USE_KEYBOARD
style_init_reset(&styles->keyboard_btn_bg);
Expand Down Expand Up @@ -738,19 +742,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)

#if LV_USE_BUTTONMATRIX
else if(lv_obj_check_type(obj, &lv_buttonmatrix_class)) {
#if LV_USE_MSGBOX
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) {
lv_obj_add_style(obj, &styles->msgbox_btn_bg, 0);
lv_obj_add_style(obj, &styles->pad_gap, 0);
lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS);
lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED);
lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED);
lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_CHECKED);
lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &styles->bg_color_secondary_muted, LV_PART_ITEMS | LV_STATE_EDITED);
return;
}
#endif
#if LV_USE_TABVIEW
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_tabview_class)) {
lv_obj_add_style(obj, &styles->bg_color_white, 0);
Expand Down Expand Up @@ -1012,7 +1003,39 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
#if LV_USE_MSGBOX
else if(lv_obj_check_type(obj, &lv_msgbox_class)) {
lv_obj_add_style(obj, &styles->card, 0);
lv_obj_add_style(obj, &styles->msgbox_bg, 0);
lv_obj_add_style(obj, &styles->pad_zero, 0);
lv_obj_add_style(obj, &styles->clip_corner, 0);
return;
}
else if(lv_obj_check_type(obj, &lv_msgbox_backdrop_class)) {
lv_obj_add_style(obj, &styles->msgbox_backdrop_bg, 0);
return;
}
else if(lv_obj_check_type(obj, &lv_msgbox_header_class)) {
lv_obj_add_style(obj, &styles->pad_tiny, 0);
lv_obj_add_style(obj, &styles->bg_color_grey, 0);
return;
}
else if(lv_obj_check_type(obj, &lv_msgbox_footer_class)) {
lv_obj_add_style(obj, &styles->pad_tiny, 0);
return;
}
else if(lv_obj_check_type(obj, &lv_msgbox_content_class)) {
lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
lv_obj_add_style(obj, &styles->pad_tiny, 0);
return;
}
else if(lv_obj_check_type(obj, &lv_msgbox_header_button_class) ||
lv_obj_check_type(obj, &lv_msgbox_footer_button_class)) {
lv_obj_add_style(obj, &styles->btn, 0);
lv_obj_add_style(obj, &styles->bg_color_primary, 0);
lv_obj_add_style(obj, &styles->transition_delayed, 0);
lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED);
lv_obj_add_style(obj, &styles->transition_normal, LV_STATE_PRESSED);
lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &styles->bg_color_secondary, LV_STATE_CHECKED);
lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED);
return;
}
#endif
Expand Down
13 changes: 13 additions & 0 deletions lib/libesp32_lvgl/lv_binding_berry/generate/LVGL_API_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1570,3 +1570,16 @@ set_light_color|lv.color||[lv_qrcode_set_light_color](https://docs.lvgl.io/9.0/s
set_size|int||[lv_qrcode_set_size](https://docs.lvgl.io/9.0/search.html?q=lv_qrcode_set_size)
update|\<any\>, int|int|[lv_qrcode_update](https://docs.lvgl.io/9.0/search.html?q=lv_qrcode_update)

### widget `lv.colorwheel`

Method|Arguments|Return type|LVGL equivalent
:---|:---|:---|:---
get_color_mode||int|[lv_colorwheel_get_color_mode](https://docs.lvgl.io/9.0/search.html?q=lv_colorwheel_get_color_mode)
get_color_mode_fixed||bool|[lv_colorwheel_get_color_mode_fixed](https://docs.lvgl.io/9.0/search.html?q=lv_colorwheel_get_color_mode_fixed)
get_hsv||int|[lv_colorwheel_get_hsv](https://docs.lvgl.io/9.0/search.html?q=lv_colorwheel_get_hsv)
get_rgb||lv.color|[lv_colorwheel_get_rgb](https://docs.lvgl.io/9.0/search.html?q=lv_colorwheel_get_rgb)
set_hsv|int|bool|[lv_colorwheel_set_hsv](https://docs.lvgl.io/9.0/search.html?q=lv_colorwheel_set_hsv)
set_mode|int||[lv_colorwheel_set_mode](https://docs.lvgl.io/9.0/search.html?q=lv_colorwheel_set_mode)
set_mode_fixed|bool||[lv_colorwheel_set_mode_fixed](https://docs.lvgl.io/9.0/search.html?q=lv_colorwheel_set_mode_fixed)
set_rgb|lv.color|bool|[lv_colorwheel_set_rgb](https://docs.lvgl.io/9.0/search.html?q=lv_colorwheel_set_rgb)

23 changes: 23 additions & 0 deletions lib/libesp32_lvgl/lv_binding_berry/generate/be_lv_c_mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ extern "C" {

#include "be_ctypes.h"
#include "be_mapping.h"
#include "../src/lv_colorwheel.h"

/* `lv_style` methods */
const be_ntv_func_def_t lv_style_func[] = {
Expand Down Expand Up @@ -1422,6 +1423,20 @@ const be_ntv_func_def_t lv_tileview_func[] = {
};
#endif // BE_LV_WIDGET_TILEVIEW

/* `lv_colorwheel` methods */
#ifdef BE_LV_WIDGET_COLORWHEEL
const be_ntv_func_def_t lv_colorwheel_func[] = {
{ "get_color_mode", { (const void*) &lv_colorwheel_get_color_mode, "i", "(lv.obj)" } },
{ "get_color_mode_fixed", { (const void*) &lv_colorwheel_get_color_mode_fixed, "b", "(lv.obj)" } },
{ "get_hsv", { (const void*) &lv_colorwheel_get_hsv, "i", "(lv.obj)" } },
{ "get_rgb", { (const void*) &lv_colorwheel_get_rgb, "lv.color", "(lv.obj)" } },
{ "set_hsv", { (const void*) &lv_colorwheel_set_hsv, "b", "(lv.obj)i" } },
{ "set_mode", { (const void*) &lv_colorwheel_set_mode, "", "(lv.obj)i" } },
{ "set_mode_fixed", { (const void*) &lv_colorwheel_set_mode_fixed, "", "(lv.obj)b" } },
{ "set_rgb", { (const void*) &lv_colorwheel_set_rgb, "b", "(lv.obj)(lv.color)" } },
};
#endif // BE_LV_WIDGET_COLORWHEEL

extern const bclass be_class_lv_anim;
extern const bclass be_class_lv_animimg;
extern const bclass be_class_lv_arc;
Expand All @@ -1433,6 +1448,7 @@ extern const bclass be_class_lv_canvas;
extern const bclass be_class_lv_chart;
extern const bclass be_class_lv_checkbox;
extern const bclass be_class_lv_color;
extern const bclass be_class_lv_colorwheel;
extern const bclass be_class_lv_display;
extern const bclass be_class_lv_dropdown;
extern const bclass be_class_lv_event;
Expand Down Expand Up @@ -1503,6 +1519,9 @@ const be_ntv_class_def_t lv_classes[] = {
{ "lv_checkbox", &be_class_lv_checkbox, lv_checkbox_func, sizeof(lv_checkbox_func) / sizeof(lv_checkbox_func[0]) },
#endif // BE_LV_WIDGET_CHECKBOX
{ "lv_color", &be_class_lv_color, lv_color_func, sizeof(lv_color_func) / sizeof(lv_color_func[0]) },
#ifdef BE_LV_WIDGET_COLORWHEEL
{ "lv_colorwheel", &be_class_lv_colorwheel, lv_colorwheel_func, sizeof(lv_colorwheel_func) / sizeof(lv_colorwheel_func[0]) },
#endif // BE_LV_WIDGET_COLORWHEEL
{ "lv_display", &be_class_lv_display, lv_display_func, sizeof(lv_display_func) / sizeof(lv_display_func[0]) },
#ifdef BE_LV_WIDGET_DROPDOWN
{ "lv_dropdown", &be_class_lv_dropdown, lv_dropdown_func, sizeof(lv_dropdown_func) / sizeof(lv_dropdown_func[0]) },
Expand Down Expand Up @@ -1770,6 +1789,10 @@ const size_t lv_classes_size = sizeof(lv_classes) / sizeof(lv_classes[0]);
#ifdef BE_LV_WIDGET_TILEVIEW
int be_ntv_lv_tileview_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_tileview_create, "+_p", "(lv.obj)"); }
#endif // BE_LV_WIDGET_TILEVIEW
/* `lv_colorwheel` methods */
#ifdef BE_LV_WIDGET_COLORWHEEL
int be_ntv_lv_colorwheel_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_colorwheel_create, "+_p", "(lv.obj)b"); }
#endif // BE_LV_WIDGET_COLORWHEEL

// create font either empty or from parameter on stack
int lvbe_font_create(bvm *vm) { return be_call_c_func(vm, NULL, "+_p", ""); }
Expand Down
16 changes: 16 additions & 0 deletions lib/libesp32_lvgl/lv_binding_berry/generate/be_lvgl_widgets_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ BE_EXPORT_VARIABLE extern const bclass be_class_lv_obj;
extern int lvbe_font_create(bvm *vm);
extern int lvbe_theme_create(bvm *vm);

// adding ad-hoc colorwheel from LVGL8 to LVGL9
extern const lv_obj_class_t lv_colorwheel_class;


extern int be_ntv_lv_style_init(bvm *vm);
extern int be_ntv_lv_font_init(bvm *vm);
Expand Down Expand Up @@ -78,6 +81,7 @@ extern int be_ntv_lv_table_init(bvm *vm);
extern int be_ntv_lv_tabview_init(bvm *vm);
extern int be_ntv_lv_textarea_init(bvm *vm);
extern int be_ntv_lv_tileview_init(bvm *vm);
extern int be_ntv_lv_colorwheel_init(bvm *vm);

extern const bclass be_class_lv_anim;
extern const bclass be_class_lv_animimg;
Expand All @@ -90,6 +94,7 @@ extern const bclass be_class_lv_canvas;
extern const bclass be_class_lv_chart;
extern const bclass be_class_lv_checkbox;
extern const bclass be_class_lv_color;
extern const bclass be_class_lv_colorwheel;
extern const bclass be_class_lv_display;
extern const bclass be_class_lv_dropdown;
extern const bclass be_class_lv_event;
Expand Down Expand Up @@ -685,3 +690,14 @@ class be_class_lv_tileview (scope: global, name: lv_tileview, super: be_class_lv
}
@const_object_info_end */

/********************************************************************
** Solidified class: lv_colorwheel
********************************************************************/
#include "be_fixed_be_class_lv_colorwheel.h"
/* @const_object_info_begin
class be_class_lv_colorwheel (scope: global, name: lv_colorwheel, super: be_class_lv_obj, strings: weak) {
init, func(be_ntv_lv_colorwheel_init)
_class, comptr(&lv_colorwheel_class)
}
@const_object_info_end */

11 changes: 11 additions & 0 deletions lib/libesp32_lvgl/lv_binding_berry/mapping/lv_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1498,3 +1498,14 @@ void be_load_lvgl_classes(bvm *vm)
void lv_image_set_tasmota_logo(lv_obj_t * img)
lv_area_t * lv_bar_get_indic_area(lv_obj_t * bar)

// ../src/lv_colorwheel.h
lv_obj_t * lv_colorwheel_create(lv_obj_t * parent, bool knob_recolor)
bool lv_colorwheel_set_hsv(lv_obj_t * obj, lv_color_hsv_t hsv)
bool lv_colorwheel_set_rgb(lv_obj_t * obj, lv_color_t color)
void lv_colorwheel_set_mode(lv_obj_t * obj, lv_colorwheel_mode_t mode)
void lv_colorwheel_set_mode_fixed(lv_obj_t * obj, bool fixed)
lv_color_hsv_t lv_colorwheel_get_hsv(lv_obj_t * obj)
lv_color_t lv_colorwheel_get_rgb(lv_obj_t * obj)
lv_colorwheel_mode_t lv_colorwheel_get_color_mode(lv_obj_t * obj)
bool lv_colorwheel_get_color_mode_fixed(lv_obj_t * obj)

Loading