From e06201f042c141d97b06e6b031ab4d6cb5c4e03f Mon Sep 17 00:00:00 2001 From: 3096 Date: Fri, 26 Jun 2020 22:27:52 -0700 Subject: [PATCH 01/15] material theme: fix lv_win uninitialed styles --- src/lv_themes/lv_theme_material.c | 62 +++++++++++++++++-------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 33d6f4985..c1cd0c0bf 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -792,6 +792,39 @@ static void roller_init(void) static void tabview_init(void) { #if LV_USE_TABVIEW != 0 +#endif +} + +static void tileview_init(void) +{ +#if LV_USE_TILEVIEW != 0 +#endif +} + +static void table_init(void) +{ +#if LV_USE_TABLE != 0 + style_init_reset(&styles->table_cell); + lv_style_set_border_color(&styles->table_cell, LV_STATE_DEFAULT, COLOR_BG_BORDER); + lv_style_set_border_width(&styles->table_cell, LV_STATE_DEFAULT, 1); + lv_style_set_border_side(&styles->table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM); + lv_style_set_pad_left(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); + lv_style_set_pad_right(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); + lv_style_set_pad_top(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); + lv_style_set_pad_bottom(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); + +#endif +} + +static void win_init(void) +{ +#if LV_USE_WIN != 0 +#endif +} + +static void tabview_win_shared_init(void) +{ +#if LV_USE_TABVIEW || LV_USE_WIN style_init_reset(&styles->tabview_btns_bg); lv_style_set_bg_opa(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&styles->tabview_btns_bg, LV_STATE_DEFAULT, COLOR_BG); @@ -831,34 +864,6 @@ static void tabview_init(void) #endif } -static void tileview_init(void) -{ -#if LV_USE_TILEVIEW != 0 -#endif -} - -static void table_init(void) -{ -#if LV_USE_TABLE != 0 - style_init_reset(&styles->table_cell); - lv_style_set_border_color(&styles->table_cell, LV_STATE_DEFAULT, COLOR_BG_BORDER); - lv_style_set_border_width(&styles->table_cell, LV_STATE_DEFAULT, 1); - lv_style_set_border_side(&styles->table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM); - lv_style_set_pad_left(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); - lv_style_set_pad_right(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); - lv_style_set_pad_top(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); - lv_style_set_pad_bottom(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); - -#endif -} - -static void win_init(void) -{ -#if LV_USE_WIN != 0 - -#endif -} - /********************** * GLOBAL FUNCTIONS @@ -927,6 +932,7 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s tileview_init(); table_init(); win_init(); + tabview_win_shared_init(); theme.apply_xcb = theme_apply; From 40daa7195dc86655dcf6b830cfabfc2d8d793d84 Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Sun, 28 Jun 2020 00:46:22 +0300 Subject: [PATCH 02/15] lv_theme: add lv_theme_set_apply_cb (#1616) --- src/lv_themes/lv_theme.c | 11 +++++++++++ src/lv_themes/lv_theme.h | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/src/lv_themes/lv_theme.c b/src/lv_themes/lv_theme.c index 365fe3aa4..d990912db 100644 --- a/src/lv_themes/lv_theme.c +++ b/src/lv_themes/lv_theme.c @@ -106,6 +106,17 @@ void lv_theme_set_base(lv_theme_t * new, lv_theme_t * base) new->base = base; } +/** + * Set a callback for a theme. + * The callback is used to add styles to different objects + * @param theme pointer to theme which callback should be set + * @param cb pointer to the callback + */ +void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb) +{ + theme->apply_cb = apply_cb; +} + /** * Get the small font of the theme * @return pointer to the font diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index 0a24f5e7d..788766726 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -206,6 +206,14 @@ void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy); */ void lv_theme_set_base(lv_theme_t * new, lv_theme_t * base); +/** + * Set an apply callback for a theme. + * The apply callback is used to add styles to different objects + * @param theme pointer to theme which callback should be set + * @param apply_cb pointer to the callback + */ +void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb); + /** * Get the small font of the theme * @return pointer to the font From d055944ebb80e45a1d4f3940654cba5343f4cdce Mon Sep 17 00:00:00 2001 From: liangyongxiang Date: Sun, 28 Jun 2020 12:13:39 +0800 Subject: [PATCH 03/15] Add conditional macro LV_USE_GROUP to more GROUP related singles: - LV_SIGNAL_CONTROL - LV_SIGNAL_GET_EDITABLE --- src/lv_widgets/lv_btn.c | 2 ++ src/lv_widgets/lv_btnmatrix.c | 4 ++++ src/lv_widgets/lv_calendar.c | 2 ++ src/lv_widgets/lv_checkbox.c | 2 ++ src/lv_widgets/lv_cpicker.c | 2 ++ src/lv_widgets/lv_dropdown.c | 4 ++++ src/lv_widgets/lv_list.c | 2 ++ src/lv_widgets/lv_msgbox.c | 9 +++++++-- src/lv_widgets/lv_page.c | 4 ++++ src/lv_widgets/lv_roller.c | 5 +++++ src/lv_widgets/lv_slider.c | 4 ++++ src/lv_widgets/lv_spinbox.c | 4 ++++ src/lv_widgets/lv_switch.c | 4 ++++ src/lv_widgets/lv_tabview.c | 9 +++++++-- src/lv_widgets/lv_textarea.c | 4 ++++ src/lv_widgets/lv_win.c | 2 ++ 16 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/lv_widgets/lv_btn.c b/src/lv_widgets/lv_btn.c index e69aae20b..fa327bd6e 100644 --- a/src/lv_widgets/lv_btn.c +++ b/src/lv_widgets/lv_btn.c @@ -289,6 +289,7 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param) } } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { if(lv_btn_get_checkable(btn)) { @@ -309,6 +310,7 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param) if(res != LV_RES_OK) return res; } } +#endif } return res; diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index 0f2718699..d40880ce1 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -992,6 +992,7 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa ext->btn_id_act = LV_BTNMATRIX_BTN_NONE; } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP char c = *((char *)param); if(c == LV_KEY_RIGHT) { if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE) @@ -1059,10 +1060,13 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa ext->btn_id_act = ext->btn_id_focused; lv_obj_invalidate(btnm); } +#endif } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = true; +#endif } return res; } diff --git a/src/lv_widgets/lv_calendar.c b/src/lv_widgets/lv_calendar.c index d1b205bb4..fd1f93182 100644 --- a/src/lv_widgets/lv_calendar.c +++ b/src/lv_widgets/lv_calendar.c @@ -515,6 +515,7 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void * lv_obj_invalidate(calendar); } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP uint8_t c = *((uint8_t *)param); lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { @@ -537,6 +538,7 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void * } lv_obj_invalidate(calendar); } +#endif } return res; diff --git a/src/lv_widgets/lv_checkbox.c b/src/lv_widgets/lv_checkbox.c index 7196678e2..3f8ac3dc7 100644 --- a/src/lv_widgets/lv_checkbox.c +++ b/src/lv_widgets/lv_checkbox.c @@ -193,11 +193,13 @@ static lv_res_t lv_checkbox_signal(lv_obj_t * cb, lv_signal_t sign, void * param lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG)); } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN || c == LV_KEY_LEFT || c == LV_KEY_UP) { /*Follow the backgrounds state with the bullet*/ lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG)); } +#endif } return res; diff --git a/src/lv_widgets/lv_cpicker.c b/src/lv_widgets/lv_cpicker.c index 1b8025c5b..d80c9a56c 100644 --- a/src/lv_widgets/lv_cpicker.c +++ b/src/lv_widgets/lv_cpicker.c @@ -701,6 +701,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p lv_obj_invalidate(cpicker); } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/ if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { @@ -745,6 +746,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p if(res != LV_RES_OK) return res; } } +#endif } else if(sign == LV_SIGNAL_PRESSED) { ext->last_change_time = lv_tick_get(); diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index 0f16ef8e0..c7bbd8746 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -968,6 +968,7 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p if(ext->page) lv_obj_refresh_style(ext->page, LV_STYLE_PROP_ALL); } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) { if(ext->page == NULL) { @@ -992,10 +993,13 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p ext->sel_opt_id = ext->sel_opt_id_orig; lv_dropdown_close(ddlist); } +#endif } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = true; +#endif } return res; diff --git a/src/lv_widgets/lv_list.c b/src/lv_widgets/lv_list.c index d7b502db1..9df0d621d 100644 --- a/src/lv_widgets/lv_list.c +++ b/src/lv_widgets/lv_list.c @@ -730,8 +730,10 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param) #endif } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = true; +#endif } else if(sign == LV_SIGNAL_CONTROL) { diff --git a/src/lv_widgets/lv_msgbox.c b/src/lv_widgets/lv_msgbox.c index f971f93d8..60f4cdc9c 100644 --- a/src/lv_widgets/lv_msgbox.c +++ b/src/lv_widgets/lv_msgbox.c @@ -412,6 +412,7 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param { lv_res_t res; +#if LV_USE_GROUP /*Translate LV_KEY_UP/DOWN to LV_KEY_LEFT/RIGHT */ char c_trans = 0; if(sign == LV_SIGNAL_CONTROL) { @@ -421,6 +422,7 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param param = &c_trans; } +#endif if(sign == LV_SIGNAL_GET_STYLE) { lv_get_style_info_t * info = param; @@ -460,8 +462,11 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param if(btn_id != LV_BTNMATRIX_BTN_NONE) lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id); } } - else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL || - sign == LV_SIGNAL_GET_EDITABLE) { + else if( +#if LV_USE_GROUP + sign == LV_SIGNAL_CONTROL || sign == LV_SIGNAL_GET_EDITABLE || +#endif + sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS) { if(ext->btnm) { ext->btnm->signal_cb(ext->btnm, sign, param); } diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index f8141c320..89c6c0f0e 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -859,6 +859,7 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) refr_ext_draw_pad(page); } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP uint32_t c = *((uint32_t *)param); if(c == LV_KEY_DOWN) { @@ -883,10 +884,13 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) else lv_page_scroll_hor(page, lv_obj_get_width(page) / 4); } +#endif } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = true; +#endif } return res; diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 8a366fd79..23fe90837 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -490,13 +490,16 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par /* Include the ancient signal function */ if(sign != LV_SIGNAL_CONTROL) { /*Don't let the page to scroll on keys*/ +#if LV_USE_GROUP res = ancestor_signal(roller, sign, param); if(res != LV_RES_OK) return res; +#endif } if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME); lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller); + LV_UNUSED(ext); if(sign == LV_SIGNAL_STYLE_CHG) { lv_obj_t * label = get_label(roller); @@ -556,6 +559,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par #endif } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) { if(ext->sel_opt_id + 1 < ext->option_cnt) { @@ -572,6 +576,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par ext->sel_opt_id_ori = ori_id; } } +#endif } else if(sign == LV_SIGNAL_CLEANUP) { lv_obj_clean_style_list(roller, LV_ROLLER_PART_SELECTED); diff --git a/src/lv_widgets/lv_slider.c b/src/lv_widgets/lv_slider.c index b516c03f1..d7efb7469 100644 --- a/src/lv_widgets/lv_slider.c +++ b/src/lv_widgets/lv_slider.c @@ -407,6 +407,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { @@ -419,13 +420,16 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL); if(res != LV_RES_OK) return res; } +#endif } else if(sign == LV_SIGNAL_CLEANUP) { lv_obj_clean_style_list(slider, LV_SLIDER_PART_KNOB); } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = true; +#endif } return res; diff --git a/src/lv_widgets/lv_spinbox.c b/src/lv_widgets/lv_spinbox.c index c3098dc5e..669c72d38 100644 --- a/src/lv_widgets/lv_spinbox.c +++ b/src/lv_widgets/lv_spinbox.c @@ -390,8 +390,10 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p /* Include the ancient signal function */ if(sign != LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP res = ancestor_signal(spinbox, sign, param); if(res != LV_RES_OK) return res; +#endif } if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME); @@ -464,6 +466,7 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p } } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/ @@ -488,6 +491,7 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p else { lv_textarea_add_char(spinbox, c); } +#endif } return res; diff --git a/src/lv_widgets/lv_switch.c b/src/lv_widgets/lv_switch.c index f3b6aa549..dfc1aa964 100644 --- a/src/lv_widgets/lv_switch.c +++ b/src/lv_widgets/lv_switch.c @@ -296,12 +296,14 @@ static lv_res_t lv_switch_signal(lv_obj_t * sw, lv_signal_t sign, void * param) } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_UP) lv_switch_on(sw, LV_ANIM_ON); else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) lv_switch_off(sw, LV_ANIM_ON); res = lv_event_send(sw, LV_EVENT_VALUE_CHANGED, NULL); if(res != LV_RES_OK) return res; +#endif } else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { lv_style_int_t knob_left = lv_obj_get_style_pad_left(sw, LV_SWITCH_PART_KNOB); @@ -320,8 +322,10 @@ static lv_res_t lv_switch_signal(lv_obj_t * sw, lv_signal_t sign, void * param) sw->ext_draw_pad = LV_MATH_MAX(sw->ext_draw_pad, knob_size); } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = false; /*The ancestor slider is editable the switch is not*/ +#endif } return res; diff --git a/src/lv_widgets/lv_tabview.c b/src/lv_widgets/lv_tabview.c index 2b2475eb2..9e51d59dc 100644 --- a/src/lv_widgets/lv_tabview.c +++ b/src/lv_widgets/lv_tabview.c @@ -645,12 +645,17 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p #endif } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = true; +#endif } - if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL || sign == LV_SIGNAL_PRESSED || - sign == LV_SIGNAL_RELEASED) { + if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || +#if LV_USE_GROUP + sign == LV_SIGNAL_CONTROL || +#endif + sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED) { /* The button matrix is not in a group (the tab view is in it) but it should handle the * group signals. So propagate the related signals to the button matrix manually*/ diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index e95cb5cdd..c8bfc65da 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -1466,6 +1466,7 @@ static lv_res_t lv_textarea_signal(lv_obj_t * ta, lv_signal_t sign, void * param } } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/ if(c == LV_KEY_RIGHT) lv_textarea_cursor_right(ta); @@ -1486,10 +1487,13 @@ static lv_res_t lv_textarea_signal(lv_obj_t * ta, lv_signal_t sign, void * param else { lv_textarea_add_char(ta, c); } +#endif } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = true; +#endif } else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING || sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_RELEASED) { diff --git a/src/lv_widgets/lv_win.c b/src/lv_widgets/lv_win.c index fa5147053..6b825c168 100644 --- a/src/lv_widgets/lv_win.c +++ b/src/lv_widgets/lv_win.c @@ -645,8 +645,10 @@ static lv_res_t lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param) ext->title_txt = NULL; } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP /*Forward all the control signals to the page*/ ext->page->signal_cb(ext->page, sign, param); +#endif } return res; From ddbeb212b7be7aac7d71a0323c9d756d88a8418c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 28 Jun 2020 13:29:01 +0200 Subject: [PATCH 04/15] Add support to compressed fonts without pre-filter to gain some speed by sacrificing some memory --- CHANGELOG.md | 1 + src/lv_font/lv_font_fmt_txt.c | 34 +++++++++++++++++++++++++--------- src/lv_font/lv_font_fmt_txt.h | 1 + 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15ec85db2..7b747ea9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Available in the `dev` branch - Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes - Add `lv_obj_align_x()` and `lv_obj_align_y()` functions - Add `lv_obj_align_origo_x()` and `lv_obj_align_origo_y()` functions +- Support compressed fonts without pre-filter to gain some speed by sacrificing some memory ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* diff --git a/src/lv_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index abcb2f01e..403fe26ee 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -37,7 +37,7 @@ static int32_t unicode_list_compare(const void * ref, const void * element); static int32_t kern_pair_8_compare(const void * ref, const void * element); static int32_t kern_pair_16_compare(const void * ref, const void * element); -static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp); +static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp, bool prefilter); static inline void decompress_line(uint8_t * out, lv_coord_t w); static inline uint8_t get_bits(const uint8_t * in, uint32_t bit_pos, uint8_t len); static inline void bits_write(uint8_t * out, uint32_t bit_pos, uint8_t val, uint8_t len); @@ -114,7 +114,8 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic if(decompr_buf == NULL) return NULL; } - decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp); + bool prefilter = fdsc->bitmap_format == LV_FONT_FMT_TXT_COMPRESSED ? true : false; + decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp, prefilter); return decompr_buf; } @@ -333,8 +334,9 @@ static int32_t kern_pair_16_compare(const void * ref, const void * element) * @param out buffer to store the result * @param px_num number of pixels in the glyph (width * height) * @param bpp bit per pixel (bpp = 3 will be converted to bpp = 4) + * @param prefilter true: the lines are XORed */ -static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp) +static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp, bool prefilter) { uint32_t wrp = 0; uint8_t wr_size = bpp; @@ -343,7 +345,12 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord rle_init(in, bpp); uint8_t * line_buf1 = _lv_mem_buf_get(w); - uint8_t * line_buf2 = _lv_mem_buf_get(w); + + uint8_t * line_buf2 = NULL; + + if(prefilter) { + line_buf2= _lv_mem_buf_get(w); + } decompress_line(line_buf1, w); @@ -356,12 +363,21 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord } for(y = 1; y < h; y++) { - decompress_line(line_buf2, w); + if(prefilter) { + decompress_line(line_buf2, w); - for(x = 0; x < w; x++) { - line_buf1[x] = line_buf2[x] ^ line_buf1[x]; - bits_write(out, wrp, line_buf1[x], bpp); - wrp += wr_size; + for(x = 0; x < w; x++) { + line_buf1[x] = line_buf2[x] ^ line_buf1[x]; + bits_write(out, wrp, line_buf1[x], bpp); + wrp += wr_size; + } + } else { + decompress_line(line_buf1, w); + + for(x = 0; x < w; x++) { + bits_write(out, wrp, line_buf1[x], bpp); + wrp += wr_size; + } } } diff --git a/src/lv_font/lv_font_fmt_txt.h b/src/lv_font/lv_font_fmt_txt.h index 657bcfa30..549c7f5e6 100644 --- a/src/lv_font/lv_font_fmt_txt.h +++ b/src/lv_font/lv_font_fmt_txt.h @@ -150,6 +150,7 @@ typedef struct { typedef enum { LV_FONT_FMT_TXT_PLAIN = 0, LV_FONT_FMT_TXT_COMPRESSED = 1, + LV_FONT_FMT_TXT_COMPRESSED_NO_PREFILTER= 1, } lv_font_fmt_txt_bitmap_format_t; From 92027cc06f4dae161d4916eceb0e4b8c434a1b3c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 28 Jun 2020 13:32:40 +0200 Subject: [PATCH 05/15] lv_hal_tick: revert using uint32_t as tick_irq_flag uint8_t surely can be written in 1 instruction even on 16 bit MCUs --- src/lv_hal/lv_hal_tick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_hal/lv_hal_tick.c b/src/lv_hal/lv_hal_tick.c index afdceb077..3a1a5128a 100644 --- a/src/lv_hal/lv_hal_tick.c +++ b/src/lv_hal/lv_hal_tick.c @@ -29,7 +29,7 @@ * STATIC VARIABLES **********************/ static uint32_t sys_time = 0; -static volatile uint32_t tick_irq_flag; +static volatile uint8_t tick_irq_flag; /********************** * MACROS From 421f1b2c0122c7354e9b47708984b3ee23ac77d0 Mon Sep 17 00:00:00 2001 From: Themba Dube Date: Sun, 28 Jun 2020 09:16:25 -0400 Subject: [PATCH 06/15] lv_gpu: fix #1617 by renaming internal macros This avoids conflicts with STM32Cube. --- src/lv_gpu/lv_gpu_stm32_dma2d.c | 12 ++++++------ src/lv_gpu/lv_gpu_stm32_dma2d.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lv_gpu/lv_gpu_stm32_dma2d.c b/src/lv_gpu/lv_gpu_stm32_dma2d.c index 086f27753..9810587dd 100644 --- a/src/lv_gpu/lv_gpu_stm32_dma2d.c +++ b/src/lv_gpu/lv_gpu_stm32_dma2d.c @@ -27,9 +27,9 @@ #endif #if LV_COLOR_DEPTH == 16 - #define DMA2D_COLOR_FORMAT DMA2D_RGB565 + #define LV_DMA2D_COLOR_FORMAT LV_DMA2D_RGB565 #elif LV_COLOR_DEPTH == 32 - #define DMA2D_COLOR_FORMAT DMA2D_ARGB8888 + #define LV_DMA2D_COLOR_FORMAT LV_DMA2D_ARGB8888 #else /*Can't use GPU with other formats*/ #endif @@ -68,7 +68,7 @@ void lv_gpu_stm32_dma2d_init(void) volatile uint32_t temp = RCC->AHB1ENR; /* set output colour mode */ - DMA2D->OPFCCR = DMA2D_COLOR_FORMAT; + DMA2D->OPFCCR = LV_DMA2D_COLOR_FORMAT; } /** @@ -160,7 +160,7 @@ void lv_gpu_stm32_dma2d_copy(lv_color_t * buf, lv_coord_t buf_w, const lv_color_ DMA2D->CR = 0; /* copy output colour mode, this register controls both input and output colour format */ - DMA2D->FGPFCCR = DMA2D_COLOR_FORMAT; + DMA2D->FGPFCCR = LV_DMA2D_COLOR_FORMAT; DMA2D->FGMAR = (uint32_t)map; DMA2D->FGOR = map_w - copy_w; DMA2D->OMAR = (uint32_t)buf; @@ -189,11 +189,11 @@ void lv_gpu_stm32_dma2d_blend(lv_color_t * buf, lv_coord_t buf_w, const lv_color invalidate_cache(); DMA2D->CR = 0x20000; - DMA2D->BGPFCCR = DMA2D_COLOR_FORMAT; + DMA2D->BGPFCCR = LV_DMA2D_COLOR_FORMAT; DMA2D->BGMAR = (uint32_t)buf; DMA2D->BGOR = buf_w - copy_w; - DMA2D->FGPFCCR = (uint32_t)DMA2D_COLOR_FORMAT + DMA2D->FGPFCCR = (uint32_t)LV_DMA2D_COLOR_FORMAT /* alpha mode 2, replace with foreground * alpha value */ | (2 << DMA2D_FGPFCCR_AM_Pos) /* alpha value */ diff --git a/src/lv_gpu/lv_gpu_stm32_dma2d.h b/src/lv_gpu/lv_gpu_stm32_dma2d.h index d3da2a846..9f244a603 100644 --- a/src/lv_gpu/lv_gpu_stm32_dma2d.h +++ b/src/lv_gpu/lv_gpu_stm32_dma2d.h @@ -20,11 +20,11 @@ extern "C" { * DEFINES *********************/ -#define DMA2D_ARGB8888 0 -#define DMA2D_RGB888 1 -#define DMA2D_RGB565 2 -#define DMA2D_ARGB1555 3 -#define DMA2D_ARGB4444 4 +#define LV_DMA2D_ARGB8888 0 +#define LV_DMA2D_RGB888 1 +#define LV_DMA2D_RGB565 2 +#define LV_DMA2D_ARGB1555 3 +#define LV_DMA2D_ARGB4444 4 /********************** * TYPEDEFS From d0db0bab5cb5d21c785af4145ea602c5bb7e0795 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 28 Jun 2020 20:10:05 +0200 Subject: [PATCH 07/15] add Arduino library files --- library.properties | 10 ++++++++++ src/lvgl.h | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 library.properties create mode 100644 src/lvgl.h diff --git a/library.properties b/library.properties new file mode 100644 index 000000000..9c8c48826 --- /dev/null +++ b/library.properties @@ -0,0 +1,10 @@ +name=lvgl +version=7.0.2 +author=kisvegabor +maintainer=Pavel Brychta +sentence=Full-featured Graphics Library for Embedded Systems +paragraph=Powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash). +category=Display +url=https://lvgl.io +architectures=* +includes=lvgl.h diff --git a/src/lvgl.h b/src/lvgl.h new file mode 100644 index 000000000..77dca2bec --- /dev/null +++ b/src/lvgl.h @@ -0,0 +1,39 @@ +/** + * @file lvgl.h + * This file exists only to be compatible with Arduino's library structure + */ + +#ifndef LVGL_SRC_H +#define LVGL_SRC_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ + +#include "../lvgl.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} +#endif + +#endif /*LVGL_SRC_H*/ From 069e24bdb294f27cc45c50497b05b5377d9f16d7 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 28 Jun 2020 20:37:32 +0200 Subject: [PATCH 08/15] add examples folder with arduio examples and move porting folder there --- .../arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino | 119 ++++++++++++++++++ examples/arduino/ESP32_TFT_eSPI/README.md | 44 +++++++ examples/arduino/README.md | 37 ++++++ .../porting}/lv_port_disp_template.c | 0 .../porting}/lv_port_disp_template.h | 0 .../porting}/lv_port_fs_template.c | 0 .../porting}/lv_port_fs_template.h | 0 .../porting}/lv_port_indev_template.c | 0 .../porting}/lv_port_indev_template.h | 0 library.properties | 10 -- lv_conf_template.h | 4 +- src/lv_conf_internal.h | 4 +- 12 files changed, 204 insertions(+), 14 deletions(-) create mode 100644 examples/arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino create mode 100644 examples/arduino/ESP32_TFT_eSPI/README.md create mode 100644 examples/arduino/README.md rename {porting => examples/porting}/lv_port_disp_template.c (100%) rename {porting => examples/porting}/lv_port_disp_template.h (100%) rename {porting => examples/porting}/lv_port_fs_template.c (100%) rename {porting => examples/porting}/lv_port_fs_template.h (100%) rename {porting => examples/porting}/lv_port_indev_template.c (100%) rename {porting => examples/porting}/lv_port_indev_template.h (100%) delete mode 100644 library.properties diff --git a/examples/arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino b/examples/arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino new file mode 100644 index 000000000..4e777c19e --- /dev/null +++ b/examples/arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino @@ -0,0 +1,119 @@ +#include +#include + +TFT_eSPI tft = TFT_eSPI(); /* TFT instance */ +static lv_disp_buf_t disp_buf; +static lv_color_t buf[LV_HOR_RES_MAX * 10]; + +#if USE_LV_LOG != 0 +/* Serial debugging */ +void my_print(lv_log_level_t level, const char * file, uint32_t line, const char * dsc) +{ + + Serial.printf("%s@%d->%s\r\n", file, line, dsc); + Serial.flush(); +} +#endif + +/* Display flushing */ +void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) +{ + uint32_t w = (area->x2 - area->x1 + 1); + uint32_t h = (area->y2 - area->y1 + 1); + + tft.startWrite(); + tft.setAddrWindow(area->x1, area->y1, w, h); + tft.pushColors(&color_p->full, w * h, true); + tft.endWrite(); + + lv_disp_flush_ready(disp); +} + +/*Read the touchpad*/ +bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) +{ + uint16_t touchX, touchY; + + bool touched = tft.getTouch(&touchX, &touchY, 600); + + if(!touched) + { + data->state = LV_INDEV_STATE_REL; + return false; + } + else + { + data->state = LV_INDEV_STATE_PR; + } + + if(touchX>screenWidth || touchY > screenHeight) + { + Serial.println("Y or y outside of expected parameters.."); + Serial.print("y:"); + Serial.print(touchX); + Serial.print(" x:"); + Serial.print(touchY); + } + else + { + /*Set the coordinates*/ + data->point.x = touchX; + data->point.y = touchY; + + Serial.print("Data x"); + Serial.println(touchX); + + Serial.print("Data y"); + Serial.println(touchY); + + } + + return false; /*Return `false` because we are not buffering and no more data to read*/ +} + +void setup() +{ + Serial.begin(115200); /* prepare for possible serial debug */ + + lv_init(); + +#if USE_LV_LOG != 0 + lv_log_register_print_cb(my_print); /* register print function for debugging */ +#endif + + tft.begin(); /* TFT init */ + tft.setRotation(1); /* Landscape orientation */ + + uint16_t calData[5] = { 275, 3620, 264, 3532, 1 }; + tft.setTouch(calData); + + lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10); + + /*Initialize the display*/ + lv_disp_drv_t disp_drv; + lv_disp_drv_init(&disp_drv); + disp_drv.hor_res = 320; + disp_drv.ver_res = 240; + disp_drv.flush_cb = my_disp_flush; + disp_drv.buffer = &disp_buf; + lv_disp_drv_register(&disp_drv); + + /*Initialize the (dummy) input device driver*/ + lv_indev_drv_t indev_drv; + lv_indev_drv_init(&indev_drv); + indev_drv.type = LV_INDEV_TYPE_POINTER; + indev_drv.read_cb = my_touchpad_read; + lv_indev_drv_register(&indev_drv); + + /* Try an example from the lv_examples repository + * https://github.com/lvgl/lv_examples*/ + lv_ex_btn_1(); +} + + +void loop() +{ + + lv_task_handler(); /* let the GUI do its work */ + delay(5); +} diff --git a/examples/arduino/ESP32_TFT_eSPI/README.md b/examples/arduino/ESP32_TFT_eSPI/README.md new file mode 100644 index 000000000..10f583d42 --- /dev/null +++ b/examples/arduino/ESP32_TFT_eSPI/README.md @@ -0,0 +1,44 @@ +# Example for lv_arduino using a slider + +This example has the screen set to 320x480 (ILI9488), change this by altering the following lines in the main ino file: + +```C +int screenWidth = 480; +int screenHeight = 320; +``` + +## Backlight + +Change pin 32 to your preferred backlight pin using a PNP transistor (2N3906) or remove the following code and connect directly to +ve: + +```C + ledcSetup(10, 5000/*freq*/, 10 /*resolution*/); + ledcAttachPin(32, 10); + analogReadResolution(10); + ledcWrite(10,768); +``` + +## Theme selection + +Change the following to change the theme: + +```C + lv_theme_t * th = lv_theme_night_init(210, NULL); //Set a HUE value and a Font for the Night Theme + lv_theme_set_current(th); +``` + +## Calibration + +This is using the bodmer tft_espi driver for touch. To correctly set the calibration load the calibration sketch and replace the following with your values: + +```C +uint16_t calData[5] = { 275, 3620, 264, 3532, 1 }; +``` + +## Screen rotation + +Check the following if you need to alter your screen rotation: + +```C + tft.setRotation(3); +``` diff --git a/examples/arduino/README.md b/examples/arduino/README.md new file mode 100644 index 000000000..b6a764c9e --- /dev/null +++ b/examples/arduino/README.md @@ -0,0 +1,37 @@ +# LVGL Arduino examples + +LVGL can be installed via Arduino IDE Library Manager or as an .ZIP library. +It will install [lv_exmaples](https://github.com/lvgl/lv_examples) which contains a lot of examples and demos to try LVGL. + +## Example + +There are simple examples which use the [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) library as a TFT driver to simplify testing. +To get all this to work you have to setup TFT_eSPI to work with your TFT display type via editing the `User_Setup.h` file in TFT_eSPI library folder, or by selecting your own configurtion in the `User_Setup_Select.h` file in TFT_eSPI library folder. + +LVGL library has its own configuration file called `lv_conf.h`. When LVGL is installed to followings needs to be done to configure it: +1. Go to directory of the installed Arduno libraries +2. Go to `lvgl` and copy `lv_conf_template.h` as `lvgl.h` next to the `lvgl` folder. +3. Open `lv_conf.h` and change the first `#if 0` to `#if 1` +4. Set the resolution of your display in `LV_HOR_RES_MAX` and `LV_VER_RES_MAX` +5. Set the color depth of you display in `LV_COLOR_DEPTH` +6. Set `LV_TICK_CUSTOM 1` + +## Debugging + +In case of trouble there are debug informations inside LVGL. In the `ESP32_TFT_eSPI` example there is `my_print` method, which allow to send this debug informations to the serial interface. To enable this feature you have to edit `lv_conf.h` file and enable logging in section `log settings`: + +```c +/*Log settings*/ +#define USE_LV_LOG 1 /*Enable/disable the log module*/ +#if LV_USE_LOG +/* How important log should be added: + * LV_LOG_LEVEL_TRACE A lot of logs to give detailed information + * LV_LOG_LEVEL_INFO Log important events + * LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem + * LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail + * LV_LOG_LEVEL_NONE Do not log anything + */ +# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN +``` + +After enabling log module and setting LV_LOG_LEVEL accordingly the output log is sent to the `Serial` port @ 115200 Bd. diff --git a/porting/lv_port_disp_template.c b/examples/porting/lv_port_disp_template.c similarity index 100% rename from porting/lv_port_disp_template.c rename to examples/porting/lv_port_disp_template.c diff --git a/porting/lv_port_disp_template.h b/examples/porting/lv_port_disp_template.h similarity index 100% rename from porting/lv_port_disp_template.h rename to examples/porting/lv_port_disp_template.h diff --git a/porting/lv_port_fs_template.c b/examples/porting/lv_port_fs_template.c similarity index 100% rename from porting/lv_port_fs_template.c rename to examples/porting/lv_port_fs_template.c diff --git a/porting/lv_port_fs_template.h b/examples/porting/lv_port_fs_template.h similarity index 100% rename from porting/lv_port_fs_template.h rename to examples/porting/lv_port_fs_template.h diff --git a/porting/lv_port_indev_template.c b/examples/porting/lv_port_indev_template.c similarity index 100% rename from porting/lv_port_indev_template.c rename to examples/porting/lv_port_indev_template.c diff --git a/porting/lv_port_indev_template.h b/examples/porting/lv_port_indev_template.h similarity index 100% rename from porting/lv_port_indev_template.h rename to examples/porting/lv_port_indev_template.h diff --git a/library.properties b/library.properties deleted file mode 100644 index 9c8c48826..000000000 --- a/library.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=lvgl -version=7.0.2 -author=kisvegabor -maintainer=Pavel Brychta -sentence=Full-featured Graphics Library for Embedded Systems -paragraph=Powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash). -category=Display -url=https://lvgl.io -architectures=* -includes=lvgl.h diff --git a/lv_conf_template.h b/lv_conf_template.h index f4cd80800..945761c86 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -268,8 +268,8 @@ typedef void * lv_img_decoder_user_data_t; * It removes the need to manually update the tick with `lv_tick_inc`) */ #define LV_TICK_CUSTOM 0 #if LV_TICK_CUSTOM == 1 -#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/ -#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/ +#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ +#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ #endif /*LV_TICK_CUSTOM*/ typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/ diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 8b389a355..d6c9163b6 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -391,10 +391,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #endif #if LV_TICK_CUSTOM == 1 #ifndef LV_TICK_CUSTOM_INCLUDE -#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/ +#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the sys time function*/ #endif #ifndef LV_TICK_CUSTOM_SYS_TIME_EXPR -#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/ +#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current sys time in ms*/ #endif #endif /*LV_TICK_CUSTOM*/ From bae04005d33627547efb4c6964656aa2eebf4225 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 29 Jun 2020 20:46:49 +0200 Subject: [PATCH 09/15] update old function name in comment --- src/lv_widgets/lv_textarea.c | 2 +- src/lv_widgets/lv_textarea.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index c8bfc65da..bfdc5af26 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -221,7 +221,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy) /** * Insert a character to the current cursor position. - * To add a wide char, e.g. 'Á' use `lv_txt_encoded_conv_wc('Á')` + * To add a wide char, e.g. 'Á' use `_lv_txt_encoded_conv_wc('Á')` * @param ta pointer to a text area object * @param c a character (e.g. 'a') */ diff --git a/src/lv_widgets/lv_textarea.h b/src/lv_widgets/lv_textarea.h index 9f07749fe..49cfc9b7d 100644 --- a/src/lv_widgets/lv_textarea.h +++ b/src/lv_widgets/lv_textarea.h @@ -106,7 +106,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy); /** * Insert a character to the current cursor position. - * To add a wide char, e.g. 'Á' use `lv_txt_encoded_conv_wc('Á')` + * To add a wide char, e.g. 'Á' use `_lv_txt_encoded_conv_wc('Á')` * @param ta pointer to a text area object * @param c a character (e.g. 'a') */ From 6d1da27b3cd07b29fa13af2c78074f7f075fd13b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 30 Jun 2020 09:43:58 +0200 Subject: [PATCH 10/15] Create merge-to-dev.yml --- .github/workflows/merge-to-dev.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/merge-to-dev.yml diff --git a/.github/workflows/merge-to-dev.yml b/.github/workflows/merge-to-dev.yml new file mode 100644 index 000000000..997bb5d2e --- /dev/null +++ b/.github/workflows/merge-to-dev.yml @@ -0,0 +1,17 @@ +name: Merge master branch to dev +on: + push: + branches: + - 'master' +jobs: + merge-branch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Merge to dev branch + uses: devmasx/merge-branch@v1.1.0 + with: + type: now + target_branch: 'dev' + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From 86f74e3da2908fac67deb7d774aeac59d5899b67 Mon Sep 17 00:00:00 2001 From: xiaogangly <67666754+xiaogangly@users.noreply.github.com> Date: Wed, 1 Jul 2020 15:26:37 +0800 Subject: [PATCH 11/15] Fix a memory leak bug in function "lv_objmask_remove_mask" . There is a little memory leak When you call function "lv_objmask_remove_mask" to remove a specified mask. It's need free the memory of list's node. --- src/lv_widgets/lv_objmask.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lv_widgets/lv_objmask.c b/src/lv_widgets/lv_objmask.c index e78b1227d..2c817fb17 100644 --- a/src/lv_widgets/lv_objmask.c +++ b/src/lv_widgets/lv_objmask.c @@ -171,6 +171,7 @@ void lv_objmask_remove_mask(lv_obj_t * objmask, lv_objmask_mask_t * mask) else { lv_mem_free(mask->param); _lv_ll_remove(&ext->mask_ll, mask); + lv_mem_free(mask); } lv_obj_invalidate(objmask); From 6b246b2fed308a83d09a425d726cc1a698ba7f0c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 1 Jul 2020 10:53:23 +0200 Subject: [PATCH 12/15] fix default theme colors --- lv_conf_template.h | 4 ++-- src/lv_conf_internal.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lv_conf_template.h b/lv_conf_template.h index 945761c86..828413eab 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -428,8 +428,8 @@ typedef void * lv_font_user_data_t; #define LV_THEME_DEFAULT_INCLUDE /*Include a header for the init. function*/ #define LV_THEME_DEFAULT_INIT lv_theme_material_init -#define LV_THEME_DEFAULT_COLOR_PRIMARY LV_COLOR_RED -#define LV_THEME_DEFAULT_COLOR_SECONDARY LV_COLOR_BLUE +#define LV_THEME_DEFAULT_COLOR_PRIMARY lv_color_hex(0x01a2b1) +#define LV_THEME_DEFAULT_COLOR_SECONDARY lv_color_hex(0x44d1b6) #define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT #define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_16 #define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_16 diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index d6c9163b6..ef86888a8 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -391,10 +391,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #endif #if LV_TICK_CUSTOM == 1 #ifndef LV_TICK_CUSTOM_INCLUDE -#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the sys time function*/ +#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ #endif #ifndef LV_TICK_CUSTOM_SYS_TIME_EXPR -#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current sys time in ms*/ +#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ #endif #endif /*LV_TICK_CUSTOM*/ @@ -638,10 +638,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #define LV_THEME_DEFAULT_INIT lv_theme_material_init #endif #ifndef LV_THEME_DEFAULT_COLOR_PRIMARY -#define LV_THEME_DEFAULT_COLOR_PRIMARY LV_COLOR_RED +#define LV_THEME_DEFAULT_COLOR_PRIMARY lv_color_hex(0x01a2b1) #endif #ifndef LV_THEME_DEFAULT_COLOR_SECONDARY -#define LV_THEME_DEFAULT_COLOR_SECONDARY LV_COLOR_BLUE +#define LV_THEME_DEFAULT_COLOR_SECONDARY lv_color_hex(0x44d1b6) #endif #ifndef LV_THEME_DEFAULT_FLAG #define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT @@ -702,7 +702,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ /* Support bidirectional texts. * Allows mixing Left-to-Right and Right-to-Left texts. - * The direction will be processed according to the Unicode Bidirectional Algorithm: + * The direction will be processed according to the Unicode Bidirectioanl Algorithm: * https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ #ifndef LV_USE_BIDI #define LV_USE_BIDI 0 From 06603a9c8456d91724bf78e0f05befa35b2204b3 Mon Sep 17 00:00:00 2001 From: pete-pjb Date: Wed, 1 Jul 2020 12:13:46 +0100 Subject: [PATCH 13/15] New functions for Check Box and a minor bug fix Remove use of c++ keyword 'new' from function parameter in lv_theme_set_base() function. Add function lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state). Add function lv_checkbox_get_state(const lv_obj_t * cb) Update Change log. --- CHANGELOG.md | 373 ++++++++++++++++++----------------- src/lv_themes/lv_theme.c | 6 +- src/lv_themes/lv_theme.h | 4 +- src/lv_widgets/lv_checkbox.h | 18 ++ 4 files changed, 211 insertions(+), 190 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15ec85db2..fd481633e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,185 +1,188 @@ -# Changelog - -## v7.2.0 (planned on 04.08.2020) -Available in the `dev` branch - -### New features -- Add `LV_CALENDAR_WEEK_STARTS_MONDAY` -- Add `lv_chart_set_x_start_point()` function - Set the index of the x-axis start point in the data array -- Add `lv_chart_set_ext_array()` function - Set an external array of data points to use for the chart -- Add `lv_chart_set_point_id()` function - Set an individual point value in the chart series directly based on index -- Add `lv_chart_get_x_start_point()` function - Get the current index of the x-axis start point in the data array -- Add `lv_chart_get_point_id()` function - Get an individual point value in the chart series directly based on index -- Add `ext_buf_assigned` bit field to `lv_chart_series_t` structure - it's true if external buffer is assigned to series -- Add `lv_chart_set_series_axis()` to assign series to primary or secondary axis -- Add `lv_chart_set_y_range()` to allow setting range of secondary y axis (based on `lv_chart_set_range` but extended with an axis parameter) -- Allow setting different font for the selected text in `lv_roller` -- Add `theme->apply_cb` to replace `theme->apply_xcb` to make it compatible with the MicroPython binding -- Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes -- Add `lv_obj_align_x()` and `lv_obj_align_y()` functions -- Add `lv_obj_align_origo_x()` and `lv_obj_align_origo_y()` functions - -## v7.1.0 (planned on 07.07.2020) -*Available in the `master` branch* - -### New features -- Add `focus_parent` attribute to `lv_obj` -- Allow using buttons in encoder input device -- Add lv_btnmatrix_set/get_align capability -- DMA2D: Remove dependency on ST CubeMX HAL -- Added `max_used` propriety to `lv_mem_monitor_t` struct -- In `lv_init` test if the the strings are UTF-8 encoded. -- Add `user_data` to themes -- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems. - -### Bugfixes -- `lv_img` fix invalidation area when angle or zoom changes -- Update the style handling to support Big endian MCUs -- Change some methods to support big endian hardware. - -## v7.0.2 (16.06.2020) - -### Bugfixes -- `lv_textarea` fix wrong cursor position when clicked after the last character -- Change all text related indices from 16-bit to 32-bit integers throughout whole library. #1545 -- Fix gestures -- Do not call `set_px_cb` for transparent pixel -- Fix list button focus in material theme -- Fix crash when the a text area is cleared with the backspace of a keyboard -- Add version number to `lv_conf_template.h` -- Add log in true double buffering mode with `set_px_cb` -- `lv_dropdown`: fix missing `LV_EVENT_VALUE_CHANGED` event when used with encoder -- `lv_tileview`: fix if not the {0;0} tile is created first -- `lv_debug`: restructure to allow asserting in from `lv_misc` too -- add assert if `_lv_mem_buf_get()` fails -- `lv_textarea`: fix character delete in password mode -- Update `LV_OPA_MIN` and `LV_OPA_MAX` to widen the opacity processed range -- `lv_btnm` fix sending events for hidden buttons -- `lv_gaguge` make `lv_gauge_set_angle_offset` offset the labels and needles too -- Fix typo in the API `scrllable` -> `scrollable` -- `tabview` by default allow auto expanding the page only to right and bottom (#1573) -- fix crash when drawing gradient to the same color -- chart: fix memory leak - -## v7.0.1 (01.06.2020) - -### Bugfixes -- Make the Microptyhon working by adding the required variables as GC_ROOT -- Prefix some internal API functions with `_` to reduce the API of LVGL -- Fix built-in SimSun CJK font -- Fix UTF-8 encoding when `LV_USE_ARABIC_PERSIAN_CHARS` is enabled -- Fix DMA2D usage when 32 bit images directly blended -- Fix lv_roller in infinite mode when used with encoder -- Add `lv_theme_get_color_secondary()` -- Add `LV_COLOR_MIX_ROUND_OFS` to adjust color mixing to make it compatible with the GPU -- Improve DMA2D blending -- Remove memcpy from `lv_ll` (caused issues with some optimization settings) -- `lv_chart` fix X tick drawing -- Fix vertical dashed line drawing -- Some additonal minor fixes and formattings - -## v7.0.0 (18.05.2020) - -### Documentation -The docs for v7 is available at https://docs.littlevgl.com/v7/en/html/index.html - -### Legal changes - -The name of the project is changed to LVGL and the new website is on https://lvgl.io - -LVGL remains free under the same conditions (MIT license) and a company is created to manage LVGL and offer services. - - -### New drawing system -Complete rework of LVGL's draw engine to use "masks" for more advanced and higher quality graphical effects. -A possible use-case of this system is to remove the overflowing content from the rounded edges. -It also allows drawing perfectly anti-aliased circles, lines, and arcs. -Internally, the drawings happen by defining masks (such as rounded rectangle, line, angle). -When something is drawn the currently active masks can make some pixels transparent. -For example, rectangle borders are drawn by using 2 rectangle masks: one mask removes the inner part and another the outer part. - -The API in this regard remained the same but some new functions were added: -- `lv_img_set_zoom`: set image object's zoom factor -- `lv_img_set_angle`: set image object's angle without using canvas -- `lv_img_set_pivot`: set the pivot point of rotation - - -The new drawing engine brought new drawing features too. They are highlighted in the "style" section. - -### New style system -The old style system is replaced with a new more flexible and lightweighted one. -It uses an approach similar to CSS: support cascading styles, inheriting properties and local style properties per object. -As part of these updates, a lot of objects were reworked and the APIs have been changed. - -- more shadows options: *offset* and *spread* -- gradient stop position to shift the gradient area and horizontal gradient -- `LV_BLEND_MODE_NORMAL/ADDITIVE/SUBTRACTIVE` blending modes -- *clip corner*: crop the content on the rounded corners -- *text underline* and *strikethrough* -- dashed vertical and horizontal lines (*dash gap*, *dash_width*) -- *outline*: a border-like part drawn out of the background. Can have spacing to the background. -- *pattern*: display and image in the middle of the background or repeat it -- *value* display a text which is stored in the style. It can be used e.g. as a lighweighted text on buttons too. -- *margin*: similar to *padding* but used to keep space outside of the object - -Read the [Style](https://docs.littlevgl.com/v7/en/html/overview/style.html) section of the documentation to learn how the new styles system works. - -### GPU integration -To better utilize GPUs, from this version GPU usage can be integrated into LVGL. In `lv_conf.h` any supported GPUs can be enabled with a single configuration option. - -Right now, only ST's DMA2D (Chrom-ART) is integrated. More will in the upcoming releases. - -### Renames -The following object types are renamed: -- sw -> switch -- ta -> textarea -- cb -> checkbox -- lmeter -> linemeter -- mbox -> msgbox -- ddlist -> dropdown -- btnm -> btnmatrix -- kb -> keyboard -- preload -> spinner -- lv_objx folder -> lv_widgets -- LV_FIT_FILL -> LV_FIT_PARENT -- LV_FIT_FLOOD -> LV_FLOOD_MAX -- LV_LAYOUT_COL_L/M/R -> LV_LAYOUT_COLUMN_LEFT/MID/RIGHT -- LV_LAYOUT_ROW_T/M/B -> LV_LAYOUT_ROW_TOP/MID/BOTTOM - -### Reworked and improved object -- `dropdown`: Completely reworked. Now creates a separate list when opened and can be dropped to down/up/left/right. -- `label`: `body_draw` is removed, instead, if its style has a visible background/border/shadow etc it will be drawn. Padding really makes the object larger (not just virtually as before) -- `arc`: can draw bacground too. -- `btn`: doesn't store styles for each state because it's done naturally in the new style system. -- `calendar`: highlight the pressed datum. The used styles are changed: use `LV_CALENDAR_PART_DATE` normal for normal dates, checked for highlighted, focused for today, pressed for the being pressed. (checked+pressed, focused+pressed also work) -- `chart`: only has `LINE` and `COLUMN` types because with new styles all the others can be described. LV_CHART_PART_SERIES sets the style of the series. bg_opa > 0 draws an area in LINE mode. `LV_CHART_PART_SERIES_BG` also added to set a different style for the series area. Padding in `LV_CHART_PART_BG` makes the series area smaller, and it ensures space for axis labels/numbers. -- `linemeter`, `gauge`: can have background if the related style properties are set. Padding makes the scale/lines smaller. scale_border_width and scale_end_border_width allow to draw an arc on the outer part of the scale lines. -- `gauge`: `lv_gauge_set_needle_img` allows use image as needle -- `canvas`: allow drawing to true color alpha and alpha only canvas, add `lv_canvas_blur_hor/ver` and rename `lv_canvas_rotate` to `lv_canvas_transform` -- `textarea`: If available in the font use bullet (`U+2022`) character in text area password - -### New object types -- `lv_objmask`: masks can be added to it. The children will be masked accordingly. - -### Others -- Change the built-in fonts to [Montserrat](https://fonts.google.com/specimen/Montserrat) and add built-in fonts from 12 px to 48 px for every 2nd size. -- Add example CJK and Arabic/Persian/Hebrew built-in font -- Add ° and "bullet" to the built-in fonts -- Add Arabic/Persian script support: change the character according to its position in the text. -- Add `playback_time` to animations. -- Add `repeat_count` to animations instead of the current "repeat forever". -- Replace `LV_LAYOUT_PRETTY` with `LV_LAYOUT_PRETTY_TOP/MID/BOTTOM` - -### Demos -- [lv_examples](https://github.com/littlevgl/lv_examples) was reworked and new examples and demos were added - -### New release policy -- Maintain this Changelog for every release -- Save old major version in new branches. E.g. `release/v6` -- Merge new features and fixes directly into `master` and release a patch or minor releases every 2 weeks. - -### Migrating from v6 to v7 -- First and foremost, create a new `lv_conf.h` based on `lv_conf_templ.h`. -- To try the new version it suggested using a simulator project and see the examples. -- If you have a running project, the most difficult part of the migration is updating to the new style system. Unfortunately, there is no better way than manually updating to the new format. -- The other parts are mainly minor renames and refactoring as described above. +# Changelog + +## v7.2.0 (planned on 04.08.2020) +Available in the `dev` branch + +### New features +- Add `LV_CALENDAR_WEEK_STARTS_MONDAY` +- Add `lv_chart_set_x_start_point()` function - Set the index of the x-axis start point in the data array +- Add `lv_chart_set_ext_array()` function - Set an external array of data points to use for the chart +- Add `lv_chart_set_point_id()` function - Set an individual point value in the chart series directly based on index +- Add `lv_chart_get_x_start_point()` function - Get the current index of the x-axis start point in the data array +- Add `lv_chart_get_point_id()` function - Get an individual point value in the chart series directly based on index +- Add `ext_buf_assigned` bit field to `lv_chart_series_t` structure - it's true if external buffer is assigned to series +- Add `lv_chart_set_series_axis()` to assign series to primary or secondary axis +- Add `lv_chart_set_y_range()` to allow setting range of secondary y axis (based on `lv_chart_set_range` but extended with an axis parameter) +- Allow setting different font for the selected text in `lv_roller` +- Add `theme->apply_cb` to replace `theme->apply_xcb` to make it compatible with the MicroPython binding +- Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes +- Add `lv_obj_align_x()` and `lv_obj_align_y()` functions +- Add `lv_obj_align_origo_x()` and `lv_obj_align_origo_y()` functions + +## v7.1.0 (planned on 07.07.2020) +*Available in the `master` branch* + +### New features +- Add `focus_parent` attribute to `lv_obj` +- Allow using buttons in encoder input device +- Add lv_btnmatrix_set/get_align capability +- DMA2D: Remove dependency on ST CubeMX HAL +- Added `max_used` propriety to `lv_mem_monitor_t` struct +- In `lv_init` test if the the strings are UTF-8 encoded. +- Add `user_data` to themes +- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems. +- Add inline function lv_checkbox_get_state(const lv_obj_t * cb) to extend the checkbox functionality. +- Add inline function lv_checkbox_set_state(const lv_obj_t * cb, lv_btn_state_t state ) to extend the checkbox functionality. + +### Bugfixes +- `lv_img` fix invalidation area when angle or zoom changes +- Update the style handling to support Big endian MCUs +- Change some methods to support big endian hardware. +- remove use of c++ keyword 'new' in parameter of function lv_theme_set_base(). + +## v7.0.2 (16.06.2020) + +### Bugfixes +- `lv_textarea` fix wrong cursor position when clicked after the last character +- Change all text related indices from 16-bit to 32-bit integers throughout whole library. #1545 +- Fix gestures +- Do not call `set_px_cb` for transparent pixel +- Fix list button focus in material theme +- Fix crash when the a text area is cleared with the backspace of a keyboard +- Add version number to `lv_conf_template.h` +- Add log in true double buffering mode with `set_px_cb` +- `lv_dropdown`: fix missing `LV_EVENT_VALUE_CHANGED` event when used with encoder +- `lv_tileview`: fix if not the {0;0} tile is created first +- `lv_debug`: restructure to allow asserting in from `lv_misc` too +- add assert if `_lv_mem_buf_get()` fails +- `lv_textarea`: fix character delete in password mode +- Update `LV_OPA_MIN` and `LV_OPA_MAX` to widen the opacity processed range +- `lv_btnm` fix sending events for hidden buttons +- `lv_gaguge` make `lv_gauge_set_angle_offset` offset the labels and needles too +- Fix typo in the API `scrllable` -> `scrollable` +- `tabview` by default allow auto expanding the page only to right and bottom (#1573) +- fix crash when drawing gradient to the same color +- chart: fix memory leak + +## v7.0.1 (01.06.2020) + +### Bugfixes +- Make the Microptyhon working by adding the required variables as GC_ROOT +- Prefix some internal API functions with `_` to reduce the API of LVGL +- Fix built-in SimSun CJK font +- Fix UTF-8 encoding when `LV_USE_ARABIC_PERSIAN_CHARS` is enabled +- Fix DMA2D usage when 32 bit images directly blended +- Fix lv_roller in infinite mode when used with encoder +- Add `lv_theme_get_color_secondary()` +- Add `LV_COLOR_MIX_ROUND_OFS` to adjust color mixing to make it compatible with the GPU +- Improve DMA2D blending +- Remove memcpy from `lv_ll` (caused issues with some optimization settings) +- `lv_chart` fix X tick drawing +- Fix vertical dashed line drawing +- Some additonal minor fixes and formattings + +## v7.0.0 (18.05.2020) + +### Documentation +The docs for v7 is available at https://docs.littlevgl.com/v7/en/html/index.html + +### Legal changes + +The name of the project is changed to LVGL and the new website is on https://lvgl.io + +LVGL remains free under the same conditions (MIT license) and a company is created to manage LVGL and offer services. + + +### New drawing system +Complete rework of LVGL's draw engine to use "masks" for more advanced and higher quality graphical effects. +A possible use-case of this system is to remove the overflowing content from the rounded edges. +It also allows drawing perfectly anti-aliased circles, lines, and arcs. +Internally, the drawings happen by defining masks (such as rounded rectangle, line, angle). +When something is drawn the currently active masks can make some pixels transparent. +For example, rectangle borders are drawn by using 2 rectangle masks: one mask removes the inner part and another the outer part. + +The API in this regard remained the same but some new functions were added: +- `lv_img_set_zoom`: set image object's zoom factor +- `lv_img_set_angle`: set image object's angle without using canvas +- `lv_img_set_pivot`: set the pivot point of rotation + + +The new drawing engine brought new drawing features too. They are highlighted in the "style" section. + +### New style system +The old style system is replaced with a new more flexible and lightweighted one. +It uses an approach similar to CSS: support cascading styles, inheriting properties and local style properties per object. +As part of these updates, a lot of objects were reworked and the APIs have been changed. + +- more shadows options: *offset* and *spread* +- gradient stop position to shift the gradient area and horizontal gradient +- `LV_BLEND_MODE_NORMAL/ADDITIVE/SUBTRACTIVE` blending modes +- *clip corner*: crop the content on the rounded corners +- *text underline* and *strikethrough* +- dashed vertical and horizontal lines (*dash gap*, *dash_width*) +- *outline*: a border-like part drawn out of the background. Can have spacing to the background. +- *pattern*: display and image in the middle of the background or repeat it +- *value* display a text which is stored in the style. It can be used e.g. as a lighweighted text on buttons too. +- *margin*: similar to *padding* but used to keep space outside of the object + +Read the [Style](https://docs.littlevgl.com/v7/en/html/overview/style.html) section of the documentation to learn how the new styles system works. + +### GPU integration +To better utilize GPUs, from this version GPU usage can be integrated into LVGL. In `lv_conf.h` any supported GPUs can be enabled with a single configuration option. + +Right now, only ST's DMA2D (Chrom-ART) is integrated. More will in the upcoming releases. + +### Renames +The following object types are renamed: +- sw -> switch +- ta -> textarea +- cb -> checkbox +- lmeter -> linemeter +- mbox -> msgbox +- ddlist -> dropdown +- btnm -> btnmatrix +- kb -> keyboard +- preload -> spinner +- lv_objx folder -> lv_widgets +- LV_FIT_FILL -> LV_FIT_PARENT +- LV_FIT_FLOOD -> LV_FLOOD_MAX +- LV_LAYOUT_COL_L/M/R -> LV_LAYOUT_COLUMN_LEFT/MID/RIGHT +- LV_LAYOUT_ROW_T/M/B -> LV_LAYOUT_ROW_TOP/MID/BOTTOM + +### Reworked and improved object +- `dropdown`: Completely reworked. Now creates a separate list when opened and can be dropped to down/up/left/right. +- `label`: `body_draw` is removed, instead, if its style has a visible background/border/shadow etc it will be drawn. Padding really makes the object larger (not just virtually as before) +- `arc`: can draw bacground too. +- `btn`: doesn't store styles for each state because it's done naturally in the new style system. +- `calendar`: highlight the pressed datum. The used styles are changed: use `LV_CALENDAR_PART_DATE` normal for normal dates, checked for highlighted, focused for today, pressed for the being pressed. (checked+pressed, focused+pressed also work) +- `chart`: only has `LINE` and `COLUMN` types because with new styles all the others can be described. LV_CHART_PART_SERIES sets the style of the series. bg_opa > 0 draws an area in LINE mode. `LV_CHART_PART_SERIES_BG` also added to set a different style for the series area. Padding in `LV_CHART_PART_BG` makes the series area smaller, and it ensures space for axis labels/numbers. +- `linemeter`, `gauge`: can have background if the related style properties are set. Padding makes the scale/lines smaller. scale_border_width and scale_end_border_width allow to draw an arc on the outer part of the scale lines. +- `gauge`: `lv_gauge_set_needle_img` allows use image as needle +- `canvas`: allow drawing to true color alpha and alpha only canvas, add `lv_canvas_blur_hor/ver` and rename `lv_canvas_rotate` to `lv_canvas_transform` +- `textarea`: If available in the font use bullet (`U+2022`) character in text area password + +### New object types +- `lv_objmask`: masks can be added to it. The children will be masked accordingly. + +### Others +- Change the built-in fonts to [Montserrat](https://fonts.google.com/specimen/Montserrat) and add built-in fonts from 12 px to 48 px for every 2nd size. +- Add example CJK and Arabic/Persian/Hebrew built-in font +- Add ° and "bullet" to the built-in fonts +- Add Arabic/Persian script support: change the character according to its position in the text. +- Add `playback_time` to animations. +- Add `repeat_count` to animations instead of the current "repeat forever". +- Replace `LV_LAYOUT_PRETTY` with `LV_LAYOUT_PRETTY_TOP/MID/BOTTOM` + +### Demos +- [lv_examples](https://github.com/littlevgl/lv_examples) was reworked and new examples and demos were added + +### New release policy +- Maintain this Changelog for every release +- Save old major version in new branches. E.g. `release/v6` +- Merge new features and fixes directly into `master` and release a patch or minor releases every 2 weeks. + +### Migrating from v6 to v7 +- First and foremost, create a new `lv_conf.h` based on `lv_conf_templ.h`. +- To try the new version it suggested using a simulator project and see the examples. +- If you have a running project, the most difficult part of the migration is updating to the new style system. Unfortunately, there is no better way than manually updating to the new format. +- The other parts are mainly minor renames and refactoring as described above. diff --git a/src/lv_themes/lv_theme.c b/src/lv_themes/lv_theme.c index d990912db..eddeebd83 100644 --- a/src/lv_themes/lv_theme.c +++ b/src/lv_themes/lv_theme.c @@ -98,12 +98,12 @@ void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy) * Set a base theme for a theme. * The styles from the base them will be added before the styles of the current theme. * Arbitrary long chain of themes can be created by setting base themes. - * @param new pointer to theme which base should be set + * @param new_theme pointer to theme which base should be set * @param base pointer to the base theme */ -void lv_theme_set_base(lv_theme_t * new, lv_theme_t * base) +void lv_theme_set_base(lv_theme_t * new_theme, lv_theme_t * base) { - new->base = base; + new_theme->base = base; } /** diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index 788766726..8297b0b53 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -201,10 +201,10 @@ void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy); * Set a base theme for a theme. * The styles from the base them will be added before the styles of the current theme. * Arbitrary long chain of themes can be created by setting base themes. - * @param new pointer to theme which base should be set + * @param new_theme pointer to theme which base should be set * @param base pointer to the base theme */ -void lv_theme_set_base(lv_theme_t * new, lv_theme_t * base); +void lv_theme_set_base(lv_theme_t * new_theme, lv_theme_t * base); /** * Set an apply callback for a theme. diff --git a/src/lv_widgets/lv_checkbox.h b/src/lv_widgets/lv_checkbox.h index 7a1536692..cb083733f 100644 --- a/src/lv_widgets/lv_checkbox.h +++ b/src/lv_widgets/lv_checkbox.h @@ -106,6 +106,15 @@ static inline void lv_checkbox_set_disabled(lv_obj_t * cb) lv_btn_set_state(cb, LV_BTN_STATE_DISABLED); } +/** + * Set the state of a check box + * @param cb pointer to a check box object + * @param state the new state of the check box (from lv_btn_state_t enum) + */ +static inline void lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state) +{ + lv_btn_set_state(cb, state); +} /*===================== * Getter functions *====================*/ @@ -137,6 +146,15 @@ static inline bool lv_checkbox_is_inactive(const lv_obj_t * cb) return lv_btn_get_state(cb) == LV_BTN_STATE_DISABLED ? true : false; } +/** + * Get the current state of a check box + * @param cb pointer to a check box object + * @return the state of the check box (from lv_btn_state_t enum) + */ +static inline lv_btn_state_t lv_checkbox_get_state(const lv_obj_t * cb) +{ + return lv_btn_get_state(cb); +} /********************** * MACROS From ac26442ca6eb42f025ef516aec92c88196112522 Mon Sep 17 00:00:00 2001 From: jbamaral Date: Wed, 1 Jul 2020 10:08:45 -0300 Subject: [PATCH 14/15] Fix lv_textarea_add_char on big endian (#1620) --- CHANGELOG.md | 1 + src/lv_misc/lv_txt.c | 3 ++- src/lv_widgets/lv_textarea.c | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3e542b3d..f31d2b820 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Update the style handling to support Big endian MCUs - Change some methods to support big endian hardware. - Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems. +- Fix inserting chars in text area in big endian hardware. ## v7.0.2 (16.06.2020) diff --git a/src/lv_misc/lv_txt.c b/src/lv_misc/lv_txt.c index c76c486e7..a29a3c158 100644 --- a/src/lv_misc/lv_txt.c +++ b/src/lv_misc/lv_txt.c @@ -534,6 +534,7 @@ static uint32_t lv_txt_unicode_to_utf8(uint32_t letter_uni) */ static uint32_t lv_txt_utf8_conv_wc(uint32_t c) { +#if LV_BIG_ENDIAN_SYSTEM == 0 /*Swap the bytes (UTF-8 is big endian, but the MCUs are little endian)*/ if((c & 0x80) != 0) { uint32_t swapped; @@ -547,7 +548,7 @@ static uint32_t lv_txt_utf8_conv_wc(uint32_t c) } c = swapped; } - +#endif return c; } diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index bfdc5af26..182ac55da 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -231,9 +231,17 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) lv_textarea_ext_t * ext = lv_obj_get_ext_attr(ta); - uint32_t letter_buf[2]; - letter_buf[0] = c; - letter_buf[1] = '\0'; + const char *letter_buf; + + uint32_t u32_buf[2]; + u32_buf[0] = c; + u32_buf[1] = 0; + + letter_buf = (char*)&u32_buf; + +#if LV_BIG_ENDIAN_SYSTEM + if (c != 0) while (*letter_buf == 0) ++letter_buf; +#endif ta_insert_replace = NULL; lv_event_send(ta, LV_EVENT_INSERT, letter_buf); @@ -241,7 +249,7 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) if(ta_insert_replace[0] == '\0') return; /*Drop this text*/ /*Add the replaced text directly it's different from the original*/ - if(strcmp(ta_insert_replace, (char *)letter_buf)) { + if(strcmp(ta_insert_replace, letter_buf)) { lv_textarea_add_text(ta, ta_insert_replace); return; } @@ -272,7 +280,7 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) if(txt[0] == '\0') lv_obj_invalidate(ta); } - lv_label_ins_text(ext->label, ext->cursor.pos, (const char *)letter_buf); /*Insert the character*/ + lv_label_ins_text(ext->label, ext->cursor.pos, letter_buf); /*Insert the character*/ lv_textarea_clear_selection(ta); /*Clear selection*/ if(ext->pwd_mode != 0) { From 1051e3f5a4dfc7ed14f1a64b6920a60180646478 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 1 Jul 2020 15:15:03 +0200 Subject: [PATCH 15/15] roller: fix copy. Closes #1628 --- src/lv_widgets/lv_roller.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 23fe90837..07c89e6c2 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -120,11 +120,16 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy) } /*Copy an existing roller*/ else { + lv_label_create(roller, get_label(copy)); + lv_roller_ext_t * copy_ext = lv_obj_get_ext_attr(copy); lv_roller_set_options(roller, lv_roller_get_options(copy), copy_ext->mode); ext->auto_fit = copy_ext->auto_fit; lv_obj_t * scrl = lv_page_get_scrollable(roller); lv_obj_set_signal_cb(scrl, lv_roller_scrl_signal); + + lv_style_list_copy(&ext->style_sel, ©_ext->style_sel); + lv_obj_refresh_style(roller, LV_STYLE_PROP_ALL); } LV_LOG_INFO("roller created");