From e06201f042c141d97b06e6b031ab4d6cb5c4e03f Mon Sep 17 00:00:00 2001 From: 3096 Date: Fri, 26 Jun 2020 22:27:52 -0700 Subject: [PATCH 1/8] 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 d055944ebb80e45a1d4f3940654cba5343f4cdce Mon Sep 17 00:00:00 2001 From: liangyongxiang Date: Sun, 28 Jun 2020 12:13:39 +0800 Subject: [PATCH 2/8] 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 92027cc06f4dae161d4916eceb0e4b8c434a1b3c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 28 Jun 2020 13:32:40 +0200 Subject: [PATCH 3/8] 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 4/8] 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 5/8] 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 6/8] 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 7/8] 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 8/8] 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}}