From e1afa61128a0a91a306447a9224ca38813da2443 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 2 Feb 2019 04:46:19 +0100 Subject: [PATCH 01/17] multi-disp: inital changes --- lv_hal/lv_hal_disp.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index 131b948cc..fbbadbf7c 100644 --- a/lv_hal/lv_hal_disp.h +++ b/lv_hal/lv_hal_disp.h @@ -33,6 +33,10 @@ extern "C" { * Display Driver structure to be registered by HAL */ typedef struct _disp_drv_t { + lv_coord_t hor_res; + + lv_coord_t ver_res; + /*Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished*/ void (*disp_flush)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p); @@ -59,6 +63,10 @@ typedef struct _disp_drv_t { typedef struct _disp_t { lv_disp_drv_t driver; + lv_area_t inv_buf[32]; + lv_ll_t scr_ll; + lv_obj_t * act_scr; + lv_obj_t * top_scr; struct _disp_t *next; } lv_disp_t; From 2692100bb1a14dc4d306f9fb9402b36624f2606a Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 3 Feb 2019 00:47:50 +0100 Subject: [PATCH 02/17] multi-disp: minor update --- lv_hal/lv_hal_disp.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index fbbadbf7c..15019ef43 100644 --- a/lv_hal/lv_hal_disp.h +++ b/lv_hal/lv_hal_disp.h @@ -67,6 +67,7 @@ typedef struct _disp_t { lv_ll_t scr_ll; lv_obj_t * act_scr; lv_obj_t * top_scr; + uint8_t orientation:2; struct _disp_t *next; } lv_disp_t; From e2e6479fb07d5f88d8dfd6335dea346acc54d7d1 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 7 Feb 2019 19:17:10 +0100 Subject: [PATCH 03/17] multi_disp: add dynamic hor/ver res --- lv_conf_checker.h | 4 +-- lv_core/lv_disp.c | 54 ++++++++++++++++++++++++++++++++++++++++ lv_core/lv_disp.h | 42 +++++++++++++++++++++++++++++++ lv_core/lv_obj.c | 4 +-- lv_core/lv_obj.h | 2 +- lv_core/lv_refr.c | 6 ++--- lv_draw/lv_draw_rbasic.c | 2 +- lv_draw/lv_draw_vbasic.c | 2 +- lv_hal/lv_hal_disp.h | 1 + lv_objx/lv_btnm.c | 2 +- lv_objx/lv_chart.c | 2 +- lv_objx/lv_kb.c | 2 +- lv_objx/lv_mbox.c | 2 +- lv_objx/lv_tabview.c | 4 +-- lv_objx/lv_tileview.c | 6 ++--- lv_objx/lv_win.c | 3 +-- lvgl.h | 1 + 17 files changed, 118 insertions(+), 21 deletions(-) create mode 100644 lv_core/lv_disp.c create mode 100644 lv_core/lv_disp.h diff --git a/lv_conf_checker.h b/lv_conf_checker.h index e4caa9480..10f6a1436 100644 --- a/lv_conf_checker.h +++ b/lv_conf_checker.h @@ -62,10 +62,10 @@ /* Horizontal and vertical resolution of the library.*/ #ifndef LV_HOR_RES -#define LV_HOR_RES (480) +//#define LV_HOR_RES (480) #endif #ifndef LV_VER_RES -#define LV_VER_RES (320) +//#define LV_VER_RES (320) #endif /* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide diff --git a/lv_core/lv_disp.c b/lv_core/lv_disp.c new file mode 100644 index 000000000..d4fc22e25 --- /dev/null +++ b/lv_core/lv_disp.c @@ -0,0 +1,54 @@ +/** + * @file lv_disp.c + * + */ + +/********************* + * INCLUDES + *********************/ +#include "lv_disp.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ + +/********************** + * STATIC VARIABLES + **********************/ + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp) +{ + if(disp == NULL) disp = lv_disp_get_active(); + + if(disp == NULL) return LV_HOR_RES_MAX; + else return disp->driver.hor_res; +} + + +lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp) +{ + if(disp == NULL) disp = lv_disp_get_active(); + + if(disp == NULL) return LV_VER_RES_MAX; + else return disp->driver.ver_res; +} + +/********************** + * STATIC FUNCTIONS + **********************/ diff --git a/lv_core/lv_disp.h b/lv_core/lv_disp.h new file mode 100644 index 000000000..89db388f9 --- /dev/null +++ b/lv_core/lv_disp.h @@ -0,0 +1,42 @@ +/** + * @file lv_disp.h + * + */ + +#ifndef LV_DISP_H +#define LV_DISP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "../lv_hal/lv_hal_disp.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp); +lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp); + +/********************** + * MACROS + **********************/ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*LV_TEMPL_H*/ diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index a58ead8c2..ae8f45178 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -144,8 +144,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) /*Set coordinates to full screen size*/ new_obj->coords.x1 = 0; new_obj->coords.y1 = 0; - new_obj->coords.x2 = LV_HOR_RES - 1; - new_obj->coords.y2 = LV_VER_RES - 1; + new_obj->coords.x2 = lv_disp_get_hor_res(NULL) - 1; + new_obj->coords.y2 = lv_disp_get_ver_res(NULL) - 1; new_obj->ext_size = 0; /*Init realign*/ diff --git a/lv_core/lv_obj.h b/lv_core/lv_obj.h index cfd8a8ac3..7f8f848ab 100644 --- a/lv_core/lv_obj.h +++ b/lv_core/lv_obj.h @@ -33,7 +33,7 @@ extern "C" { *********************/ /*Error check of lv_conf.h*/ -#if LV_HOR_RES == 0 || LV_VER_RES == 0 +#if LV_HOR_RES_MAX == 0 || LV_VER_RES_MAX == 0 #error "LittlevGL: LV_HOR_RES and LV_VER_RES must be greater than 0" #endif diff --git a/lv_core/lv_refr.c b/lv_core/lv_refr.c index d6987832a..98c3a2709 100644 --- a/lv_core/lv_refr.c +++ b/lv_core/lv_refr.c @@ -102,8 +102,8 @@ void lv_inv_area(const lv_area_t * area_p) lv_area_t scr_area; scr_area.x1 = 0; scr_area.y1 = 0; - scr_area.x2 = LV_HOR_RES - 1; - scr_area.y2 = LV_VER_RES - 1; + scr_area.x2 = LV_HOR_RES_MAX - 1; + scr_area.y2 = LV_VER_RES_MAX - 1; lv_area_t com_area; bool suc; @@ -346,7 +346,7 @@ static void lv_refr_area_with_vdb(const lv_area_t * area_p) /*Calculate the max row num*/ lv_coord_t w = lv_area_get_width(area_p); lv_coord_t h = lv_area_get_height(area_p); - lv_coord_t y2 = area_p->y2 >= LV_VER_RES ? y2 = LV_VER_RES - 1 : area_p->y2; + lv_coord_t y2 = area_p->y2 >= lv_disp_get_ver_res(NULL) ? y2 = lv_disp_get_ver_res(NULL) - 1 : area_p->y2; int32_t max_row = (uint32_t) LV_VDB_SIZE / w; diff --git a/lv_draw/lv_draw_rbasic.c b/lv_draw/lv_draw_rbasic.c index 369adf523..647554924 100644 --- a/lv_draw/lv_draw_rbasic.c +++ b/lv_draw/lv_draw_rbasic.c @@ -79,7 +79,7 @@ void lv_rfill(const lv_area_t * cords_p, const lv_area_t * mask_p, union_ok = lv_area_intersect(&masked_area, cords_p, mask_p); } else { lv_area_t scr_area; - lv_area_set(&scr_area, 0, 0, LV_HOR_RES - 1, LV_VER_RES - 1); + lv_area_set(&scr_area, 0, 0, lv_disp_get_hor_res(NULL) - 1, lv_disp_get_ver_res(NULL) - 1); union_ok = lv_area_intersect(&masked_area, cords_p, &scr_area); } diff --git a/lv_draw/lv_draw_vbasic.c b/lv_draw/lv_draw_vbasic.c index c8b2fab55..8ab127856 100644 --- a/lv_draw/lv_draw_vbasic.c +++ b/lv_draw/lv_draw_vbasic.c @@ -147,7 +147,7 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, #if USE_LV_GPU - static lv_color_t color_array_tmp[LV_HOR_RES]; /*Used by 'lv_disp_mem_blend'*/ + static lv_color_t color_array_tmp[LV_HOR_RES_MAX]; /*Used by 'lv_disp_mem_blend'*/ static lv_coord_t last_width = -1; lv_coord_t w = lv_area_get_width(&vdb_rel_a); diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index 15019ef43..e298b4ac8 100644 --- a/lv_hal/lv_hal_disp.h +++ b/lv_hal/lv_hal_disp.h @@ -20,6 +20,7 @@ extern "C" { #include "lv_hal.h" #include "../lv_misc/lv_color.h" #include "../lv_misc/lv_area.h" +#include "../lv_core/lv_obj.h" /********************* * DEFINES diff --git a/lv_objx/lv_btnm.c b/lv_objx/lv_btnm.c index 07e6a72b2..33abbf20c 100644 --- a/lv_objx/lv_btnm.c +++ b/lv_objx/lv_btnm.c @@ -97,7 +97,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new button matrix object*/ if(copy == NULL) { - lv_obj_set_size(new_btnm, LV_HOR_RES / 2, LV_VER_RES / 4); + lv_obj_set_size(new_btnm, LV_DPI * 3, LV_DPI * 2); lv_btnm_set_map(new_btnm, lv_btnm_def_map); /*Set the default styles*/ diff --git a/lv_objx/lv_chart.c b/lv_objx/lv_chart.c index 1dedaa7a4..0904bb91f 100644 --- a/lv_objx/lv_chart.c +++ b/lv_objx/lv_chart.c @@ -90,7 +90,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new chart background object*/ if(copy == NULL) { - lv_obj_set_size(new_chart, LV_HOR_RES / 3, LV_VER_RES / 3); + lv_obj_set_size(new_chart, LV_DPI * 3, LV_DPI * 2); /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); diff --git a/lv_objx/lv_kb.c b/lv_objx/lv_kb.c index 395fc8d5d..d41b5962d 100644 --- a/lv_objx/lv_kb.c +++ b/lv_objx/lv_kb.c @@ -102,7 +102,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new keyboard keyboard*/ if(copy == NULL) { - lv_obj_set_size(new_kb, LV_HOR_RES, LV_VER_RES / 2); + lv_obj_set_size(new_kb, LV_DPI * 3, LV_DPI * 2); lv_obj_align(new_kb, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0); lv_btnm_set_action(new_kb, lv_kb_def_action); lv_btnm_set_map(new_kb, kb_map_lc); diff --git a/lv_objx/lv_mbox.c b/lv_objx/lv_mbox.c index af53ddd4d..ac355d10a 100644 --- a/lv_objx/lv_mbox.c +++ b/lv_objx/lv_mbox.c @@ -91,7 +91,7 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy) lv_cont_set_layout(new_mbox, LV_LAYOUT_COL_M); lv_cont_set_fit(new_mbox, false, true); - lv_obj_set_width(new_mbox, LV_HOR_RES / 2); + lv_obj_set_width(new_mbox, LV_DPI * 2); lv_obj_align(new_mbox, NULL, LV_ALIGN_CENTER, 0, 0); /*Set the default styles*/ diff --git a/lv_objx/lv_tabview.c b/lv_objx/lv_tabview.c index 8b16ec878..c09560fbd 100644 --- a/lv_objx/lv_tabview.c +++ b/lv_objx/lv_tabview.c @@ -106,7 +106,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) ext->tab_name_ptr[0] = ""; ext->tab_cnt = 0; - lv_obj_set_size(new_tabview, LV_HOR_RES, LV_VER_RES); + lv_obj_set_size(new_tabview, LV_DPI * 3, LV_DPI * 2); ext->btns = lv_btnm_create(new_tabview, NULL); lv_obj_set_height(ext->btns, 3 * LV_DPI / 4); @@ -123,7 +123,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) lv_cont_set_fit(ext->content, true, false); lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T); lv_cont_set_style(ext->content, &lv_style_transp_tight); - lv_obj_set_height(ext->content, LV_VER_RES - lv_obj_get_height(ext->btns)); + lv_obj_set_height(ext->content, lv_obj_get_height(new_tabview) - lv_obj_get_height(ext->btns)); lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); /*Set the default styles*/ diff --git a/lv_objx/lv_tileview.c b/lv_objx/lv_tileview.c index c80cfecad..447534f32 100644 --- a/lv_objx/lv_tileview.c +++ b/lv_objx/lv_tileview.c @@ -89,7 +89,7 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new tileview*/ if(copy == NULL) { - lv_obj_set_size(new_tileview, LV_HOR_RES, LV_VER_RES); + lv_obj_set_size(new_tileview, LV_DPI * 3, LV_DPI * 3); lv_obj_set_drag_throw(lv_page_get_scrl(new_tileview), false); lv_page_set_scrl_fit(new_tileview, true, true); /*Set the default styles*/ @@ -506,8 +506,8 @@ static void drag_end_handler(lv_obj_t * tileview) lv_obj_t * scrl = lv_page_get_scrl(tileview); lv_point_t p; - p.x = - (scrl->coords.x1 - LV_HOR_RES / 2); - p.y = - (scrl->coords.y1 - LV_VER_RES / 2); + p.x = - (scrl->coords.x1 - lv_obj_get_width(tileview) / 2); + p.y = - (scrl->coords.y1 - lv_obj_get_height(tileview) / 2); /*From the drag vector (drag throw) predict the end position*/ if(ext->drag_hor) { diff --git a/lv_objx/lv_win.c b/lv_objx/lv_win.c index 3bc968dda..60dfe4784 100644 --- a/lv_objx/lv_win.c +++ b/lv_objx/lv_win.c @@ -70,7 +70,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new window object*/ if(copy == NULL) { - lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES); + lv_obj_set_size(new_win, LV_DPI * 3, LV_DPI * 3); lv_obj_set_pos(new_win, 0, 0); lv_obj_set_style(new_win, &lv_style_pretty); @@ -107,7 +107,6 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy) } lv_obj_set_signal_func(new_win, lv_win_signal); - lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES); } /*Copy an existing object*/ else { diff --git a/lvgl.h b/lvgl.h index 2d0dd560d..6aab3e4e0 100644 --- a/lvgl.h +++ b/lvgl.h @@ -26,6 +26,7 @@ extern "C" { #include "lv_core/lv_lang.h" #include "lv_core/lv_vdb.h" #include "lv_core/lv_refr.h" +#include "lv_core/lv_disp.h" #include "lv_themes/lv_theme.h" From 5b92b4d01bca2f7123a881f2e3e83c31df34f5e9 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 10 Feb 2019 11:06:47 +0100 Subject: [PATCH 04/17] move basic descriptors to lv_disp_t --- lv_core/lv_disp.c | 17 ------- lv_core/lv_disp.h | 2 +- lv_core/lv_indev.c | 45 +++++++++-------- lv_core/lv_obj.c | 103 ++++++++++++++++++++++----------------- lv_core/lv_obj.h | 14 ++---- lv_draw/lv_draw_rbasic.c | 2 +- lv_draw/lv_draw_vbasic.c | 2 +- lv_hal/lv_hal.h | 6 +-- lv_hal/lv_hal_disp.c | 72 ++++++++++++++------------- lv_hal/lv_hal_disp.h | 26 ++++------ lv_hal/lv_hal_indev.c | 36 ++++++-------- lv_hal/lv_hal_indev.h | 16 +++--- lv_misc/lv_gc.h | 9 +--- 13 files changed, 166 insertions(+), 184 deletions(-) diff --git a/lv_core/lv_disp.c b/lv_core/lv_disp.c index d4fc22e25..29861b769 100644 --- a/lv_core/lv_disp.c +++ b/lv_core/lv_disp.c @@ -32,23 +32,6 @@ * GLOBAL FUNCTIONS **********************/ -lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp) -{ - if(disp == NULL) disp = lv_disp_get_active(); - - if(disp == NULL) return LV_HOR_RES_MAX; - else return disp->driver.hor_res; -} - - -lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp) -{ - if(disp == NULL) disp = lv_disp_get_active(); - - if(disp == NULL) return LV_VER_RES_MAX; - else return disp->driver.ver_res; -} - /********************** * STATIC FUNCTIONS **********************/ diff --git a/lv_core/lv_disp.h b/lv_core/lv_disp.h index 89db388f9..952caf564 100644 --- a/lv_core/lv_disp.h +++ b/lv_core/lv_disp.h @@ -13,7 +13,7 @@ extern "C" { /********************* * INCLUDES *********************/ -#include "../lv_hal/lv_hal_disp.h" +#include "../lv_hal/lv_hal.h" /********************* * DEFINES diff --git a/lv_core/lv_indev.c b/lv_core/lv_indev.c index 1c2480cce..8be40082b 100644 --- a/lv_core/lv_indev.c +++ b/lv_core/lv_indev.c @@ -121,12 +121,13 @@ void lv_indev_reset_lpr(lv_indev_t * indev) */ void lv_indev_enable(lv_hal_indev_type_t type, bool enable) { - lv_indev_t * i = lv_indev_next(NULL); - while(i) { - if(i->driver.type == type) i->proc.disabled = enable == false ? 1 : 0; - i = lv_indev_next(i); - } +// lv_indev_t * i = lv_indev_next(NULL); +// +// while(i) { +// if(i->driver.type == type) i->proc.disabled = enable == false ? 1 : 0; +// i = lv_indev_next(i); +// } } /** @@ -244,19 +245,23 @@ void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point) */ uint32_t lv_indev_get_inactive_time(const lv_indev_t * indev) { - uint32_t t; - if(indev) return t = lv_tick_elaps(indev->last_activity_time); + //TODO +// uint32_t t; +// +// if(indev) return t = lv_tick_elaps(indev->last_activity_time); +// +// lv_indev_t * i; +// t = UINT16_MAX; +// i = lv_indev_next(NULL); +// while(i) { +// t = LV_MATH_MIN(t, lv_tick_elaps(i->last_activity_time)); +// i = lv_indev_next(i); +// } +// +// return t; - lv_indev_t * i; - t = UINT16_MAX; - i = lv_indev_next(NULL); - while(i) { - t = LV_MATH_MIN(t, lv_tick_elaps(i->last_activity_time)); - i = lv_indev_next(i); - } - - return t; + return 0; } /** @@ -583,14 +588,14 @@ static void indev_proc_press(lv_indev_proc_t * proc) /*If there is no last object then search*/ if(proc->act_obj == NULL) { - pr_obj = indev_search_obj(proc, lv_layer_top()); - if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_scr_act()); + pr_obj = indev_search_obj(proc, lv_layer_top(NULL)); + if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_scr_act(NULL)); } /*If there is last object but it is not dragged and not protected also search*/ else if(proc->drag_in_prog == 0 && lv_obj_is_protected(proc->act_obj, LV_PROTECT_PRESS_LOST) == false) {/*Now act_obj != NULL*/ - pr_obj = indev_search_obj(proc, lv_layer_top()); - if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_scr_act()); + pr_obj = indev_search_obj(proc, lv_layer_top(NULL)); + if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_scr_act(NULL)); } /*If a dragable or a protected object was the last then keep it*/ else { diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index ae8f45178..4588ab424 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -17,6 +17,7 @@ #include "../lv_misc/lv_task.h" #include "../lv_misc/lv_fs.h" #include "../lv_misc/lv_ufs.h" +#include "../lv_hal/lv_hal.h" #include #include #include "../lv_misc/lv_gc.h" @@ -62,13 +63,6 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param); */ void lv_init(void) { - LV_GC_ROOT(_lv_def_scr) = NULL; - LV_GC_ROOT(_lv_act_scr) = NULL; - LV_GC_ROOT(_lv_top_layer) = NULL; - LV_GC_ROOT(_lv_sys_layer) = NULL; - LV_GC_ROOT(_lv_disp_list) = NULL; - LV_GC_ROOT(_lv_indev_list) = NULL; - LV_LOG_TRACE("lv_init started"); /*Initialize the lv_misc modules*/ @@ -91,20 +85,9 @@ void lv_init(void) /*Initialize the screen refresh system*/ lv_refr_init(); - /*Create the default screen*/ - lv_ll_init(&LV_GC_ROOT(_lv_scr_ll), sizeof(lv_obj_t)); - LV_GC_ROOT(_lv_def_scr) = lv_obj_create(NULL, NULL); + lv_ll_init(&LV_GC_ROOT(_lv_disp_ll), sizeof(lv_disp_t)); + lv_ll_init(&LV_GC_ROOT(_lv_indev_ll), sizeof(lv_indev_t)); - LV_GC_ROOT(_lv_act_scr) = LV_GC_ROOT(_lv_def_scr); - - LV_GC_ROOT(_lv_top_layer) = lv_obj_create(NULL, NULL); - lv_obj_set_style(LV_GC_ROOT(_lv_top_layer), &lv_style_transp_fit); - - LV_GC_ROOT(_lv_sys_layer) = lv_obj_create(NULL, NULL); - lv_obj_set_style(LV_GC_ROOT(_lv_sys_layer), &lv_style_transp_fit); - - /*Refresh the screen*/ - lv_obj_invalidate(LV_GC_ROOT(_lv_act_scr)); #if LV_INDEV_READ_PERIOD != 0 /*Init the input device handling*/ @@ -133,8 +116,12 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) /*Create a screen if the parent is NULL*/ if(parent == NULL) { LV_LOG_TRACE("Screen create started"); + lv_disp_t * disp = lv_disp_get_last(); + if(!disp) { + LV_LOG_WARN("lv_obj_create: not display created to so far. No place to assign the new screen") + } - new_obj = lv_ll_ins_head(&LV_GC_ROOT(_lv_scr_ll)); + new_obj = lv_ll_ins_head(&disp->scr_ll); lv_mem_assert(new_obj); if(new_obj == NULL) return NULL; @@ -357,7 +344,8 @@ lv_res_t lv_obj_del(lv_obj_t * obj) /*Remove the object from parent's children list*/ lv_obj_t * par = lv_obj_get_parent(obj); if(par == NULL) { /*It is a screen*/ - lv_ll_rem(&LV_GC_ROOT(_lv_scr_ll), obj); + lv_disp_t * d = lv_scr_get_disp(obj); + lv_ll_rem(&d->scr_ll, obj); } else { lv_ll_rem(&(par->child_ll), obj); } @@ -415,9 +403,9 @@ void lv_obj_invalidate(const lv_obj_t * obj) /*Invalidate the object only if it belongs to the 'LV_GC_ROOT(_lv_act_scr)'*/ lv_obj_t * obj_scr = lv_obj_get_screen(obj); - if(obj_scr == lv_scr_act() || - obj_scr == lv_layer_top() || - obj_scr == lv_layer_sys()) { + lv_disp_t * disp = lv_scr_get_disp(obj_scr); + if(obj_scr == lv_scr_act(disp) || + obj_scr == lv_layer_top(disp)) { /*Truncate recursively to the parents*/ lv_area_t area_trunc; lv_obj_t * par = lv_obj_get_parent(obj); @@ -448,9 +436,24 @@ void lv_obj_invalidate(const lv_obj_t * obj) * Setter functions *====================*/ + /*-------------- * Screen set *--------------*/ +lv_disp_t * lv_scr_get_disp(lv_obj_t * scr) +{ + lv_disp_t * d; + + LL_READ(LV_GC_ROOT(_lv_disp_ll), d) { + lv_obj_t * s; + LL_READ(d->scr_ll, s) { + if(s == scr) return d; + } + } + + LV_LOG_WARN("lv_scr_get_disp: screen not found") + return NULL; +} /** * Load a new screen @@ -458,9 +461,11 @@ void lv_obj_invalidate(const lv_obj_t * obj) */ void lv_scr_load(lv_obj_t * scr) { - LV_GC_ROOT(_lv_act_scr) = scr; + lv_disp_t * d = lv_scr_get_disp(scr); - lv_obj_invalidate(LV_GC_ROOT(_lv_act_scr)); + d->act_scr = scr; + + lv_obj_invalidate(scr); } /*-------------------- @@ -1006,13 +1011,17 @@ void lv_obj_refresh_style(lv_obj_t * obj) */ void lv_obj_report_style_mod(lv_style_t * style) { - lv_obj_t * i; - LL_READ(LV_GC_ROOT(_lv_scr_ll), i) { - if(i->style_p == style || style == NULL) { - lv_obj_refresh_style(i); - } + lv_disp_t * d = lv_disp_get_next(NULL); - report_style_mod_core(style, i); + while(d) { + lv_obj_t * i; + LL_READ(d->scr_ll, i) { + if(i->style_p == style || style == NULL) { + lv_obj_refresh_style(i); + } + + report_style_mod_core(style, i); + } } } @@ -1302,28 +1311,30 @@ void lv_obj_animate(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint1 * Return with a pointer to the active screen * @return pointer to the active screen object (loaded by 'lv_scr_load()') */ -lv_obj_t * lv_scr_act(void) +lv_obj_t * lv_scr_act(lv_disp_t * disp) { - return LV_GC_ROOT(_lv_act_scr); + if(!disp) disp = lv_disp_get_last(); + if(!disp) { + LV_LOG_WARN("lv_layer_top: no display registered to get its top layer"); + return NULL; + } + + return disp->act_scr; } /** * Return with the top layer. (Same on every screen and it is above the normal screen layer) * @return pointer to the top layer object (transparent screen sized lv_obj) */ -lv_obj_t * lv_layer_top(void) +lv_obj_t * lv_layer_top(lv_disp_t * disp) { - return LV_GC_ROOT(_lv_top_layer); -} + if(!disp) disp = lv_disp_get_last(); + if(!disp) { + LV_LOG_WARN("lv_layer_top: no display registered to get its top layer"); + return NULL; + } -/** - * Return with the system layer. (Same on every screen and it is above the all other layers) - * It is used for example by the cursor - * @return pointer to the system layer object (transparent screen sized lv_obj) - */ -lv_obj_t * lv_layer_sys(void) -{ - return LV_GC_ROOT(_lv_sys_layer); + return disp->top_layer; } /** diff --git a/lv_core/lv_obj.h b/lv_core/lv_obj.h index 7f8f848ab..2d476b307 100644 --- a/lv_core/lv_obj.h +++ b/lv_core/lv_obj.h @@ -27,6 +27,7 @@ extern "C" { #include "../lv_misc/lv_ll.h" #include "../lv_misc/lv_color.h" #include "../lv_misc/lv_log.h" +#include "../lv_hal/lv_hal.h" /********************* * DEFINES @@ -277,6 +278,8 @@ void lv_obj_invalidate(const lv_obj_t * obj); * Screen set *--------------*/ +lv_disp_t * lv_scr_get_disp(lv_obj_t * scr); + /** * Load a new screen * @param scr pointer to a screen @@ -560,20 +563,13 @@ void lv_obj_animate(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint1 * Return with a pointer to the active screen * @return pointer to the active screen object (loaded by 'lv_scr_load()') */ -lv_obj_t * lv_scr_act(void); +lv_obj_t * lv_scr_act(lv_disp_t * disp); /** * Return with the top layer. (Same on every screen and it is above the normal screen layer) * @return pointer to the top layer object (transparent screen sized lv_obj) */ -lv_obj_t * lv_layer_top(void); - -/** - * Return with the system layer. (Same on every screen and it is above the all other layers) - * It is used for example by the cursor - * @return pointer to the system layer object (transparent screen sized lv_obj) - */ -lv_obj_t * lv_layer_sys(void); +lv_obj_t * lv_layer_top(lv_disp_t * disp); /** * Return with the screen of an object diff --git a/lv_draw/lv_draw_rbasic.c b/lv_draw/lv_draw_rbasic.c index 647554924..47fb5938f 100644 --- a/lv_draw/lv_draw_rbasic.c +++ b/lv_draw/lv_draw_rbasic.c @@ -9,7 +9,7 @@ #include "lv_draw_rbasic.h" #if USE_LV_REAL_DRAW != 0 -#include "../lv_hal/lv_hal_disp.h" +#include "../lv_hal/lv_hal.h" #include "../lv_misc/lv_font.h" #include "lv_draw.h" diff --git a/lv_draw/lv_draw_vbasic.c b/lv_draw/lv_draw_vbasic.c index 8ab127856..9e37563aa 100644 --- a/lv_draw/lv_draw_vbasic.c +++ b/lv_draw/lv_draw_vbasic.c @@ -9,7 +9,7 @@ #include #include -#include "../lv_hal/lv_hal_disp.h" +#include "../lv_hal/lv_hal.h" #include "../lv_misc/lv_area.h" #include "../lv_misc/lv_font.h" #include "../lv_misc/lv_color.h" diff --git a/lv_hal/lv_hal.h b/lv_hal/lv_hal.h index 5ab28f2a6..a5e0a1dd5 100644 --- a/lv_hal/lv_hal.h +++ b/lv_hal/lv_hal.h @@ -1,10 +1,10 @@ /** - * @file hal.h + * @file lv_hal.h * */ -#ifndef HAL_H -#define HAL_H +#ifndef LV_HAL_H +#define LV_HAL_H #ifdef __cplusplus extern "C" { diff --git a/lv_hal/lv_hal_disp.c b/lv_hal/lv_hal_disp.c index 3be8b927e..f08a9d7f0 100644 --- a/lv_hal/lv_hal_disp.c +++ b/lv_hal/lv_hal_disp.c @@ -11,7 +11,7 @@ *********************/ #include #include -#include "../lv_hal/lv_hal_disp.h" +#include "lv_hal.h" #include "../lv_misc/lv_mem.h" #include "../lv_core/lv_obj.h" #include "../lv_misc/lv_gc.h" @@ -57,6 +57,8 @@ void lv_disp_drv_init(lv_disp_drv_t * driver) driver->disp_fill = NULL; driver->disp_map = NULL; driver->disp_flush = NULL; + driver->hor_res = LV_HOR_RES_MAX; + driver->ver_res = LV_VER_RES_MAX; #if USE_LV_GPU driver->mem_blend = NULL; @@ -76,47 +78,36 @@ void lv_disp_drv_init(lv_disp_drv_t * driver) */ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) { - lv_disp_t * node; - node = lv_mem_alloc(sizeof(lv_disp_t)); - lv_mem_assert(node); - if(node == NULL) return NULL; + lv_disp_t * node = lv_ll_ins_head(&LV_GC_ROOT(_lv_disp_ll)); + if(!node) { + lv_mem_assert(node); + return NULL; + } memcpy(&node->driver, driver, sizeof(lv_disp_drv_t)); - node->next = NULL; - /* Set first display as active by default */ - if(LV_GC_ROOT(_lv_disp_list) == NULL) { - LV_GC_ROOT(_lv_disp_list) = node; - active = node; - lv_obj_invalidate(lv_scr_act()); - } else { - ((lv_disp_t*)LV_GC_ROOT(_lv_disp_list))->next = node; - } + lv_ll_init(&node->scr_ll, sizeof(lv_obj_t)); + + node->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/ + node->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/ return node; } - -/** - * Set the active display - * @param disp pointer to a display (return value of 'lv_disp_register') - */ -void lv_disp_set_active(lv_disp_t * disp) +void * lv_disp_get_next(lv_disp_t * disp) { - active = disp; - lv_obj_invalidate(lv_scr_act()); + if(disp == NULL) return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll)); + else return lv_ll_get_next(&LV_GC_ROOT(_lv_disp_ll), disp); } -/** - * Get a pointer to the active display - * @return pointer to the active display - */ -lv_disp_t * lv_disp_get_active(void) + +lv_disp_t * lv_disp_get_last(void) { - return active; + return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll)); } + /** * Get the next display. * @param disp pointer to the current display. NULL to initialize. @@ -124,12 +115,25 @@ lv_disp_t * lv_disp_get_active(void) */ lv_disp_t * lv_disp_next(lv_disp_t * disp) { - if(disp == NULL) { - return LV_GC_ROOT(_lv_disp_list); - } else { - if(((lv_disp_t*)LV_GC_ROOT(_lv_disp_list))->next == NULL) return NULL; - else return ((lv_disp_t*)LV_GC_ROOT(_lv_disp_list))->next; - } + if(disp == NULL) return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll)); + else return lv_ll_get_next(&LV_GC_ROOT(_lv_disp_ll), disp); +} + +lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp) +{ + if(disp == NULL) disp = lv_disp_get_active(); + + if(disp == NULL) return LV_HOR_RES_MAX; + else return disp->driver.hor_res; +} + + +lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp) +{ + if(disp == NULL) disp = lv_disp_get_active(); + + if(disp == NULL) return LV_VER_RES_MAX; + else return disp->driver.ver_res; } /** diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index e298b4ac8..4266c0938 100644 --- a/lv_hal/lv_hal_disp.h +++ b/lv_hal/lv_hal_disp.h @@ -1,12 +1,12 @@ /** - * @file hal_disp.h + * @file lv_hal_disp.h * * @description Display Driver HAL interface header file * */ -#ifndef HAL_DISP_H -#define HAL_DISP_H +#ifndef LV_HAL_DISP_H +#define LV_HAL_DISP_H #ifdef __cplusplus extern "C" { @@ -20,7 +20,7 @@ extern "C" { #include "lv_hal.h" #include "../lv_misc/lv_color.h" #include "../lv_misc/lv_area.h" -#include "../lv_core/lv_obj.h" +#include "../lv_misc/lv_ll.h" /********************* * DEFINES @@ -62,14 +62,15 @@ typedef struct _disp_drv_t { #endif } lv_disp_drv_t; +struct _lv_obj_t; + typedef struct _disp_t { lv_disp_drv_t driver; lv_area_t inv_buf[32]; lv_ll_t scr_ll; - lv_obj_t * act_scr; - lv_obj_t * top_scr; + struct _lv_obj_t * act_scr; + struct _lv_obj_t * top_layer; uint8_t orientation:2; - struct _disp_t *next; } lv_disp_t; /********************** @@ -92,17 +93,8 @@ void lv_disp_drv_init(lv_disp_drv_t *driver); */ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t *driver); -/** - * Set the active display - * @param disp pointer to a display (return value of 'lv_disp_register') - */ -void lv_disp_set_active(lv_disp_t * disp); -/** - * Get a pointer to the active display - * @return pointer to the active display - */ -lv_disp_t * lv_disp_get_active(void); +lv_disp_t * lv_disp_get_last(void); /** * Get the next display. diff --git a/lv_hal/lv_hal_indev.c b/lv_hal/lv_hal_indev.c index 6083c3fd2..601695e2e 100644 --- a/lv_hal/lv_hal_indev.c +++ b/lv_hal/lv_hal_indev.c @@ -51,6 +51,7 @@ void lv_indev_drv_init(lv_indev_drv_t * driver) { driver->read = NULL; driver->type = LV_INDEV_TYPE_NONE; + driver->disp = NULL; driver->user_data = NULL; } @@ -61,30 +62,28 @@ void lv_indev_drv_init(lv_indev_drv_t * driver) */ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver) { - lv_indev_t * node; - node = lv_mem_alloc(sizeof(lv_indev_t)); - if(!node) return NULL; + if(driver->disp == NULL) driver->disp = lv_disp_get_last(); + + if(driver->disp == NULL) { + LV_LOG_WARN("lv_indev_drv_register: no display registered hence can't attache the indev to a display"); + return NULL; + } + + lv_indev_t * node = lv_ll_ins_head(&LV_GC_ROOT(_lv_indev_ll)); + if(!node) { + lv_mem_assert(node); + return NULL; + } memset(node, 0, sizeof(lv_indev_t)); memcpy(&node->driver, driver, sizeof(lv_indev_drv_t)); - node->next = NULL; node->proc.reset_query = 1; node->cursor = NULL; node->group = NULL; node->btn_points = NULL; - if(LV_GC_ROOT(_lv_indev_list) == NULL) { - LV_GC_ROOT(_lv_indev_list) = node; - } else { - lv_indev_t * last = LV_GC_ROOT(_lv_indev_list); - while(last->next) - last = last->next; - - last->next = node; - } - return node; } @@ -95,13 +94,8 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver) */ lv_indev_t * lv_indev_next(lv_indev_t * indev) { - - if(indev == NULL) { - return LV_GC_ROOT(_lv_indev_list); - } else { - if(indev->next == NULL) return NULL; - else return indev->next; - } + if(indev == NULL) return lv_ll_get_head(LV_GC_ROOT(&_lv_indev_ll)); + else return lv_ll_get_next(LV_GC_ROOT(&_lv_indev_ll), indev); } /** diff --git a/lv_hal/lv_hal_indev.h b/lv_hal/lv_hal_indev.h index 214b02754..977ae3e21 100644 --- a/lv_hal/lv_hal_indev.h +++ b/lv_hal/lv_hal_indev.h @@ -1,12 +1,12 @@ /** - * @file hal_indev.h + * @file lv_hal_indev.h * * @description Input Device HAL interface layer header file * */ -#ifndef HAL_INDEV_H -#define HAL_INDEV_H +#ifndef LV_HAL_INDEV_H +#define LV_HAL_INDEV_H #ifdef __cplusplus extern "C" { @@ -19,7 +19,7 @@ extern "C" { #include #include "lv_hal.h" #include "../lv_misc/lv_area.h" -#include "../lv_core/lv_obj.h" +//#include "../lv_core/lv_obj.h" /********************* * DEFINES @@ -62,7 +62,9 @@ typedef struct { typedef struct { lv_hal_indev_type_t type; /*Input device type*/ bool (*read)(lv_indev_data_t *data); /*Function pointer to read data. Return 'true' if there is still data to be read (buffered)*/ + lv_disp_t * disp; void *user_data; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/ + } lv_indev_drv_t; struct _lv_obj_t; @@ -101,7 +103,7 @@ typedef struct _lv_indev_proc_t { struct _lv_indev_t; -typedef void (*lv_indev_feedback_t)(struct _lv_indev_t *, lv_signal_t); +typedef void (*lv_indev_feedback_t)(struct _lv_indev_t *, uint8_t); struct _lv_obj_t; struct _lv_group_t; @@ -112,13 +114,13 @@ typedef struct _lv_indev_t { lv_indev_proc_t proc; lv_indev_feedback_t feedback; uint32_t last_activity_time; + lv_disp_t * disp; union { struct _lv_obj_t *cursor; /*Cursor for LV_INPUT_TYPE_POINTER*/ struct _lv_group_t *group; /*Keypad destination group*/ const lv_point_t * btn_points; /*Array points assigned to the button ()screen will be pressed here by the buttons*/ }; - struct _lv_indev_t *next; } lv_indev_t; /********************** @@ -143,7 +145,7 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t *driver); /** * Get the next input device. * @param indev pointer to the current input device. NULL to initialize. - * @return the next input devise or NULL if no more. Gives the first input device when the parameter is NULL + * @return the next input devise or NULL if no more. Give the first input device when the parameter is NULL */ lv_indev_t * lv_indev_next(lv_indev_t * indev); diff --git a/lv_misc/lv_gc.h b/lv_misc/lv_gc.h index 72b10fc45..2ba405fc3 100644 --- a/lv_misc/lv_gc.h +++ b/lv_misc/lv_gc.h @@ -31,17 +31,12 @@ extern "C" { #define LV_GC_ROOTS(prefix) \ prefix lv_ll_t _lv_task_ll; /*Linked list to store the lv_tasks*/ \ - prefix lv_ll_t _lv_scr_ll; /*Linked list of screens*/ \ + prefix lv_ll_t _lv_disp_ll; /*Linked list of screens*/ \ + prefix lv_ll_t _lv_indev_ll; /*Linked list of screens*/ \ prefix lv_ll_t _lv_drv_ll;\ prefix lv_ll_t _lv_file_ll;\ prefix lv_ll_t _lv_anim_ll;\ - prefix void * _lv_def_scr;\ - prefix void * _lv_act_scr;\ - prefix void * _lv_top_layer;\ - prefix void * _lv_sys_layer;\ prefix void * _lv_task_act;\ - prefix void * _lv_indev_list;\ - prefix void * _lv_disp_list;\ #define LV_NO_PREFIX From b15ffa3d8991b082149e3e06a0fa43a3d7c8a4f9 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 12 Feb 2019 15:38:13 +0100 Subject: [PATCH 05/17] multi-disp: add unique inv_buf to each display --- lv_core/lv_disp.c | 20 +++++++++ lv_core/lv_disp.h | 12 ++++++ lv_core/lv_indev.c | 9 ++-- lv_core/lv_obj.c | 40 ++++++++++-------- lv_core/lv_obj.h | 7 +++- lv_core/lv_refr.c | 98 ++++++++++++++++---------------------------- lv_core/lv_refr.h | 7 ++-- lv_hal/lv_hal_disp.c | 2 + lv_hal/lv_hal_disp.h | 7 +++- lv_objx/lv_btnm.c | 10 +++-- lv_objx/lv_page.c | 14 ++++--- lv_objx/lv_ta.c | 8 ++-- lv_objx/lv_tabview.c | 3 +- 13 files changed, 135 insertions(+), 102 deletions(-) diff --git a/lv_core/lv_disp.c b/lv_core/lv_disp.c index 29861b769..5c108cd1f 100644 --- a/lv_core/lv_disp.c +++ b/lv_core/lv_disp.c @@ -32,6 +32,26 @@ * GLOBAL FUNCTIONS **********************/ +/** + * Get the number of areas in the buffer + * @return number of invalid areas + */ +uint16_t lv_disp_get_inv_buf_size(lv_disp_t * disp) +{ + return disp->inv_p; +} + +/** + * Pop (delete) the last 'num' invalidated areas from the buffer + * @param num number of areas to delete + */ +void lv_disp_pop_from_inv_buf(lv_disp_t * disp, uint16_t num) +{ + + if(disp->inv_p < num) disp->inv_p = 0; + else disp->inv_p -= num; +} + /********************** * STATIC FUNCTIONS **********************/ diff --git a/lv_core/lv_disp.h b/lv_core/lv_disp.h index 8579fdd34..aff3ce110 100644 --- a/lv_core/lv_disp.h +++ b/lv_core/lv_disp.h @@ -27,6 +27,18 @@ extern "C" { * GLOBAL PROTOTYPES **********************/ +/** + * Get the number of areas in the buffer + * @return number of invalid areas + */ +uint16_t lv_disp_get_inv_buf_size(lv_disp_t * disp); + +/** + * Pop (delete) the last 'num' invalidated areas from the buffer + * @param num number of areas to delete + */ +void lv_disp_pop_from_inv_buf(lv_disp_t * disp, uint16_t num); + /********************** * MACROS **********************/ diff --git a/lv_core/lv_indev.c b/lv_core/lv_indev.c index a0d2ec508..666372fcf 100644 --- a/lv_core/lv_indev.c +++ b/lv_core/lv_indev.c @@ -7,6 +7,8 @@ * INCLUDES ********************/ #include "lv_indev.h" +#include "lv_disp.h" +#include "lv_obj.h" #include "../lv_hal/lv_hal_tick.h" #include "../lv_core/lv_group.h" @@ -14,7 +16,6 @@ #include "../lv_misc/lv_task.h" #include "../lv_misc/lv_math.h" #include "../lv_draw/lv_draw_rbasic.h" -#include "lv_obj.h" /********************* * DEFINES @@ -877,7 +878,7 @@ static void indev_drag(lv_indev_proc_t * state) /*Get the coordinates of the object and modify them*/ lv_coord_t act_x = lv_obj_get_x(drag_obj); lv_coord_t act_y = lv_obj_get_y(drag_obj); - uint16_t inv_buf_size = lv_refr_get_buf_size(); /*Get the number of currently invalidated areas*/ + uint16_t inv_buf_size = lv_disp_get_inv_buf_size(indev_act->driver.disp); /*Get the number of currently invalidated areas*/ lv_coord_t prev_x = drag_obj->coords.x1; lv_coord_t prev_y = drag_obj->coords.y1; @@ -903,8 +904,8 @@ static void indev_drag(lv_indev_proc_t * state) lv_coord_t act_par_w = lv_obj_get_width(lv_obj_get_parent(drag_obj)); lv_coord_t act_par_h = lv_obj_get_height(lv_obj_get_parent(drag_obj)); if(act_par_w == prev_par_w && act_par_h == prev_par_h) { - uint16_t new_inv_buf_size = lv_refr_get_buf_size(); - lv_refr_pop_from_buf(new_inv_buf_size - inv_buf_size); + uint16_t new_inv_buf_size = lv_disp_get_inv_buf_size(indev_act->driver.disp); + lv_disp_pop_from_inv_buf(indev_act->driver.disp, new_inv_buf_size - inv_buf_size); } } } diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index 6f571ddc9..b54f9bea6 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -436,7 +436,7 @@ void lv_obj_invalidate(const lv_obj_t * obj) par = lv_obj_get_parent(par); } - if(union_ok != false) lv_inv_area(&area_trunc); + if(union_ok) lv_inv_area(disp, &area_trunc); } } @@ -449,21 +449,6 @@ void lv_obj_invalidate(const lv_obj_t * obj) /*-------------- * Screen set *--------------*/ -lv_disp_t * lv_scr_get_disp(lv_obj_t * scr) -{ - lv_disp_t * d; - - LL_READ(LV_GC_ROOT(_lv_disp_ll), d) { - lv_obj_t * s; - LL_READ(d->scr_ll, s) { - if(s == scr) return d; - } - } - - LV_LOG_WARN("lv_scr_get_disp: screen not found") - return NULL; -} - /** * Load a new screen * @param scr pointer to a screen @@ -1379,6 +1364,29 @@ lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj) return (lv_obj_t *)act_p; } +lv_disp_t * lv_scr_get_disp(lv_obj_t * scr) +{ + lv_disp_t * d; + + LL_READ(LV_GC_ROOT(_lv_disp_ll), d) { + lv_obj_t * s; + LL_READ(d->scr_ll, s) { + if(s == scr) return d; + } + } + + LV_LOG_WARN("lv_scr_get_disp: screen not found") + return NULL; +} + + + +lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj) +{ + lv_obj_t * scr = lv_obj_get_screen(obj); + return lv_scr_get_disp(scr); +} + /*--------------------- * Parent/children get *--------------------*/ diff --git a/lv_core/lv_obj.h b/lv_core/lv_obj.h index 13a86559f..f291c3634 100644 --- a/lv_core/lv_obj.h +++ b/lv_core/lv_obj.h @@ -278,8 +278,6 @@ void lv_obj_invalidate(const lv_obj_t * obj); * Screen set *--------------*/ -lv_disp_t * lv_scr_get_disp(lv_obj_t * scr); - /** * Load a new screen * @param scr pointer to a screen @@ -584,6 +582,11 @@ lv_obj_t * lv_layer_sys(lv_disp_t * disp); */ lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj); + +lv_disp_t * lv_scr_get_disp(lv_obj_t * scr); + +lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj); + /*--------------------- * Parent/children get *--------------------*/ diff --git a/lv_core/lv_refr.c b/lv_core/lv_refr.c index d63250354..c83737282 100644 --- a/lv_core/lv_refr.c +++ b/lv_core/lv_refr.c @@ -19,17 +19,10 @@ /********************* * DEFINES *********************/ -#ifndef LV_INV_FIFO_SIZE -#define LV_INV_FIFO_SIZE 32 /*The average count of objects on a screen */ -#endif /********************** * TYPEDEFS **********************/ -typedef struct { - lv_area_t area; - uint8_t joined; -} lv_join_t; /********************** * STATIC PROTOTYPES @@ -50,8 +43,6 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p); /********************** * STATIC VARIABLES **********************/ -static lv_join_t inv_buf[LV_INV_FIFO_SIZE]; -static uint16_t inv_buf_p; static void (*monitor_cb)(uint32_t, uint32_t); /*Monitor the rendering time*/ static void (*round_cb)(lv_area_t *); /*If set then called to modify invalidated areas for special display controllers*/ static uint32_t px_num; @@ -70,9 +61,6 @@ static lv_disp_t * disp_refr; /*Display being refreshed*/ */ void lv_refr_init(void) { - inv_buf_p = 0; - memset(inv_buf, 0, sizeof(inv_buf)); - lv_task_t * task; task = lv_task_create(lv_refr_task, LV_REFR_PERIOD, LV_TASK_PRIO_MID, NULL); lv_task_ready(task); /*Be sure the screen will be refreshed immediately on start up*/ @@ -91,22 +79,26 @@ void lv_refr_now(void) /** - * Invalidate an area - * @param area_p pointer to area which should be invalidated + * Invalidate an area on display to redraw it + * @param area_p pointer to area which should be invalidated (NULL: delete the invalidated areas) + * @param disp pointer to display where the area should be invalidated (NULL can be used if there is only one display) */ -void lv_inv_area(const lv_area_t * area_p) +void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p) { + if(!disp) disp = lv_disp_get_last(); + if(!disp) return; + /*Clear the invalidate buffer if the parameter is NULL*/ if(area_p == NULL) { - inv_buf_p = 0; + disp->inv_p = 0; return; } lv_area_t scr_area; scr_area.x1 = 0; scr_area.y1 = 0; - scr_area.x2 = LV_HOR_RES_MAX - 1; - scr_area.y2 = LV_VER_RES_MAX - 1; + scr_area.x2 = disp->driver.hor_res - 1; + scr_area.y2 = disp->driver.ver_res - 1; lv_area_t com_area; bool suc; @@ -119,18 +111,18 @@ void lv_inv_area(const lv_area_t * area_p) /*Save only if this area is not in one of the saved areas*/ uint16_t i; - for(i = 0; i < inv_buf_p; i++) { - if(lv_area_is_in(&com_area, &inv_buf[i].area) != false) return; + for(i = 0; i < disp->inv_p; i++) { + if(lv_area_is_in(&com_area, &disp->inv_areas[i]) != false) return; } /*Save the area*/ - if(inv_buf_p < LV_INV_FIFO_SIZE) { - lv_area_copy(&inv_buf[inv_buf_p].area, &com_area); + if(disp->inv_p < LV_INV_BUF_SIZE) { + lv_area_copy(&disp->inv_areas[disp->inv_p], &com_area); } else {/*If no place for the area add the screen*/ - inv_buf_p = 0; - lv_area_copy(&inv_buf[inv_buf_p].area, &scr_area); + disp->inv_p = 0; + lv_area_copy(&disp->inv_areas[disp->inv_p], &scr_area); } - inv_buf_p ++; + disp->inv_p ++; } } @@ -156,25 +148,6 @@ void lv_refr_set_round_cb(void(*cb)(lv_area_t *)) round_cb = cb; } -/** - * Get the number of areas in the buffer - * @return number of invalid areas - */ -uint16_t lv_refr_get_buf_size(void) -{ - return inv_buf_p; -} - -/** - * Pop (delete) the last 'num' invalidated areas from the buffer - * @param num number of areas to delete - */ -void lv_refr_pop_from_buf(uint16_t num) -{ - if(inv_buf_p < num) inv_buf_p = 0; - else inv_buf_p -= num; -} - /** * Get the display which is being refreshed * @return the display being refreshed @@ -208,7 +181,7 @@ static void lv_refr_task(void * param) lv_refr_areas(); /*If refresh happened ...*/ - if(inv_buf_p != 0) { + if(disp_refr->inv_p != 0) { /*In true double buffered mode copy the refreshed areas to the new VDB to keep it up to date*/ #if LV_VDB_TRUE_DOUBLE_BUFFERED @@ -247,8 +220,9 @@ static void lv_refr_task(void * param) #endif /*Clean up*/ - memset(inv_buf, 0, sizeof(inv_buf)); - inv_buf_p = 0; + memset(disp_refr->inv_areas, 0, sizeof(disp_refr->inv_areas)); + memset(disp_refr->inv_area_joined, 0, sizeof(disp_refr->inv_area_joined)); + disp_refr->inv_p = 0; /*Call monitor cb if present*/ if(monitor_cb != NULL) { @@ -269,32 +243,32 @@ static void lv_refr_join_area(void) uint32_t join_from; uint32_t join_in; lv_area_t joined_area; - for(join_in = 0; join_in < inv_buf_p; join_in++) { - if(inv_buf[join_in].joined != 0) continue; + for(join_in = 0; join_in < disp_refr->inv_p; join_in++) { + if(disp_refr->inv_area_joined[join_in] != 0) continue; /*Check all areas to join them in 'join_in'*/ - for(join_from = 0; join_from < inv_buf_p; join_from++) { + for(join_from = 0; join_from < disp_refr->inv_p; join_from++) { /*Handle only unjoined areas and ignore itself*/ - if(inv_buf[join_from].joined != 0 || join_in == join_from) { + if(disp_refr->inv_area_joined[join_from] != 0 || join_in == join_from) { continue; } /*Check if the areas are on each other*/ - if(lv_area_is_on(&inv_buf[join_in].area, - &inv_buf[join_from].area) == false) { + if(lv_area_is_on(&disp_refr->inv_areas[join_in], + &disp_refr->inv_areas[join_from]) == false) { continue; } - lv_area_join(&joined_area, &inv_buf[join_in].area, - &inv_buf[join_from].area); + lv_area_join(&joined_area, &disp_refr->inv_areas[join_in], + &disp_refr->inv_areas[join_from]); /*Join two area only if the joined area size is smaller*/ if(lv_area_get_size(&joined_area) < - (lv_area_get_size(&inv_buf[join_in].area) + lv_area_get_size(&inv_buf[join_from].area))) { - lv_area_copy(&inv_buf[join_in].area, &joined_area); + (lv_area_get_size(&disp_refr->inv_areas[join_in]) + lv_area_get_size(&disp_refr->inv_areas[join_from]))) { + lv_area_copy(&disp_refr->inv_areas[join_in], &joined_area); /*Mark 'join_form' is joined into 'join_in'*/ - inv_buf[join_from].joined = 1; + disp_refr->inv_area_joined[join_from] = 1; } } } @@ -308,17 +282,17 @@ static void lv_refr_areas(void) px_num = 0; uint32_t i; - for(i = 0; i < inv_buf_p; i++) { + for(i = 0; i < disp_refr->inv_p; i++) { /*Refresh the unjoined areas*/ - if(inv_buf[i].joined == 0) { + if(disp_refr->inv_area_joined[i] == 0) { /*If there is no VDB do simple drawing*/ #if LV_VDB_SIZE == 0 lv_refr_area_no_vdb(&inv_buf[i].area); #else /*If VDB is used...*/ - lv_refr_area_with_vdb(&inv_buf[i].area); + lv_refr_area_with_vdb(&disp_refr->inv_areas[i]); #endif - if(monitor_cb != NULL) px_num += lv_area_get_size(&inv_buf[i].area); + if(monitor_cb != NULL) px_num += lv_area_get_size(&disp_refr->inv_areas[i]); } } diff --git a/lv_core/lv_refr.h b/lv_core/lv_refr.h index cc979aa76..14f75dd16 100644 --- a/lv_core/lv_refr.h +++ b/lv_core/lv_refr.h @@ -54,10 +54,11 @@ void lv_refr_init(void); void lv_refr_now(void); /** - * Invalidate an area - * @param area_p pointer to area which should be invalidated + * Invalidate an area on display to redraw it + * @param area_p pointer to area which should be invalidated (NULL: delete the invalidated areas) + * @param disp pointer to display where the area should be invalidated (NULL can be used if there is only one display) */ -void lv_inv_area(const lv_area_t * area_p); +void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p); /** * Set a function to call after every refresh to announce the refresh time and the number of refreshed pixels diff --git a/lv_hal/lv_hal_disp.c b/lv_hal/lv_hal_disp.c index 7e959d49e..5df264386 100644 --- a/lv_hal/lv_hal_disp.c +++ b/lv_hal/lv_hal_disp.c @@ -94,6 +94,8 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) lv_obj_set_style(node->top_layer, &lv_style_transp); lv_obj_set_style(node->sys_layer, &lv_style_transp); + node->inv_p = 0; + return node; } diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index 936b938c7..dd1060640 100644 --- a/lv_hal/lv_hal_disp.h +++ b/lv_hal/lv_hal_disp.h @@ -25,6 +25,9 @@ extern "C" { /********************* * DEFINES *********************/ +#ifndef LV_INV_BUF_SIZE +#define LV_INV_BUF_SIZE 32 /*Buffer size for invalid areas */ +#endif /********************** * TYPEDEFS @@ -66,7 +69,9 @@ struct _lv_obj_t; typedef struct _disp_t { lv_disp_drv_t driver; - lv_area_t inv_buf[32]; + lv_area_t inv_areas[LV_INV_BUF_SIZE]; + uint8_t inv_area_joined[LV_INV_BUF_SIZE]; + uint16_t inv_p; lv_ll_t scr_ll; struct _lv_obj_t * act_scr; struct _lv_obj_t * top_layer; diff --git a/lv_objx/lv_btnm.c b/lv_objx/lv_btnm.c index 33abbf20c..0ce1bba3a 100644 --- a/lv_objx/lv_btnm.c +++ b/lv_objx/lv_btnm.c @@ -561,6 +561,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) /*Invalidate to old and the new areas*/; lv_obj_get_coords(btnm, &btnm_area); if(btn_pr != ext->btn_id_pr) { + lv_disp_t * disp = lv_obj_get_disp(btnm); lv_indev_reset_lpr(param); if(ext->btn_id_pr != LV_BTNM_PR_NONE) { lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_pr]); @@ -568,7 +569,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) btn_area.y1 += btnm_area.y1; btn_area.x2 += btnm_area.x1; btn_area.y2 += btnm_area.y1; - lv_inv_area(&btn_area); + lv_inv_area(disp, &btn_area); } if(btn_pr != LV_BTNM_PR_NONE) { lv_area_copy(&btn_area, &ext->button_areas[btn_pr]); @@ -576,7 +577,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) btn_area.y1 += btnm_area.y1; btn_area.x2 += btnm_area.x1; btn_area.y2 += btnm_area.y1; - lv_inv_area(&btn_area); + lv_inv_area(disp, &btn_area); } } @@ -599,6 +600,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) if(button_is_inactive(ext->map_p[txt_i]) == false && txt_i != LV_BTNM_PR_NONE) { /*Ignore the inactive buttons anf click between the buttons*/ if(ext->action) res = ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i])); if(res == LV_RES_OK) { + lv_disp_t * disp = lv_obj_get_disp(btnm); /*Invalidate to old pressed area*/; lv_obj_get_coords(btnm, &btnm_area); @@ -607,7 +609,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) btn_area.y1 += btnm_area.y1; btn_area.x2 += btnm_area.x1; btn_area.y2 += btnm_area.y1; - lv_inv_area(&btn_area); + lv_inv_area(disp, &btn_area); if(ext->toggle != 0) { /*Invalidate to old toggled area*/; @@ -616,7 +618,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) btn_area.y1 += btnm_area.y1; btn_area.x2 += btnm_area.x1; btn_area.y2 += btnm_area.y1; - lv_inv_area(&btn_area); + lv_inv_area(disp, &btn_area); ext->btn_id_tgl = ext->btn_id_pr; } diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index 4058c494a..46c3a2160 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -1000,6 +1000,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi /*Hide scrollbars if required*/ if(page_ext->sb.mode == LV_SB_MODE_DRAG) { + lv_disp_t * disp = lv_obj_get_disp(page); lv_area_t sb_area_tmp; if(page_ext->sb.hor_draw) { lv_area_copy(&sb_area_tmp, &page_ext->sb.hor_area); @@ -1007,7 +1008,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi sb_area_tmp.y1 += page->coords.y1; sb_area_tmp.x2 += page->coords.x1; sb_area_tmp.y2 += page->coords.y1; - lv_inv_area(&sb_area_tmp); + lv_inv_area(disp, &sb_area_tmp); page_ext->sb.hor_draw = 0; } if(page_ext->sb.ver_draw) { @@ -1016,7 +1017,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi sb_area_tmp.y1 += page->coords.y1; sb_area_tmp.x2 += page->coords.x1; sb_area_tmp.y2 += page->coords.y1; - lv_inv_area(&sb_area_tmp); + lv_inv_area(disp, &sb_area_tmp); page_ext->sb.ver_draw = 0; } } @@ -1068,6 +1069,7 @@ static void lv_page_sb_refresh(lv_obj_t * page) } /*Invalidate the current (old) scrollbar areas*/ + lv_disp_t * disp = lv_obj_get_disp(page); lv_area_t sb_area_tmp; if(ext->sb.hor_draw != 0) { lv_area_copy(&sb_area_tmp, &ext->sb.hor_area); @@ -1075,7 +1077,7 @@ static void lv_page_sb_refresh(lv_obj_t * page) sb_area_tmp.y1 += page->coords.y1; sb_area_tmp.x2 += page->coords.x1; sb_area_tmp.y2 += page->coords.y1; - lv_inv_area(&sb_area_tmp); + lv_inv_area(disp, &sb_area_tmp); } if(ext->sb.ver_draw != 0) { lv_area_copy(&sb_area_tmp, &ext->sb.ver_area); @@ -1083,7 +1085,7 @@ static void lv_page_sb_refresh(lv_obj_t * page) sb_area_tmp.y1 += page->coords.y1; sb_area_tmp.x2 += page->coords.x1; sb_area_tmp.y2 += page->coords.y1; - lv_inv_area(&sb_area_tmp); + lv_inv_area(disp, &sb_area_tmp); } @@ -1137,7 +1139,7 @@ static void lv_page_sb_refresh(lv_obj_t * page) sb_area_tmp.y1 += page->coords.y1; sb_area_tmp.x2 += page->coords.x1; sb_area_tmp.y2 += page->coords.y1; - lv_inv_area(&sb_area_tmp); + lv_inv_area(disp, &sb_area_tmp); } if(ext->sb.ver_draw != 0) { lv_area_copy(&sb_area_tmp, &ext->sb.ver_area); @@ -1145,7 +1147,7 @@ static void lv_page_sb_refresh(lv_obj_t * page) sb_area_tmp.y1 += page->coords.y1; sb_area_tmp.x2 += page->coords.x1; sb_area_tmp.y2 += page->coords.y1; - lv_inv_area(&sb_area_tmp); + lv_inv_area(disp, &sb_area_tmp); } } diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index 69c12ce03..8427891a6 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -1136,13 +1136,14 @@ static void cursor_blink_anim(lv_obj_t * ta, uint8_t show) if(ext->cursor.type != LV_CURSOR_NONE && (ext->cursor.type & LV_CURSOR_HIDDEN) == 0) { + lv_disp_t * disp = lv_obj_get_disp(ta); lv_area_t area_tmp; lv_area_copy(&area_tmp, &ext->cursor.area); area_tmp.x1 += ext->label->coords.x1; area_tmp.y1 += ext->label->coords.y1; area_tmp.x2 += ext->label->coords.x1; area_tmp.y2 += ext->label->coords.y1; - lv_inv_area(&area_tmp); + lv_inv_area(disp, &area_tmp); } } } @@ -1327,13 +1328,14 @@ static void refr_cursor_area(lv_obj_t * ta) } /*Save the new area*/ + lv_disp_t * disp = lv_obj_get_disp(ta); lv_area_t area_tmp; lv_area_copy(&area_tmp, &ext->cursor.area); area_tmp.x1 += ext->label->coords.x1; area_tmp.y1 += ext->label->coords.y1; area_tmp.x2 += ext->label->coords.x1; area_tmp.y2 += ext->label->coords.y1; - lv_inv_area(&area_tmp); + lv_inv_area(disp, &area_tmp); lv_area_copy(&ext->cursor.area, &cur_area); @@ -1342,7 +1344,7 @@ static void refr_cursor_area(lv_obj_t * ta) area_tmp.y1 += ext->label->coords.y1; area_tmp.x2 += ext->label->coords.x1; area_tmp.y2 += ext->label->coords.y1; - lv_inv_area(&area_tmp); + lv_inv_area(disp, &area_tmp); } #endif diff --git a/lv_objx/lv_tabview.c b/lv_objx/lv_tabview.c index c09560fbd..ffe6f2147 100644 --- a/lv_objx/lv_tabview.c +++ b/lv_objx/lv_tabview.c @@ -106,7 +106,8 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) ext->tab_name_ptr[0] = ""; ext->tab_cnt = 0; - lv_obj_set_size(new_tabview, LV_DPI * 3, LV_DPI * 2); + lv_disp_t * disp = lv_obj_get_disp(par); + lv_obj_set_size(new_tabview, lv_disp_get_hor_res(disp), lv_disp_get_ver_res(disp)); ext->btns = lv_btnm_create(new_tabview, NULL); lv_obj_set_height(ext->btns, 3 * LV_DPI / 4); From 7571bedc46e887ccbe968d2a44251db7b0928e51 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 12 Feb 2019 16:20:59 +0100 Subject: [PATCH 06/17] multi-disp: minor updates --- lv_core/lv_disp.c | 12 ++++++++++++ lv_core/lv_disp.h | 2 ++ lv_core/lv_vdb.c | 2 +- lv_hal/lv_hal_disp.h | 13 ++++++++----- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lv_core/lv_disp.c b/lv_core/lv_disp.c index 5c108cd1f..6017ba27c 100644 --- a/lv_core/lv_disp.c +++ b/lv_core/lv_disp.c @@ -52,6 +52,18 @@ void lv_disp_pop_from_inv_buf(lv_disp_t * disp, uint16_t num) else disp->inv_p -= num; } +void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr) +{ + lv_disp_t * old_disp = lv_scr_get_disp(scr); + + if(old_disp == disp) { + LV_LOG_WARN("lv_disp_assign_screen: tried to assign to the same screen") + return; + } + + lv_ll_chg_list(&old_disp->scr_ll, &disp->scr_ll, scr); +} + /********************** * STATIC FUNCTIONS **********************/ diff --git a/lv_core/lv_disp.h b/lv_core/lv_disp.h index aff3ce110..62690f551 100644 --- a/lv_core/lv_disp.h +++ b/lv_core/lv_disp.h @@ -14,6 +14,7 @@ extern "C" { * INCLUDES *********************/ #include "../lv_hal/lv_hal.h" +#include "lv_obj.h" /********************* * DEFINES @@ -26,6 +27,7 @@ extern "C" { /********************** * GLOBAL PROTOTYPES **********************/ +void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr); /** * Get the number of areas in the buffer diff --git a/lv_core/lv_vdb.c b/lv_core/lv_vdb.c index 6ab6a9243..12523b2a2 100644 --- a/lv_core/lv_vdb.c +++ b/lv_core/lv_vdb.c @@ -111,7 +111,7 @@ void lv_vdb_flush(void) /*Flush the rendered content to the display*/ lv_disp_t * disp = lv_refr_get_disp_refreshing(); - if(disp->driver.disp_flush) disp->driver.disp_flush(vdb_act->area.x1, vdb_act->area.y1, vdb_act->area.x2, vdb_act->area.y2, vdb_act->buf); + if(disp->driver.disp_flush) disp->driver.disp_flush(disp, &vdb_act->area, vdb_act->buf); #if LV_VDB_DOUBLE diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index dd1060640..6480824a2 100644 --- a/lv_hal/lv_hal_disp.h +++ b/lv_hal/lv_hal_disp.h @@ -33,6 +33,8 @@ extern "C" { * TYPEDEFS **********************/ +struct _disp_t; + /** * Display Driver structure to be registered by HAL */ @@ -42,7 +44,7 @@ typedef struct _disp_drv_t { lv_coord_t ver_res; /*Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished*/ - void (*disp_flush)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p); + void (*disp_flush)(struct _disp_t * disp, const lv_area_t * area, lv_color_t * color_p); /*Fill an area with a color on the display*/ void (*disp_fill)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color); @@ -68,15 +70,16 @@ typedef struct _disp_drv_t { struct _lv_obj_t; typedef struct _disp_t { + void * user_data; lv_disp_drv_t driver; - lv_area_t inv_areas[LV_INV_BUF_SIZE]; - uint8_t inv_area_joined[LV_INV_BUF_SIZE]; - uint16_t inv_p; lv_ll_t scr_ll; struct _lv_obj_t * act_scr; struct _lv_obj_t * top_layer; struct _lv_obj_t * sys_layer; - uint8_t orientation:2; + lv_area_t inv_areas[LV_INV_BUF_SIZE]; + uint8_t inv_area_joined[LV_INV_BUF_SIZE]; + uint16_t inv_p :10; + uint16_t orientation :2; } lv_disp_t; /********************** From cfa7d22d332e9353028ff8799f5d7520bf1c054c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 12 Feb 2019 22:35:59 +0100 Subject: [PATCH 07/17] multi-disp: display level vdb experiment --- lv_core/lv_vdb.c | 3 +++ lv_hal/lv_hal_disp.c | 31 ++++++++++++++++++------------- lv_hal/lv_hal_disp.h | 14 +++++++++++--- lv_hal/lv_hal_indev.h | 2 +- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/lv_core/lv_vdb.c b/lv_core/lv_vdb.c index 12523b2a2..ffde701e2 100644 --- a/lv_core/lv_vdb.c +++ b/lv_core/lv_vdb.c @@ -79,9 +79,12 @@ static volatile bool vdb_flushing = false; */ lv_vdb_t * lv_vdb_get(void) { + lv_disp_t * disp = lv_refr_get_disp_refreshing(); + #if LV_VDB_DOUBLE == 0 /* Wait until VDB is flushing. * (Until this user calls of 'lv_flush_ready()' in the display drivers's flush function*/ + while(vdb_flushing); return &vdb; diff --git a/lv_hal/lv_hal_disp.c b/lv_hal/lv_hal_disp.c index 5df264386..8169a551b 100644 --- a/lv_hal/lv_hal_disp.c +++ b/lv_hal/lv_hal_disp.c @@ -66,6 +66,10 @@ void lv_disp_drv_init(lv_disp_drv_t * driver) #if LV_VDB_SIZE driver->vdb_wr = NULL; + driver->vdb = NULL; + driver->vdb2 = NULL; + driver->vdb_size = 0; + driver->vdb_double = 0; #endif } @@ -77,26 +81,27 @@ void lv_disp_drv_init(lv_disp_drv_t * driver) */ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) { - - lv_disp_t * node = lv_ll_ins_head(&LV_GC_ROOT(_lv_disp_ll)); - if(!node) { - lv_mem_assert(node); + lv_disp_t * disp = lv_ll_ins_head(&LV_GC_ROOT(_lv_disp_ll)); + if(!disp) { + lv_mem_assert(disp); return NULL; } - memcpy(&node->driver, driver, sizeof(lv_disp_drv_t)); + memcpy(&disp->driver, driver, sizeof(lv_disp_drv_t)); - lv_ll_init(&node->scr_ll, sizeof(lv_obj_t)); + lv_ll_init(&disp->scr_ll, sizeof(lv_obj_t)); - node->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/ - node->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/ - node->sys_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/ - lv_obj_set_style(node->top_layer, &lv_style_transp); - lv_obj_set_style(node->sys_layer, &lv_style_transp); + disp->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/ + disp->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/ + disp->sys_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/ + lv_obj_set_style(disp->top_layer, &lv_style_transp); + lv_obj_set_style(disp->sys_layer, &lv_style_transp); - node->inv_p = 0; + disp->inv_p = 0; + disp->vdb_act = 0; + disp->vdb_flushing = 0; - return node; + return disp; } lv_disp_t * lv_disp_get_next(lv_disp_t * disp) diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index 6480824a2..4d1601e19 100644 --- a/lv_hal/lv_hal_disp.h +++ b/lv_hal/lv_hal_disp.h @@ -39,6 +39,8 @@ struct _disp_t; * Display Driver structure to be registered by HAL */ typedef struct _disp_drv_t { + void * user_data; + lv_coord_t hor_res; lv_coord_t ver_res; @@ -62,6 +64,11 @@ typedef struct _disp_drv_t { #endif #if LV_VDB_SIZE + void * vdb; + void * vdb2; + uint32_t vdb_size; + uint32_t vdb_double :1; + /*Optional: Set a pixel in a buffer according to the requirements of the display*/ void (*vdb_wr)(uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa); #endif @@ -70,7 +77,6 @@ typedef struct _disp_drv_t { struct _lv_obj_t; typedef struct _disp_t { - void * user_data; lv_disp_drv_t driver; lv_ll_t scr_ll; struct _lv_obj_t * act_scr; @@ -78,8 +84,10 @@ typedef struct _disp_t { struct _lv_obj_t * sys_layer; lv_area_t inv_areas[LV_INV_BUF_SIZE]; uint8_t inv_area_joined[LV_INV_BUF_SIZE]; - uint16_t inv_p :10; - uint16_t orientation :2; + uint32_t inv_p :10; + uint32_t orientation :2; + uint32_t vdb_flushing :1; + uint32_t vdb_act :1; } lv_disp_t; /********************** diff --git a/lv_hal/lv_hal_indev.h b/lv_hal/lv_hal_indev.h index b67a7c3eb..2186e2dab 100644 --- a/lv_hal/lv_hal_indev.h +++ b/lv_hal/lv_hal_indev.h @@ -48,13 +48,13 @@ typedef uint8_t lv_indev_state_t; /*Data type when an input device is read */ typedef struct { + void *user_data; /*'lv_indev_drv_t.priv' for this driver*/ union { lv_point_t point; /*For LV_INDEV_TYPE_POINTER the currently pressed point*/ uint32_t key; /*For LV_INDEV_TYPE_KEYPAD the currently pressed key*/ uint32_t btn; /*For LV_INDEV_TYPE_BUTTON the currently pressed button*/ int16_t enc_diff; /*For LV_INDEV_TYPE_ENCODER number of steps since the previous read*/ }; - void *user_data; /*'lv_indev_drv_t.priv' for this driver*/ lv_indev_state_t state; /*LV_INDEV_STATE_REL or LV_INDEV_STATE_PR*/ } lv_indev_data_t; From 673892cd8092625303f1baf7cd931cfa0b9e14b4 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 13 Feb 2019 01:40:22 +0100 Subject: [PATCH 08/17] multi-disp: unique VDB to displays --- lv_conf_checker.h | 4 +- lv_core/lv_indev.c | 9 - lv_core/lv_obj.c | 1 - lv_core/lv_obj.h | 13 - lv_core/lv_refr.c | 296 +++++++++--------- lv_core/lv_refr.h | 9 + lv_core/lv_vdb.c | 212 ------------- lv_core/lv_vdb.h | 119 ------- lv_draw/lv_draw.c | 25 +- lv_draw/lv_draw.h | 7 +- lv_draw/lv_draw_arc.c | 4 +- lv_draw/{lv_draw_vbasic.c => lv_draw_basic.c} | 112 +++---- lv_draw/{lv_draw_vbasic.h => lv_draw_basic.h} | 20 +- lv_draw/lv_draw_img.c | 4 +- lv_draw/lv_draw_label.c | 9 +- lv_draw/lv_draw_line.c | 20 +- lv_draw/lv_draw_rbasic.c | 277 ---------------- lv_draw/lv_draw_rbasic.h | 96 ------ lv_draw/lv_draw_rect.c | 212 ++++++------- lv_draw/lv_draw_triangle.c | 2 +- lv_hal/lv_hal_disp.c | 36 ++- lv_hal/lv_hal_disp.h | 38 ++- lv_objx/lv_cont.c | 2 +- lvgl.h | 1 - 24 files changed, 381 insertions(+), 1147 deletions(-) delete mode 100644 lv_core/lv_vdb.c delete mode 100644 lv_core/lv_vdb.h rename lv_draw/{lv_draw_vbasic.c => lv_draw_basic.c} (89%) rename lv_draw/{lv_draw_vbasic.h => lv_draw_basic.h} (80%) delete mode 100644 lv_draw/lv_draw_rbasic.c delete mode 100644 lv_draw/lv_draw_rbasic.h diff --git a/lv_conf_checker.h b/lv_conf_checker.h index 6805efc66..fa8748d8f 100644 --- a/lv_conf_checker.h +++ b/lv_conf_checker.h @@ -100,7 +100,7 @@ * Setting it to 0 will disable VDB and `disp_drv.disp_fill` and `disp_drv.disp_map` functions * will be called to draw to the frame buffer directly*/ #ifndef LV_VDB_SIZE -#define LV_VDB_SIZE ((LV_VER_RES * LV_HOR_RES) / 10) +//#define LV_VDB_SIZE ((LV_VER_RES * LV_HOR_RES) / 10) #endif /* Bit-per-pixel of VDB. Useful for monochrome or non-standard color format displays. @@ -113,7 +113,7 @@ * 0: allocate automatically into RAM * LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/ #ifndef LV_VDB_ADR -#define LV_VDB_ADR 0 +//#define LV_VDB_ADR 0 #endif /* Use two Virtual Display buffers (VDB) to parallelize rendering and flushing diff --git a/lv_core/lv_indev.c b/lv_core/lv_indev.c index 666372fcf..bdf348d5b 100644 --- a/lv_core/lv_indev.c +++ b/lv_core/lv_indev.c @@ -15,7 +15,6 @@ #include "../lv_core/lv_refr.h" #include "../lv_misc/lv_task.h" #include "../lv_misc/lv_math.h" -#include "../lv_draw/lv_draw_rbasic.h" /********************* * DEFINES @@ -367,14 +366,6 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data) i->proc.act_point.y = data->point.y; if(i->proc.state == LV_INDEV_STATE_PR) { -#if LV_INDEV_POINT_MARKER != 0 - lv_area_t area; - area.x1 = i->proc.act_point.x - (LV_INDEV_POINT_MARKER >> 1); - area.y1 = i->proc.act_point.y - (LV_INDEV_POINT_MARKER >> 1); - area.x2 = i->proc.act_point.x + ((LV_INDEV_POINT_MARKER >> 1) | 0x1); - area.y2 = i->proc.act_point.y + ((LV_INDEV_POINT_MARKER >> 1) | 0x1); - lv_rfill(&area, NULL, LV_COLOR_MAKE(0xFF, 0, 0), LV_OPA_COVER); -#endif indev_proc_press(&i->proc); } else { indev_proc_release(&i->proc); diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index b54f9bea6..891428e04 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -12,7 +12,6 @@ #include "lv_group.h" #include "../lv_themes/lv_theme.h" #include "../lv_draw/lv_draw.h" -#include "../lv_draw/lv_draw_rbasic.h" #include "../lv_misc/lv_anim.h" #include "../lv_misc/lv_task.h" #include "../lv_misc/lv_fs.h" diff --git a/lv_core/lv_obj.h b/lv_core/lv_obj.h index f291c3634..29f3ac9dd 100644 --- a/lv_core/lv_obj.h +++ b/lv_core/lv_obj.h @@ -42,19 +42,6 @@ extern "C" { #error "LittlevGL: LV_ANTIALIAS can be only 0 or 1" #endif -#if LV_VDB_SIZE == 0 && LV_ANTIALIAS != 0 -#error "LittlevGL: If LV_VDB_SIZE == 0 the anti-aliasing must be disabled" -#endif - -#if LV_VDB_SIZE > 0 && LV_VDB_SIZE < LV_HOR_RES -#error "LittlevGL: Small Virtual Display Buffer (lv_conf.h: LV_VDB_SIZE >= LV_HOR_RES)" -#endif - -#if LV_VDB_SIZE == 0 && USE_LV_REAL_DRAW == 0 -#error "LittlevGL: If LV_VDB_SIZE = 0 Real drawing function are required (lv_conf.h: USE_LV_REAL_DRAW 1)" -#endif - - #define LV_ANIM_IN 0x00 /*Animation to show an object. 'OR' it with lv_anim_builtin_t*/ #define LV_ANIM_OUT 0x80 /*Animation to hide an object. 'OR' it with lv_anim_builtin_t*/ #define LV_ANIM_DIR_MASK 0x80 /*ANIM_IN/ANIM_OUT mask*/ diff --git a/lv_core/lv_refr.c b/lv_core/lv_refr.c index c83737282..8d833017e 100644 --- a/lv_core/lv_refr.c +++ b/lv_core/lv_refr.c @@ -8,7 +8,6 @@ *********************/ #include #include "lv_refr.h" -#include "lv_vdb.h" #include "lv_disp.h" #include "../lv_hal/lv_hal_tick.h" #include "../lv_hal/lv_hal_disp.h" @@ -30,15 +29,12 @@ static void lv_refr_task(void * param); static void lv_refr_join_area(void); static void lv_refr_areas(void); -#if LV_VDB_SIZE == 0 -static void lv_refr_area_no_vdb(const lv_area_t * area_p); -#else -static void lv_refr_area_with_vdb(const lv_area_t * area_p); -static void lv_refr_area_part_vdb(const lv_area_t * area_p); -#endif +static void lv_refr_area(const lv_area_t * area_p); +static void lv_refr_area_part(const lv_area_t * area_p); static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj); static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p); static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p); +static void lv_refr_vdb_flush(void); /********************** * STATIC VARIABLES @@ -66,6 +62,19 @@ void lv_refr_init(void) lv_task_ready(task); /*Be sure the screen will be refreshed immediately on start up*/ } +/** + * Call in the display driver's 'disp_flush' function when the flushing is finished + */ +LV_ATTRIBUTE_FLUSH_READY void lv_flush_ready(lv_disp_t * disp) +{ + disp->driver.buffer->internal.flushing = 0; + + /*If the screen is transparent initialize it when the flushing is ready*/ +#if LV_VDB_DOUBLE == 0 && LV_COLOR_SCREEN_TRANSP + memset(vdb_buf, 0x00, LV_VDB_SIZE_IN_BYTES); +#endif +} + /** * Redraw the invalidated areas now. * Normally the redrawing is periodically executed in `lv_task_handler` but a long blocking process can @@ -126,6 +135,7 @@ void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p) } } + /** * Set a function to call after every refresh to announce the refresh time and the number of refreshed pixels * @param cb pointer to a callback function (void my_refr_cb(uint32_t time_ms, uint32_t px_num)) @@ -182,42 +192,35 @@ static void lv_refr_task(void * param) /*If refresh happened ...*/ if(disp_refr->inv_p != 0) { - /*In true double buffered mode copy the refreshed areas to the new VDB to keep it up to date*/ - #if LV_VDB_TRUE_DOUBLE_BUFFERED - lv_vdb_t * vdb_p = lv_vdb_get(); - vdb_p->area.x1 = 0; - vdb_p->area.x2 = LV_HOR_RES-1; - vdb_p->area.y1 = 0; - vdb_p->area.y2 = LV_VER_RES - 1; + if(lv_disp_is_true_double_buffered(disp_refr)) { + lv_vdb_t * vdb = lv_disp_get_vdb(disp_refr); - /*Flush the content of the VDB*/ - lv_vdb_flush(); + /*Flush the content of the VDB*/ + lv_refr_vdb_flush(); - /* With true double buffering the flushing should be only the address change of the current frame buffer - * Wait until the address change is ready and copy the active content to the other frame buffer (new active VDB) - * The changes will be written to the new VDB.*/ - lv_vdb_t * vdb_act = lv_vdb_get_active(); - lv_vdb_t * vdb_ina = lv_vdb_get_inactive(); + /* With true double buffering the flushing should be only the address change of the current frame buffer. + * Wait until the address change is ready and copy the changed content to the other frame buffer (new active VDB) + * to keep the buffers synchronized*/ + while(vdb->internal.flushing); - uint8_t * buf_act = (uint8_t *) vdb_act->buf; - uint8_t * buf_ina = (uint8_t *) vdb_ina->buf; + uint8_t * buf_act = (uint8_t *) vdb->buf_act; + uint8_t * buf_ina = (uint8_t *) vdb->buf_act == vdb->buf1 ? vdb->buf2 : vdb->buf1; - uint16_t a; - for(a = 0; a < inv_buf_p; a++) { - if(inv_buf[a].joined == 0) { - lv_coord_t y; - uint32_t start_offs = ((LV_HOR_RES * inv_buf[a].area.y1 + inv_buf[a].area.x1) * LV_VDB_PX_BPP) >> 3; - uint32_t line_length = (lv_area_get_width(&inv_buf[a].area) * LV_VDB_PX_BPP) >> 3; + uint16_t a; + for(a = 0; a < disp_refr->inv_p; a++) { + if(disp_refr->inv_area_joined[a] == 0) { + lv_coord_t y; + uint32_t start_offs = ((disp_refr->driver.hor_res * disp_refr->inv_areas[a].y1 + disp_refr->inv_areas[a].x1) * LV_VDB_PX_BPP) >> 3; + uint32_t line_length = (lv_area_get_width(&disp_refr->inv_areas[a]) * LV_VDB_PX_BPP) >> 3; - for(y = inv_buf[a].area.y1; y <= inv_buf[a].area.y2; y++) { - memcpy(buf_act + start_offs, buf_ina + start_offs, line_length); - start_offs += (LV_HOR_RES * LV_VDB_PX_BPP) >> 3; + for(y = disp_refr->inv_areas[a].y1; y <= disp_refr->inv_areas[a].y2; y++) { + memcpy(buf_act + start_offs, buf_ina + start_offs, line_length); + start_offs += (LV_HOR_RES * LV_VDB_PX_BPP) >> 3; + } } } - } - - #endif + } /*End of true double buffer handling*/ /*Clean up*/ memset(disp_refr->inv_areas, 0, sizeof(disp_refr->inv_areas)); @@ -285,146 +288,112 @@ static void lv_refr_areas(void) for(i = 0; i < disp_refr->inv_p; i++) { /*Refresh the unjoined areas*/ if(disp_refr->inv_area_joined[i] == 0) { - /*If there is no VDB do simple drawing*/ -#if LV_VDB_SIZE == 0 - lv_refr_area_no_vdb(&inv_buf[i].area); -#else - /*If VDB is used...*/ - lv_refr_area_with_vdb(&disp_refr->inv_areas[i]); -#endif + + lv_refr_area(&disp_refr->inv_areas[i]); + if(monitor_cb != NULL) px_num += lv_area_get_size(&disp_refr->inv_areas[i]); } } - } -#if LV_VDB_SIZE == 0 -/** - * Refresh an area if there is no Virtual Display Buffer - * @param area_p pointer to an area to refresh - */ -static void lv_refr_area_no_vdb(const lv_area_t * area_p) -{ - lv_obj_t * top_p; - - /*Get top object which is not covered by others*/ - top_p = lv_refr_get_top_obj(area_p, lv_scr_act()); - - /*Do the refreshing*/ - lv_refr_obj_and_children(top_p, area_p); - - /*Also refresh top and sys layer unconditionally*/ - lv_refr_obj_and_children(lv_layer_top(), area_p); - lv_refr_obj_and_children(lv_layer_sys(), area_p); -} - -#else - /** * Refresh an area if there is Virtual Display Buffer * @param area_p pointer to an area to refresh */ -static void lv_refr_area_with_vdb(const lv_area_t * area_p) +static void lv_refr_area(const lv_area_t * area_p) { - -#if LV_VDB_TRUE_DOUBLE_BUFFERED == 0 - /*Calculate the max row num*/ - lv_coord_t w = lv_area_get_width(area_p); - lv_coord_t h = lv_area_get_height(area_p); - lv_coord_t y2 = area_p->y2 >= lv_disp_get_ver_res(NULL) ? y2 = lv_disp_get_ver_res(NULL) - 1 : area_p->y2; - - int32_t max_row = (uint32_t) LV_VDB_SIZE / w; - - if(max_row > h) max_row = h; - - - /*Round down the lines of VDB if rounding is added*/ - if(round_cb) { - lv_area_t tmp; - tmp.x1 = 0; - tmp.x2 = 0; - tmp.y1 = 0; - tmp.y2 = max_row; - - lv_coord_t y_tmp = max_row; - do { - tmp.y2 = y_tmp; - round_cb(&tmp); - y_tmp --; /*Decrement the number of line until it is rounded to a smaller (or equal) value then the original. */ - } while(lv_area_get_height(&tmp) > max_row && y_tmp != 0); - - if(y_tmp == 0) { - LV_LOG_WARN("Can't set VDB height using the round function. (Wrong round_cb or to small VDB)"); - return; - } else { - max_row = tmp.y2 + 1; - } + /*True double buffering: there are two screen sized buffers. Just redraw directly into a buffer*/ + if(lv_disp_is_true_double_buffered(disp_refr)) { + lv_vdb_t * vdb = lv_disp_get_vdb(disp_refr); + vdb->area.x1 = 0; + vdb->area.x2 = LV_HOR_RES-1; + vdb->area.y1 = 0; + vdb->area.y2 = LV_VER_RES - 1; + lv_refr_area_part(area_p); } + /*The buffer is smaller: refresh the area in parts*/ + else { + lv_vdb_t * vdb = lv_disp_get_vdb(disp_refr); + /*Calculate the max row num*/ + lv_coord_t w = lv_area_get_width(area_p); + lv_coord_t h = lv_area_get_height(area_p); + lv_coord_t y2 = area_p->y2 >= lv_disp_get_ver_res(NULL) ? y2 = lv_disp_get_ver_res(NULL) - 1 : area_p->y2; - /*Always use the full row*/ - lv_coord_t row; - lv_coord_t row_last = 0; - for(row = area_p->y1; row + max_row - 1 <= y2; row += max_row) { - lv_vdb_t * vdb_p = lv_vdb_get(); - if(!vdb_p) { - LV_LOG_WARN("Invalid VDB pointer"); - return; + int32_t max_row = (uint32_t) vdb->size / w; + + if(max_row > h) max_row = h; + + /*Round down the lines of VDB if rounding is added*/ + if(round_cb) { + lv_area_t tmp; + tmp.x1 = 0; + tmp.x2 = 0; + tmp.y1 = 0; + tmp.y2 = max_row; + + lv_coord_t y_tmp = max_row; + do { + tmp.y2 = y_tmp; + round_cb(&tmp); + y_tmp --; /*Decrement the number of line until it is rounded to a smaller (or equal) value then the original. */ + } while(lv_area_get_height(&tmp) > max_row && y_tmp != 0); + + if(y_tmp == 0) { + LV_LOG_WARN("Can't set VDB height using the round function. (Wrong round_cb or to small VDB)"); + return; + } else { + max_row = tmp.y2 + 1; + } } - /*Calc. the next y coordinates of VDB*/ - vdb_p->area.x1 = area_p->x1; - vdb_p->area.x2 = area_p->x2; - vdb_p->area.y1 = row; - vdb_p->area.y2 = row + max_row - 1; - if(vdb_p->area.y2 > y2) vdb_p->area.y2 = y2; - row_last = vdb_p->area.y2; - lv_refr_area_part_vdb(area_p); - } - - /*If the last y coordinates are not handled yet ...*/ - if(y2 != row_last) { - lv_vdb_t * vdb_p = lv_vdb_get(); - if(!vdb_p) { - LV_LOG_WARN("Invalid VDB pointer"); - return; + /*Always use the full row*/ + lv_coord_t row; + lv_coord_t row_last = 0; + for(row = area_p->y1; row + max_row - 1 <= y2; row += max_row) { + /*Calc. the next y coordinates of VDB*/ + vdb->area.x1 = area_p->x1; + vdb->area.x2 = area_p->x2; + vdb->area.y1 = row; + vdb->area.y2 = row + max_row - 1; + if(vdb->area.y2 > y2) vdb->area.y2 = y2; + row_last = vdb->area.y2; + lv_refr_area_part(area_p); } - /*Calc. the next y coordinates of VDB*/ - vdb_p->area.x1 = area_p->x1; - vdb_p->area.x2 = area_p->x2; - vdb_p->area.y1 = row; - vdb_p->area.y2 = y2; + /*If the last y coordinates are not handled yet ...*/ + if(y2 != row_last) { + /*Calc. the next y coordinates of VDB*/ + vdb->area.x1 = area_p->x1; + vdb->area.x2 = area_p->x2; + vdb->area.y1 = row; + vdb->area.y2 = y2; - /*Refresh this part too*/ - lv_refr_area_part_vdb(area_p); + /*Refresh this part too*/ + lv_refr_area_part(area_p); + } } -#else - lv_vdb_t * vdb_p = lv_vdb_get(); - vdb_p->area.x1 = 0; - vdb_p->area.x2 = LV_HOR_RES-1; - vdb_p->area.y1 = 0; - vdb_p->area.y2 = LV_VER_RES - 1; - lv_refr_area_part_vdb(area_p); -#endif } /** * Refresh a part of an area which is on the actual Virtual Display Buffer * @param area_p pointer to an area to refresh */ -static void lv_refr_area_part_vdb(const lv_area_t * area_p) +static void lv_refr_area_part(const lv_area_t * area_p) { - lv_vdb_t * vdb_p = lv_vdb_get(); - if(!vdb_p) { - LV_LOG_WARN("Invalid VDB pointer"); - return; + + lv_vdb_t * vdb = lv_disp_get_vdb(disp_refr); + + /*In non double buffered mode, before rendering the next part wait until the previous image is flushed*/ + if(lv_disp_is_double_vdb(disp_refr) == false) { + while(vdb->internal.flushing); } + lv_obj_t * top_p; /*Get the new mask from the original area and the act. VDB It will be a part of 'area_p'*/ lv_area_t start_mask; - lv_area_intersect(&start_mask, area_p, &vdb_p->area); + lv_area_intersect(&start_mask, area_p, &vdb->area); /*Get the most top object which is not covered by others*/ top_p = lv_refr_get_top_obj(&start_mask, lv_scr_act(disp_refr)); @@ -438,14 +407,11 @@ static void lv_refr_area_part_vdb(const lv_area_t * area_p) /* In true double buffered mode flush only once when all areas were rendered. * In normal mode flush after every area */ -#if LV_VDB_TRUE_DOUBLE_BUFFERED == 0 - /*Flush the content of the VDB*/ - lv_vdb_flush(); -#endif + if(lv_disp_is_true_double_buffered(disp_refr) == false) { + lv_refr_vdb_flush(); + } } -#endif /*LV_VDB_SIZE == 0*/ - /** * Search the most top object which fully covers an area * @param area_p pointer to an area @@ -593,3 +559,33 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p) } } + +/** + * Flush the content of the VDB + */ +static void lv_refr_vdb_flush(void) +{ + lv_vdb_t * vdb = lv_disp_get_vdb(lv_refr_get_disp_refreshing()); + + /*In double buffered mode wait until the other buffer is flushed before flushing the current one*/ + if(vdb->buf1 && vdb->buf2) { + while(vdb->internal.flushing); + } + + vdb->internal.flushing = 1; + + /*Flush the rendered content to the display*/ + lv_disp_t * disp = lv_refr_get_disp_refreshing(); + if(disp->driver.disp_flush) disp->driver.disp_flush(disp, &vdb->area, vdb->buf_act); + + + if(vdb->buf1 && vdb->buf2) { + if(vdb->buf_act == vdb->buf1) vdb->buf_act = vdb->buf2; + else vdb->buf_act = vdb->buf1; + + /*If the screen is transparent initialize it when the new VDB is selected*/ +# if LV_COLOR_SCREEN_TRANSP + memset(vdb[vdb_active].buf, 0x00, LV_VDB_SIZE_IN_BYTES); +# endif /*LV_COLOR_SCREEN_TRANSP*/ + } +} diff --git a/lv_core/lv_refr.h b/lv_core/lv_refr.h index 14f75dd16..e27252bc7 100644 --- a/lv_core/lv_refr.h +++ b/lv_core/lv_refr.h @@ -19,6 +19,9 @@ extern "C" { /********************* * DEFINES *********************/ +#ifndef LV_ATTRIBUTE_FLUSH_READY +# define LV_ATTRIBUTE_FLUSH_READY +#endif /********************** * TYPEDEFS @@ -45,6 +48,11 @@ extern "C" { */ void lv_refr_init(void); +/** + * Call in the display driver's 'disp_flush' function when the flushing is finished + */ +LV_ATTRIBUTE_FLUSH_READY void lv_flush_ready(lv_disp_t * disp); + /** * Redraw the invalidated areas now. * Normally the redrawing is periodically executed in `lv_task_handler` but a long blocking process can @@ -60,6 +68,7 @@ void lv_refr_now(void); */ void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p); + /** * Set a function to call after every refresh to announce the refresh time and the number of refreshed pixels * @param cb pointer to a callback function (void my_refr_cb(uint32_t time_ms, uint32_t px_num)) diff --git a/lv_core/lv_vdb.c b/lv_core/lv_vdb.c deleted file mode 100644 index ffde701e2..000000000 --- a/lv_core/lv_vdb.c +++ /dev/null @@ -1,212 +0,0 @@ -/** - * @file lv_vdb.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include "lv_vdb.h" -#if LV_VDB_SIZE != 0 - -#include "../lv_hal/lv_hal_disp.h" -#include "../lv_misc/lv_log.h" -#include "../lv_core/lv_refr.h" -#include - -/********************* - * DEFINES - *********************/ -#ifndef LV_ATTRIBUTE_FLUSH_READY -#define LV_ATTRIBUTE_FLUSH_READY -#endif - -#ifndef LV_ATTRIBUTE_MEM_ALIGN -#define LV_ATTRIBUTE_MEM_ALIGN -#endif - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ - -/*Simple VDB*/ -#if LV_VDB_DOUBLE == 0 -# if LV_VDB_ADR == 0 -/*If the buffer address is not specified simply allocate it*/ -static LV_ATTRIBUTE_MEM_ALIGN uint8_t vdb_buf[LV_VDB_SIZE_IN_BYTES]; -static lv_vdb_t vdb = {.buf = (lv_color_t *)vdb_buf}; -# else /*LV_VDB_ADR != 0*/ -/*If the buffer address is specified use that address*/ -static lv_vdb_t vdb = {.buf = (lv_color_t *)LV_VDB_ADR}; -# endif - -/*LV_VDB_DOUBLE != 0*/ -#else -/*Double VDB*/ -static uint8_t vdb_active = 0; -# if LV_VDB_ADR == 0 -/*If the buffer address is not specified simply allocate it*/ -static LV_ATTRIBUTE_MEM_ALIGN uint8_t vdb_buf1[LV_VDB_SIZE_IN_BYTES]; -static LV_ATTRIBUTE_MEM_ALIGN uint8_t vdb_buf2[LV_VDB_SIZE_IN_BYTES]; -static lv_vdb_t vdb[2] = {{.buf = (lv_color_t *) vdb_buf1}, {.buf = (lv_color_t *) vdb_buf2}}; -# else /*LV_VDB_ADR != 0*/ -/*If the buffer address is specified use that address*/ -static lv_vdb_t vdb[2] = {{.buf = (lv_color_t *)LV_VDB_ADR}, {.buf = (lv_color_t *)LV_VDB2_ADR}}; -# endif -#endif - -static volatile bool vdb_flushing = false; - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/** - * Get the 'vdb' variable or allocate one in LV_VDB_DOUBLE mode - * @return pointer to a 'vdb' variable - */ -lv_vdb_t * lv_vdb_get(void) -{ - lv_disp_t * disp = lv_refr_get_disp_refreshing(); - -#if LV_VDB_DOUBLE == 0 - /* Wait until VDB is flushing. - * (Until this user calls of 'lv_flush_ready()' in the display drivers's flush function*/ - - while(vdb_flushing); - - return &vdb; -#else - /*If already there is an active do nothing*/ - return &vdb[vdb_active]; -#endif -} - -/** - * Flush the content of the VDB - */ -void lv_vdb_flush(void) -{ - lv_vdb_t * vdb_act = lv_vdb_get(); - if(!vdb_act) { - LV_LOG_WARN("Invalid VDB pointer"); - return; - } - - /*Don't start a new flush while the previous is not finished*/ -#if LV_VDB_DOUBLE - while(vdb_flushing); -#endif /*LV_VDB_DOUBLE*/ - - vdb_flushing = true; - - /*Flush the rendered content to the display*/ - lv_disp_t * disp = lv_refr_get_disp_refreshing(); - if(disp->driver.disp_flush) disp->driver.disp_flush(disp, &vdb_act->area, vdb_act->buf); - - -#if LV_VDB_DOUBLE - /*Make the other VDB active. The content of the current will be kept until the next flush*/ - vdb_active++; - vdb_active &= 0x1; - - /*If the screen is transparent initialize it when the new VDB is selected*/ -# if LV_COLOR_SCREEN_TRANSP - memset(vdb[vdb_active].buf, 0x00, LV_VDB_SIZE_IN_BYTES); -# endif /*LV_COLOR_SCREEN_TRANSP*/ - -#endif /*#if LV_VDB_DOUBLE*/ - -} - -/** - * Set the address of VDB buffer(s) manually. To use this set `LV_VDB_ADR` (and `LV_VDB2_ADR`) to `LV_VDB_ADR_INV` in `lv_conf.h`. - * It should be called before `lv_init()`. The size of the buffer should be: `LV_VDB_SIZE_IN_BYTES` - * @param buf1 address of the VDB. - * @param buf2 address of the second buffer. `NULL` if `LV_VDB_DOUBLE 0` - */ -void lv_vdb_set_adr(void * buf1, void * buf2) -{ -#if LV_VDB_DOUBLE == 0 - (void) buf2; /*unused*/ - vdb.buf = buf1; -#else - vdb[0].buf = buf1; - vdb[1].buf = buf2; -#endif -} - -/** - * Call in the display driver's 'disp_flush' function when the flushing is finished - */ -LV_ATTRIBUTE_FLUSH_READY void lv_flush_ready(void) -{ - vdb_flushing = false; - - /*If the screen is transparent initialize it when the flushing is ready*/ -#if LV_VDB_DOUBLE == 0 && LV_COLOR_SCREEN_TRANSP - memset(vdb_buf, 0x00, LV_VDB_SIZE_IN_BYTES); -#endif -} - -/** - * Get currently active VDB, where the drawing happens. Used with `LV_VDB_DOUBLE 1` - * @return pointer to the active VDB. If `LV_VDB_DOUBLE 0` give the single VDB - */ -lv_vdb_t * lv_vdb_get_active(void) -{ -#if LV_VDB_DOUBLE == 0 - return &vdb; -#else - return &vdb[vdb_active]; -#endif -} - -/** - * Get currently inactive VDB, which is being displayed or being flushed. Used with `LV_VDB_DOUBLE 1` - * @return pointer to the inactive VDB. If `LV_VDB_DOUBLE 0` give the single VDB - */ -lv_vdb_t * lv_vdb_get_inactive(void) -{ -#if LV_VDB_DOUBLE == 0 - return &vdb; -#else - return &vdb[(vdb_active + 1) & 0x1]; -#endif -} - -/** - * Whether the flushing is in progress or not - * @return true: flushing is in progress; false: flushing ready - */ -bool lv_vdb_is_flushing(void) -{ - return vdb_flushing; -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -#else - -/** - * Just for compatibility - */ -void lv_flush_ready(void) -{ - /*Do nothing. It is used only for VDB*/ -} -#endif diff --git a/lv_core/lv_vdb.h b/lv_core/lv_vdb.h deleted file mode 100644 index e94ba1980..000000000 --- a/lv_core/lv_vdb.h +++ /dev/null @@ -1,119 +0,0 @@ -/** - * @file lv_vdb.h - * - */ - -#ifndef LV_VDB_H -#define LV_VDB_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#ifdef LV_CONF_INCLUDE_SIMPLE -#include "lv_conf.h" -#else -#include "../../lv_conf.h" -#endif - -#if LV_VDB_SIZE != 0 - -#include "../lv_misc/lv_color.h" -#include "../lv_misc/lv_area.h" - -/********************* - * DEFINES - *********************/ -/*Can be used in `lv_conf.h` the set an invalid address for the VDB. It should be replaced later by a valid address using `lv_vdb_set_adr()`*/ -#define LV_VDB_ADR_INV 8 /*8 is still too small to be valid but it's aligned on 64 bit machines as well*/ - -#ifndef LV_VDB_PX_BPP -#define LV_VDB_PX_BPP LV_COLOR_SIZE /* Default is LV_COLOR_SIZE */ -#endif - - -#if LV_VDB_TRUE_DOUBLE_BUFFERED && (LV_VDB_SIZE != LV_HOR_RES * LV_VER_RES || LV_VDB_DOUBLE == 0) -#error "With LV_VDB_TRUE_DOUBLE_BUFFERED: (LV_VDB_SIZE = LV_HOR_RES * LV_VER_RES and LV_VDB_DOUBLE = 1 is required" -#endif - - -/* The size of VDB in bytes. - * (LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3): just divide by 8 to convert bits to bytes - * (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0): add an extra byte to round up. - * E.g. if LV_VDB_SIZE = 10 and LV_VDB_PX_BPP = 1 -> 10 bits -> 2 bytes*/ -#define LV_VDB_SIZE_IN_BYTES ((LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3) + (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0) - -/********************** - * TYPEDEFS - **********************/ - -typedef struct -{ - lv_area_t area; - lv_color_t *buf; -} lv_vdb_t; - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/** - * Get the 'vdb' variable or allocate one in LV_VDB_DOUBLE mode - * @return pointer to a 'vdb' variable - */ -lv_vdb_t * lv_vdb_get(void); - -/** - * Flush the content of the vdb - */ -void lv_vdb_flush(void); - -/** - * Set the address of VDB buffer(s) manually. To use this set `LV_VDB_ADR` (and `LV_VDB2_ADR`) to `LV_VDB_ADR_INV` in `lv_conf.h`. - * It should be called before `lv_init()`. The size of the buffer should be: `LV_VDB_SIZE_IN_BYTES` - * @param buf1 address of the VDB. - * @param buf2 address of the second buffer. `NULL` if `LV_VDB_DOUBLE 0` - */ -void lv_vdb_set_adr(void * buf1, void * buf2); - -/** - * Call in the display driver's 'disp_flush' function when the flushing is finished - */ -void lv_flush_ready(void); - -/** - * Get currently active VDB, where the drawing happens. Used with `LV_VDB_DOUBLE 1` - * @return pointer to the active VDB. If `LV_VDB_DOUBLE 0` give the single VDB - */ -lv_vdb_t * lv_vdb_get_active(void); - -/** - * Get currently inactive VDB, which is being displayed or being flushed. Used with `LV_VDB_DOUBLE 1` - * @return pointer to the inactive VDB. If `LV_VDB_DOUBLE 0` give the single VDB - */ -lv_vdb_t * lv_vdb_get_inactive(void); - -/** - * Whether the flushing is in progress or not - * @return true: flushing is in progress; false: flushing ready - */ -bool lv_vdb_is_flushing(void); - -/********************** - * MACROS - **********************/ - -#else /*LV_VDB_SIZE != 0*/ - -/*Just for compatibility*/ -void lv_flush_ready(void); -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_VDB_H*/ diff --git a/lv_draw/lv_draw.c b/lv_draw/lv_draw.c index f1137ceb6..af7c8a384 100644 --- a/lv_draw/lv_draw.c +++ b/lv_draw/lv_draw.c @@ -10,12 +10,7 @@ #include #include #include "lv_draw.h" -#include "lv_draw_rbasic.h" -#include "lv_draw_vbasic.h" -#include "../lv_misc/lv_fs.h" #include "../lv_misc/lv_math.h" -#include "../lv_misc/lv_ufs.h" -#include "../lv_objx/lv_img.h" /********************* * DEFINES @@ -33,22 +28,6 @@ * STATIC VARIABLES **********************/ -#if LV_VDB_SIZE != 0 -void (*const px_fp)(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_color_t color, lv_opa_t opa) = lv_vpx; -void (*const fill_fp)(const lv_area_t * coords, const lv_area_t * mask, lv_color_t color, lv_opa_t opa) = lv_vfill; -void (*const letter_fp)(const lv_point_t * pos_p, const lv_area_t * mask, const lv_font_t * font_p, uint32_t letter, lv_color_t color, lv_opa_t opa) = lv_vletter; -void (*const map_fp)(const lv_area_t * cords_p, const lv_area_t * mask_p, - const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte, - lv_color_t recolor, lv_opa_t recolor_opa) = lv_vmap; -#else -void (*const px_fp)(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_color_t color, lv_opa_t opa) = lv_rpx; -void (*const fill_fp)(const lv_area_t * coords, const lv_area_t * mask, lv_color_t color, lv_opa_t opa) = lv_rfill; -void (*const letter_fp)(const lv_point_t * pos_p, const lv_area_t * mask, const lv_font_t * font_p, uint32_t letter, lv_color_t color, lv_opa_t opa) = lv_rletter; -void (*const map_fp)(const lv_area_t * cords_p, const lv_area_t * mask_p, - const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte, - lv_color_t recolor, lv_opa_t recolor_opa) = lv_rmap; -#endif - /********************** * MACROS **********************/ @@ -132,7 +111,7 @@ void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_ for(i = 0; i < length; i++) { lv_opa_t px_opa = lv_draw_aa_get_opa(length, i, opa); if(aa_inv) px_opa = opa - px_opa; - px_fp(x, y + i, mask, color, px_opa); + lv_draw_px(x, y + i, mask, color, px_opa); } } @@ -157,7 +136,7 @@ void lv_draw_aa_hor_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_ for(i = 0; i < length; i++) { lv_opa_t px_opa = lv_draw_aa_get_opa(length, i, opa); if(aa_inv) px_opa = opa - px_opa; - px_fp(x + i, y, mask, color, px_opa); + lv_draw_px(x + i, y, mask, color, px_opa); } } diff --git a/lv_draw/lv_draw.h b/lv_draw/lv_draw.h index cf50e98ce..ccd7b2ce4 100644 --- a/lv_draw/lv_draw.h +++ b/lv_draw/lv_draw.h @@ -88,12 +88,6 @@ void lv_draw_aa_hor_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_ /********************** * GLOBAL VARIABLES **********************/ -extern void (*const px_fp)(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_color_t color, lv_opa_t opa); -extern void (*const fill_fp)(const lv_area_t * coords, const lv_area_t * mask, lv_color_t color, lv_opa_t opa); -extern void (*const letter_fp)(const lv_point_t * pos_p, const lv_area_t * mask, const lv_font_t * font_p, uint32_t letter, lv_color_t color, lv_opa_t opa); -extern void (*const map_fp)(const lv_area_t * cords_p, const lv_area_t * mask_p, - const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte, - lv_color_t recolor, lv_opa_t recolor_opa); /********************** * MACROS @@ -102,6 +96,7 @@ extern void (*const map_fp)(const lv_area_t * cords_p, const lv_area_t * mask_p, /********************** * POST INCLUDES *********************/ +#include "lv_draw_basic.h" #include "lv_draw_rect.h" #include "lv_draw_label.h" #include "lv_draw_img.h" diff --git a/lv_draw/lv_draw_arc.c b/lv_draw/lv_draw_arc.c index 525e56b79..0177d1449 100644 --- a/lv_draw/lv_draw_arc.c +++ b/lv_draw/lv_draw_arc.c @@ -239,7 +239,7 @@ static void ver_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coor lv_area_t area; lv_area_set(&area, x, y, x, y + len); - fill_fp(&area, mask, color, opa); + lv_draw_fill(&area, mask, color, opa); } static void hor_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len, lv_color_t color, lv_opa_t opa) @@ -247,7 +247,7 @@ static void hor_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coor lv_area_t area; lv_area_set(&area, x, y, x + len, y); - fill_fp(&area, mask, color, opa); + lv_draw_fill(&area, mask, color, opa); } static bool deg_test_norm(uint16_t deg, uint16_t start, uint16_t end) diff --git a/lv_draw/lv_draw_vbasic.c b/lv_draw/lv_draw_basic.c similarity index 89% rename from lv_draw/lv_draw_vbasic.c rename to lv_draw/lv_draw_basic.c index e3ead2541..7e7a6d1ed 100644 --- a/lv_draw/lv_draw_vbasic.c +++ b/lv_draw/lv_draw_basic.c @@ -1,9 +1,9 @@ /** - * @file lv_vdraw.c + * @file lv_draw_basic.c * */ -#include "lv_draw_vbasic.h" +#include "lv_draw_basic.h" #include #include @@ -16,10 +16,7 @@ #include "../lv_misc/lv_color.h" #include "../lv_misc/lv_log.h" -#if LV_VDB_SIZE != 0 - #include -#include "../lv_core/lv_vdb.h" #include "lv_draw.h" /********************* @@ -69,16 +66,11 @@ static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa, * @param color pixel color * @param opa opacity of the area (0..255) */ -void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa) +void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa) { if(opa < LV_OPA_MIN) return; if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; - lv_vdb_t * vdb_p = lv_vdb_get(); - if(!vdb_p) { - LV_LOG_WARN("Invalid VDB pointer"); - return; - } /*Pixel out of the mask*/ if(x < mask_p->x1 || x > mask_p->x2 || @@ -86,17 +78,19 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col return; } - uint32_t vdb_width = lv_area_get_width(&vdb_p->area); + lv_disp_t * disp = lv_refr_get_disp_refreshing(); + lv_vdb_t * vdb = lv_disp_get_vdb(disp); + uint32_t vdb_width = lv_area_get_width(&vdb->area); /*Make the coordinates relative to VDB*/ - x -= vdb_p->area.x1; - y -= vdb_p->area.y1; + x -= vdb->area.x1; + y -= vdb->area.y1; - lv_disp_t * disp = lv_refr_get_disp_refreshing(); if(disp->driver.vdb_wr) { - disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, x, y, color, opa); + disp->driver.vdb_wr((uint8_t *)vdb->buf_act, vdb_width, x, y, color, opa); } else { - lv_color_t * vdb_px_p = vdb_p->buf + y * vdb_width + x; + lv_color_t * vdb_px_p = vdb->buf_act; + vdb_px_p += y * vdb_width + x; #if LV_COLOR_SCREEN_TRANSP == 0 if(opa == LV_OPA_COVER) { *vdb_px_p = color; @@ -117,7 +111,7 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col * @param color fill color * @param opa opacity of the area (0..255) */ -void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, +void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa) { if(opa < LV_OPA_MIN) return; @@ -125,11 +119,6 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_area_t res_a; bool union_ok; - lv_vdb_t * vdb_p = lv_vdb_get(); - if(!vdb_p) { - LV_LOG_WARN("Invalid VDB pointer"); - return; - } /*Get the union of cord and mask*/ /* The mask is already truncated to the vdb size @@ -140,15 +129,16 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, if(union_ok == false) return; lv_disp_t * disp = lv_refr_get_disp_refreshing(); + lv_vdb_t * vdb = lv_disp_get_vdb(disp); lv_area_t vdb_rel_a; /*Stores relative coordinates on vdb*/ - vdb_rel_a.x1 = res_a.x1 - vdb_p->area.x1; - vdb_rel_a.y1 = res_a.y1 - vdb_p->area.y1; - vdb_rel_a.x2 = res_a.x2 - vdb_p->area.x1; - vdb_rel_a.y2 = res_a.y2 - vdb_p->area.y1; + vdb_rel_a.x1 = res_a.x1 - vdb->area.x1; + vdb_rel_a.y1 = res_a.y1 - vdb->area.y1; + vdb_rel_a.x2 = res_a.x2 - vdb->area.x1; + vdb_rel_a.y2 = res_a.y2 - vdb->area.y1; - lv_color_t * vdb_buf_tmp = vdb_p->buf; - uint32_t vdb_width = lv_area_get_width(&vdb_p->area); + lv_color_t * vdb_buf_tmp = vdb->buf_act; + uint32_t vdb_width = lv_area_get_width(&vdb->area); /*Move the vdb_tmp to the first row*/ vdb_buf_tmp += vdb_width * vdb_rel_a.y1; @@ -160,7 +150,7 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_coord_t w = lv_area_get_width(&vdb_rel_a); /*Don't use hw. acc. for every small fill (because of the init overhead)*/ if(w < VFILL_HW_ACC_SIZE_LIMIT) { - sw_color_fill(&vdb_p->area, vdb_p->buf, &vdb_rel_a, color, opa); + sw_color_fill(&vdb->area, vdb->buf_act, &vdb_rel_a, color, opa); } /*Not opaque fill*/ else if(opa == LV_OPA_COVER) { @@ -194,7 +184,7 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, } /*Else use sw fill if no better option*/ else { - sw_color_fill(&vdb_p->area, vdb_p->buf, &vdb_rel_a, color, opa); + sw_color_fill(&vdb->area, vdb->buf_act, &vdb_rel_a, color, opa); } } @@ -219,12 +209,12 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, } /*Use sw fill with opa if no better option*/ else { - sw_color_fill(&vdb_p->area, vdb_p->buf, &vdb_rel_a, color, opa); + sw_color_fill(&vdb->area, vdb->buf_act, &vdb_rel_a, color, opa); } } #else - sw_color_fill(&vdb_p->area, vdb_p->buf, &vdb_rel_a, color, opa); + sw_color_fill(&vdb->area, vdb->buf_act, &vdb_rel_a, color, opa); #endif } @@ -237,7 +227,7 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, * @param color color of letter * @param opa opacity of letter (0..255) */ -void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p, +void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv_font_t * font_p, uint32_t letter, lv_color_t color, lv_opa_t opa) { @@ -299,14 +289,11 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p, if(pos_x + letter_w < mask_p->x1 || pos_x > mask_p->x2 || pos_y + letter_h < mask_p->y1 || pos_y > mask_p->y2) return; - lv_vdb_t * vdb_p = lv_vdb_get(); - if(!vdb_p) { - LV_LOG_WARN("Invalid VDB pointer"); - return; - } + lv_disp_t * disp = lv_refr_get_disp_refreshing(); + lv_vdb_t * vdb = lv_disp_get_vdb(disp); - lv_coord_t vdb_width = lv_area_get_width(&vdb_p->area); - lv_color_t * vdb_buf_tmp = vdb_p->buf; + lv_coord_t vdb_width = lv_area_get_width(&vdb->area); + lv_color_t * vdb_buf_tmp = vdb->buf_act; lv_coord_t col, row; uint8_t col_bit; uint8_t col_byte_cnt; @@ -322,8 +309,8 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p, lv_coord_t row_end = pos_y + letter_h <= mask_p->y2 ? letter_h : mask_p->y2 - pos_y + 1; /*Set a pointer on VDB to the first pixel of the letter*/ - vdb_buf_tmp += ((pos_y - vdb_p->area.y1) * vdb_width) - + pos_x - vdb_p->area.x1; + vdb_buf_tmp += ((pos_y - vdb->area.y1) * vdb_width) + + pos_x - vdb->area.x1; /*If the letter is partially out of mask the move there on VDB*/ vdb_buf_tmp += (row_start * vdb_width) + col_start; @@ -331,8 +318,6 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p, /*Move on the map too*/ map_p += (row_start * width_byte_bpp) + ((col_start * bpp) >> 3); - lv_disp_t * disp = lv_refr_get_disp_refreshing(); - uint8_t letter_px; lv_opa_t px_opa; for(row = row_start; row < row_end; row ++) { @@ -351,8 +336,8 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p, } if(disp->driver.vdb_wr) { - disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, - (col + pos_x) - vdb_p->area.x1, (row + pos_y) - vdb_p->area.y1, + disp->driver.vdb_wr((uint8_t *)vdb->buf_act, vdb_width, + (col + pos_x) - vdb->area.x1, (row + pos_y) - vdb->area.y1, color, px_opa); } else { #if LV_COLOR_SCREEN_TRANSP == 0 @@ -392,7 +377,7 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p, * @param recolor mix the pixels with this color * @param recolor_opa the intense of recoloring */ -void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p, +void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte, lv_color_t recolor, lv_opa_t recolor_opa) { @@ -402,11 +387,6 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_area_t masked_a; bool union_ok; - lv_vdb_t * vdb_p = lv_vdb_get(); - if(!vdb_p) { - LV_LOG_WARN("Invalid VDB pointer"); - return; - } /*Get the union of map size and mask*/ /* The mask is already truncated to the vdb size @@ -428,22 +408,23 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p, map_p += (masked_a.x1 - cords_p->x1) * px_size_byte; } - /*Stores coordinates relative to the current VDB*/ - masked_a.x1 = masked_a.x1 - vdb_p->area.x1; - masked_a.y1 = masked_a.y1 - vdb_p->area.y1; - masked_a.x2 = masked_a.x2 - vdb_p->area.x1; - masked_a.y2 = masked_a.y2 - vdb_p->area.y1; + lv_disp_t * disp = lv_refr_get_disp_refreshing(); + lv_vdb_t * vdb = lv_disp_get_vdb(disp); - lv_coord_t vdb_width = lv_area_get_width(&vdb_p->area); - lv_color_t * vdb_buf_tmp = vdb_p->buf; + /*Stores coordinates relative to the current VDB*/ + masked_a.x1 = masked_a.x1 - vdb->area.x1; + masked_a.y1 = masked_a.y1 - vdb->area.y1; + masked_a.x2 = masked_a.x2 - vdb->area.x1; + masked_a.y2 = masked_a.y2 - vdb->area.y1; + + lv_coord_t vdb_width = lv_area_get_width(&vdb->area); + lv_color_t * vdb_buf_tmp = vdb->buf_act; vdb_buf_tmp += (uint32_t) vdb_width * masked_a.y1; /*Move to the first row*/ vdb_buf_tmp += (uint32_t) masked_a.x1; /*Move to the first col*/ lv_coord_t row; lv_coord_t map_useful_w = lv_area_get_width(&masked_a); - lv_disp_t * disp = lv_refr_get_disp_refreshing(); - /*The simplest case just copy the pixels into the VDB*/ if(chroma_key == false && alpha_byte == false && opa == LV_OPA_COVER && recolor_opa == LV_OPA_TRANSP) { @@ -453,7 +434,7 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p, for(row = masked_a.y1; row <= masked_a.y2; row++) { for(col = 0; col < map_useful_w; col++) { lv_color_t px_color = *((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]); - disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa); + disp->driver.vdb_wr((uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa); } map_p += map_width * px_size_byte; /*Next row on the map*/ } @@ -516,7 +497,7 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p, } /*Handle custom VDB write is present*/ if(disp->driver.vdb_wr) { - disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, recolored_px, opa_result); + disp->driver.vdb_wr((uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, recolored_px, opa_result); } /*Normal native VDB write*/ else { @@ -526,7 +507,7 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p, } else { /*Handle custom VDB write is present*/ if(disp->driver.vdb_wr) { - disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa_result); + disp->driver.vdb_wr((uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa_result); } /*Normal native VDB write*/ else { @@ -692,4 +673,3 @@ static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa, } #endif /*LV_COLOR_SCREEN_TRANSP*/ -#endif diff --git a/lv_draw/lv_draw_vbasic.h b/lv_draw/lv_draw_basic.h similarity index 80% rename from lv_draw/lv_draw_vbasic.h rename to lv_draw/lv_draw_basic.h index 88838b7c7..2e52d29d8 100644 --- a/lv_draw/lv_draw_vbasic.h +++ b/lv_draw/lv_draw_basic.h @@ -1,10 +1,10 @@ /** - * @file lv_draw_vbasic.h + * @file lv_draw_basic.h * */ -#ifndef LV_DRAW_VBASIC_H -#define LV_DRAW_VBASIC_H +#ifndef LV_DRAW_BASIC_H +#define LV_DRAW_BASIC_H #ifdef __cplusplus extern "C" { @@ -19,8 +19,6 @@ extern "C" { #include "../../lv_conf.h" #endif -#if LV_VDB_SIZE != 0 - #include "../lv_misc/lv_color.h" #include "../lv_misc/lv_area.h" #include "../lv_misc/lv_font.h" @@ -37,7 +35,7 @@ extern "C" { * GLOBAL PROTOTYPES **********************/ -void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa); +void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa); /** * Fill an area in the Virtual Display Buffer * @param cords_p coordinates of the area to fill @@ -45,7 +43,7 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col * @param color fill color * @param opa opacity of the area (0..255) */ -void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, +void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa); /** @@ -57,7 +55,7 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, * @param color color of letter * @param opa opacity of letter (0..255) */ -void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p, +void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv_font_t * font_p, uint32_t letter, lv_color_t color, lv_opa_t opa); @@ -72,7 +70,7 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p, * @param recolor mix the pixels with this color * @param recolor_opa the intense of recoloring */ -void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p, +void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte, lv_color_t recolor, lv_opa_t recolor_opa); @@ -80,10 +78,8 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p, * MACROS **********************/ -#endif /*LV_VDB_SIZE != 0*/ - #ifdef __cplusplus } /* extern "C" */ #endif -#endif /*LV_DRAW_RBASIC_H*/ +#endif /*LV_DRAW_BASIC_H*/ diff --git a/lv_draw/lv_draw_img.c b/lv_draw/lv_draw_img.c index 5c24aa89d..0f3d94fe8 100644 --- a/lv_draw/lv_draw_img.c +++ b/lv_draw/lv_draw_img.c @@ -316,7 +316,7 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas /* The decoder open could open the image and gave the entire uncompressed image. * Just draw it!*/ if(img_data) { - map_fp(coords, mask, img_data, opa, chroma_keyed, alpha_byte, style->image.color, style->image.intense); + lv_draw_map(coords, mask, img_data, opa, chroma_keyed, alpha_byte, style->image.color, style->image.intense); } /* The whole uncompressed image is not available. Try to read it line-by-line*/ else { @@ -341,7 +341,7 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas LV_LOG_WARN("Image draw can't read the line"); return LV_RES_INV; } - map_fp(&line, mask, buf, opa, chroma_keyed, alpha_byte, style->image.color, style->image.intense); + lv_draw_map(&line, mask, buf, opa, chroma_keyed, alpha_byte, style->image.color, style->image.intense); line.y1++; line.y2++; y++; diff --git a/lv_draw/lv_draw_label.c b/lv_draw/lv_draw_label.c index d80c9a0c2..72faf34c6 100644 --- a/lv_draw/lv_draw_label.c +++ b/lv_draw/lv_draw_label.c @@ -7,7 +7,6 @@ * INCLUDES *********************/ #include "lv_draw_label.h" -#include "lv_draw_rbasic.h" #include "../lv_misc/lv_math.h" /********************* @@ -123,12 +122,6 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st pos.y += y_ofs; } - /*Real draw need a background color for higher bpp letter*/ -#if LV_VDB_SIZE == 0 - lv_rletter_set_background(style->body.main_color); -#endif - - /*Write out all lines*/ while(txt[line_start] != '\0') { if(offset != NULL) { @@ -182,7 +175,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st if(cmd_state == CMD_STATE_IN) color = recolor; - letter_fp(&pos, mask, font, letter, color, opa); + lv_draw_letter(&pos, mask, font, letter, color, opa); letter_w = lv_font_get_width(font, letter); if(letter_w > 0){ diff --git a/lv_draw/lv_draw_line.c b/lv_draw/lv_draw_line.c index 0d2c389c2..c456095c5 100644 --- a/lv_draw/lv_draw_line.c +++ b/lv_draw/lv_draw_line.c @@ -192,7 +192,7 @@ static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2); draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2); draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2); - fill_fp(&draw_area, mask, style->line.color, opa); + lv_draw_fill(&draw_area, mask, style->line.color, opa); } static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale) @@ -214,7 +214,7 @@ static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2); draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2); draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2); - fill_fp(&draw_area, mask, style->line.color, opa); + lv_draw_fill(&draw_area, mask, style->line.color, opa); } static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale) @@ -436,12 +436,12 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ draw_area.y1 = prev_p.y + pattern[i].y; draw_area.x2 = draw_area.x1 + main_line->p_act.x - prev_p.x - 1; draw_area.y2 = draw_area.y1; - fill_fp(&draw_area, mask, style->line.color, opa); + lv_draw_fill(&draw_area, mask, style->line.color, opa); /* Fill the gaps * When stepping in y one pixel remains empty on every corner (don't do this on the first segment ) */ if(i != 0 && pattern[i].x != pattern[i - 1].x && !first_run) { - px_fp(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, opa); + lv_draw_px(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, opa); } } @@ -463,12 +463,12 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ draw_area.y1 = prev_p.y + pattern[i].y; draw_area.x2 = draw_area.x1 + main_line->p_act.x - prev_p.x; draw_area.y2 = draw_area.y1; - fill_fp(&draw_area, mask, style->line.color, opa); + lv_draw_fill(&draw_area, mask, style->line.color, opa); /* Fill the gaps * When stepping in y one pixel remains empty on every corner */ if(i != 0 && pattern[i].x != pattern[i - 1].x && !first_run) { - px_fp(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, opa); + lv_draw_px(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, opa); } } @@ -489,12 +489,12 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ draw_area.x2 = draw_area.x1; draw_area.y2 = draw_area.y1 + main_line->p_act.y - prev_p.y - 1; - fill_fp(&draw_area, mask, style->line.color, opa); + lv_draw_fill(&draw_area, mask, style->line.color, opa); /* Fill the gaps * When stepping in x one pixel remains empty on every corner (don't do this on the first segment ) */ if(i != 0 && pattern[i].y != pattern[i - 1].y && !first_run) { - px_fp(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, opa); + lv_draw_px(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, opa); } } @@ -519,12 +519,12 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ draw_area.x2 = draw_area.x1; draw_area.y2 = draw_area.y1 + main_line->p_act.y - prev_p.y; - fill_fp(&draw_area, mask, style->line.color, opa); + lv_draw_fill(&draw_area, mask, style->line.color, opa); /* Fill the gaps * When stepping in x one pixel remains empty on every corner */ if(i != 0 && pattern[i].y != pattern[i - 1].y && !first_run) { - px_fp(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, opa); + lv_draw_px(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, opa); } } diff --git a/lv_draw/lv_draw_rbasic.c b/lv_draw/lv_draw_rbasic.c deleted file mode 100644 index f0cd9c0e1..000000000 --- a/lv_draw/lv_draw_rbasic.c +++ /dev/null @@ -1,277 +0,0 @@ -/** - * @file lv_draw_rbasic.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include "lv_draw_rbasic.h" -#if USE_LV_REAL_DRAW != 0 - -#include "../lv_hal/lv_hal.h" -#include "../lv_misc/lv_font.h" -#include "../lv_core/lv_refr.h" -#include "lv_draw.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ -static lv_color_t letter_bg_color; - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/** - * Put a pixel to the display - * @param x x coordinate of the pixel - * @param y y coordinate of the pixel - * @param mask_p the pixel will be drawn on this area - * @param color color of the pixel - * @param opa opacity (ignored, only for compatibility with lv_vpx) - */ -void lv_rpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa) -{ - (void)opa; /*Opa is used only for compatibility with lv_vpx*/ - - lv_area_t area; - area.x1 = x; - area.y1 = y; - area.x2 = x; - area.y2 = y; - - lv_rfill(&area, mask_p, color, LV_OPA_COVER); -} - -/** - * Fill an area on the display - * @param cords_p coordinates of the area to fill - * @param mask_p fill only o this mask - * @param color fill color - * @param opa opacity (ignored, only for compatibility with lv_vfill) - */ -void lv_rfill(const lv_area_t * cords_p, const lv_area_t * mask_p, - lv_color_t color, lv_opa_t opa) -{ - - (void)opa; /*Opa is used only for compatibility with lv_vfill*/ - - lv_area_t masked_area; - bool union_ok = true; - - if(mask_p != NULL) { - union_ok = lv_area_intersect(&masked_area, cords_p, mask_p); - } else { - lv_area_t scr_area; - lv_area_set(&scr_area, 0, 0, lv_disp_get_hor_res(NULL) - 1, lv_disp_get_ver_res(NULL) - 1); - union_ok = lv_area_intersect(&masked_area, cords_p, &scr_area); - } - - if(union_ok != false) { - - lv_disp_t * disp = lv_refr_get_disp_refreshing(); - if(disp->driver.disp_fill) { - disp->driver.disp_fill(masked_area.x1, masked_area.y1, masked_area.x2, masked_area.y2, color); - } - } -} - -/** - * Draw a letter to the display - * @param pos_p left-top coordinate of the latter - * @param mask_p the letter will be drawn only on this area - * @param font_p pointer to font - * @param letter a letter to draw - * @param color color of letter - * @param opa opacity of letter (ignored, only for compatibility with lv_vletter) - */ -void lv_rletter(const lv_point_t * pos_p, const lv_area_t * mask_p, - const lv_font_t * font_p, uint32_t letter, - lv_color_t color, lv_opa_t opa) -{ - (void)opa; /*Opa is used only for compatibility with lv_vletter*/ - - static uint8_t bpp1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/ - static uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/ - static uint8_t bpp4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/ - 68, 85, 102, 119, - 136, 153, 170, 187, - 204, 221, 238, 255 - }; - - if(font_p == NULL) return; - - uint8_t letter_w = lv_font_get_width(font_p, letter); - uint8_t letter_h = lv_font_get_height(font_p); - uint8_t bpp = lv_font_get_bpp(font_p, letter); /*Bit per pixel (1,2, 4 or 8)*/ - uint8_t * bpp_opa_table; - uint8_t mask_init; - uint8_t mask; - - switch(bpp) { - case 1: - bpp_opa_table = bpp1_opa_table; - mask_init = 0x80; - break; - case 2: - bpp_opa_table = bpp2_opa_table; - mask_init = 0xC0; - break; - case 4: - bpp_opa_table = bpp4_opa_table; - mask_init = 0xF0; - break; - case 8: - bpp_opa_table = NULL; - mask_init = 0xFF; - break; /*No opa table, pixel value will be used directly*/ - default: - return; /*Invalid bpp. Can't render the letter*/ - } - - const uint8_t * map_p = lv_font_get_bitmap(font_p, letter); - - if(map_p == NULL) return; - - /*If the letter is completely out of mask don't draw it */ - if(pos_p->x + letter_w < mask_p->x1 || pos_p->x > mask_p->x2 || - pos_p->y + letter_h < mask_p->y1 || pos_p->y > mask_p->y2) return; - - lv_coord_t col, row; - uint8_t col_bit; - uint8_t col_byte_cnt; - uint8_t width_byte_scr = letter_w >> 3; /*Width in bytes (on the screen finally) (e.g. w = 11 -> 2 bytes wide)*/ - if(letter_w & 0x7) width_byte_scr++; - uint8_t width_byte_bpp = (letter_w * bpp) >> 3; /*Letter width in byte. Real width in the font*/ - if((letter_w * bpp) & 0x7) width_byte_bpp++; - - /* Calculate the col/row start/end on the map*/ - lv_coord_t col_start = pos_p->x >= mask_p->x1 ? 0 : mask_p->x1 - pos_p->x; - lv_coord_t col_end = pos_p->x + letter_w <= mask_p->x2 ? letter_w : mask_p->x2 - pos_p->x + 1; - lv_coord_t row_start = pos_p->y >= mask_p->y1 ? 0 : mask_p->y1 - pos_p->y; - lv_coord_t row_end = pos_p->y + letter_h <= mask_p->y2 ? letter_h : mask_p->y2 - pos_p->y + 1; - - /*Move on the map too*/ - map_p += (row_start * width_byte_bpp) + ((col_start * bpp) >> 3); - - uint8_t letter_px; - for(row = row_start; row < row_end; row ++) { - col_byte_cnt = 0; - col_bit = (col_start * bpp) % 8; - mask = mask_init >> col_bit; - for(col = col_start; col < col_end; col ++) { - letter_px = (*map_p & mask) >> (8 - col_bit - bpp); - if(letter_px != 0) { - lv_rpx(pos_p->x + col, pos_p->y + row, mask_p, lv_color_mix(color, letter_bg_color, bpp == 8 ? letter_px : bpp_opa_table[letter_px]), LV_OPA_COVER); - } - - if(col_bit < 8 - bpp) { - col_bit += bpp; - mask = mask >> bpp; - } else { - col_bit = 0; - col_byte_cnt ++; - mask = mask_init; - map_p ++; - } - } - - map_p += (width_byte_bpp) - col_byte_cnt; - } -} - -/** - * When the letter is ant-aliased it needs to know the background color - * @param bg_color the background color of the currently drawn letter - */ -void lv_rletter_set_background(lv_color_t color) -{ - letter_bg_color = color; -} - -/** - * Draw a color map to the display (image) - * @param cords_p coordinates the color map - * @param mask_p the map will drawn only on this area - * @param map_p pointer to a lv_color_t array - * @param opa opacity of the map (ignored, only for compatibility with 'lv_vmap') - * @param chroma_keyed true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels - * @param alpha_byte true: extra alpha byte is inserted for every pixel (not supported, only l'v_vmap' can draw it) - * @param recolor mix the pixels with this color - * @param recolor_opa the intense of recoloring - */ -void lv_rmap(const lv_area_t * cords_p, const lv_area_t * mask_p, - const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte, - lv_color_t recolor, lv_opa_t recolor_opa) -{ - if(alpha_byte) return; /*Pixel level opacity i not supported in real map drawing*/ - - (void)opa; /*opa is used only for compatibility with lv_vmap*/ - lv_area_t masked_a; - bool union_ok; - - union_ok = lv_area_intersect(&masked_a, cords_p, mask_p); - - /*If there are common part of the mask and map then draw the map*/ - if(union_ok == false) return; - - lv_disp_t * disp = lv_refr_get_disp_refreshing(); - if(disp->driver.disp_map == NULL) return; - - /*Go to the first pixel*/ - lv_coord_t map_width = lv_area_get_width(cords_p); - map_p += (masked_a.y1 - cords_p->y1) * map_width * sizeof(lv_color_t); - map_p += (masked_a.x1 - cords_p->x1) * sizeof(lv_color_t); - - lv_coord_t row; - if(recolor_opa == LV_OPA_TRANSP && chroma_key == false) { - lv_coord_t mask_w = lv_area_get_width(&masked_a) - 1; - for(row = masked_a.y1; row <= masked_a.y2; row++) { - disp->driver.disp_map(masked_a.x1, row, masked_a.x1 + mask_w, row, (lv_color_t *)map_p); - map_p += map_width * sizeof(lv_color_t); /*Next row on the map*/ - } - } else { - lv_color_t chroma_key_color = LV_COLOR_TRANSP; - lv_coord_t col; - for(row = masked_a.y1; row <= masked_a.y2; row++) { - for(col = masked_a.x1; col <= masked_a.x2; col++) { - lv_color_t * px_color = (lv_color_t *) &map_p[(uint32_t)(col - masked_a.x1) * sizeof(lv_color_t)]; - - if(chroma_key && chroma_key_color.full == px_color->full) continue; - - if(recolor_opa != LV_OPA_TRANSP) { - lv_color_t recolored_px = lv_color_mix(recolor, *px_color, recolor_opa); - - lv_rpx(col, row, mask_p, recolored_px, LV_OPA_COVER); - } else { - lv_rpx(col, row, mask_p, *px_color, LV_OPA_COVER); - } - - } - map_p += map_width * sizeof(lv_color_t); /*Next row on the map*/ - } - } -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -#endif /*USE_LV_REAL_DRAW*/ diff --git a/lv_draw/lv_draw_rbasic.h b/lv_draw/lv_draw_rbasic.h deleted file mode 100644 index b1d62f3fb..000000000 --- a/lv_draw/lv_draw_rbasic.h +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @file lv_draw_rbasic..h - * - */ - -#ifndef LV_DRAW_RBASIC_H -#define LV_DRAW_RBASIC_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#ifdef LV_CONF_INCLUDE_SIMPLE -#include "lv_conf.h" -#else -#include "../../lv_conf.h" -#endif - -#if USE_LV_REAL_DRAW != 0 - -#include "../lv_misc/lv_color.h" -#include "../lv_misc/lv_area.h" -#include "../lv_misc/lv_font.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -void lv_rpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa); - -/** - * Fill an area on the display - * @param cords_p coordinates of the area to fill - * @param mask_p fill only o this mask - * @param color fill color - * @param opa opacity (ignored, only for compatibility with lv_vfill) - */ -void lv_rfill(const lv_area_t * cords_p, const lv_area_t * mask_p, - lv_color_t color, lv_opa_t opa); - -/** - * Draw a letter to the display - * @param pos_p left-top coordinate of the latter - * @param mask_p the letter will be drawn only on this area - * @param font_p pointer to font - * @param letter a letter to draw - * @param color color of letter - * @param opa opacity of letter (ignored, only for compatibility with lv_vletter) - */ -void lv_rletter(const lv_point_t * pos_p, const lv_area_t * mask_p, - const lv_font_t * font_p, uint32_t letter, - lv_color_t color, lv_opa_t opa); - -/** - * When the letter is ant-aliased it needs to know the background color - * @param bg_color the background color of the currently drawn letter - */ -void lv_rletter_set_background(lv_color_t color); - - -/** - * Draw a color map to the display (image) - * @param cords_p coordinates the color map - * @param mask_p the map will drawn only on this area - * @param map_p pointer to a lv_color_t array - * @param opa opacity of the map (ignored, only for compatibility with 'lv_vmap') - * @param chroma_keyed true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels - * @param alpha_byte true: extra alpha byte is inserted for every pixel (not supported, only l'v_vmap' can draw it) - * @param recolor mix the pixels with this color - * @param recolor_opa the intense of recoloring - */ -void lv_rmap(const lv_area_t * cords_p, const lv_area_t * mask_p, - const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte, - lv_color_t recolor, lv_opa_t recolor_opa); -/********************** - * MACROS - **********************/ - -#endif /*USE_LV_REAL_DRAW*/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_DRAW_RBASIC_H*/ diff --git a/lv_draw/lv_draw_rect.c b/lv_draw/lv_draw_rect.c index 5b4ef1665..0d2e5cfa4 100644 --- a/lv_draw/lv_draw_rect.c +++ b/lv_draw/lv_draw_rect.c @@ -30,7 +30,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale); static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale); -#if USE_LV_SHADOW && LV_VDB_SIZE +#if USE_LV_SHADOW static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale); static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale); static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale); @@ -66,7 +66,7 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_sty { if(lv_area_get_height(coords) < 1 || lv_area_get_width(coords) < 1) return; -#if USE_LV_SHADOW && LV_VDB_SIZE +#if USE_LV_SHADOW if(style->body.shadow.width != 0) { lv_draw_shadow(coords, mask, style, opa_scale); } @@ -133,7 +133,7 @@ static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * ma #endif } - fill_fp(&work_area, mask, mcolor, opa); + lv_draw_fill(&work_area, mask, mcolor, opa); } else { lv_coord_t row; lv_coord_t row_start = coords->y1 + radius; @@ -157,7 +157,7 @@ static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * ma mix = (uint32_t)((uint32_t)(coords->y2 - work_area.y1) * 255) / height; act_color = lv_color_mix(mcolor, gcolor, mix); - fill_fp(&work_area, mask, act_color, opa); + lv_draw_fill(&work_area, mask, act_color, opa); } } } @@ -263,19 +263,19 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa); } - px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, aa_color_hor_bottom, aa_opa); - px_fp(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, aa_color_hor_bottom, aa_opa); - px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, aa_color_hor_top, aa_opa); - px_fp(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, aa_color_hor_top, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, aa_color_hor_bottom, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, aa_color_hor_bottom, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, aa_color_hor_top, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, aa_color_hor_top, aa_opa); mix = (uint32_t)((uint32_t)(radius - out_y_seg_start + i) * 255) / height; aa_color_ver = lv_color_mix(mcolor, gcolor, mix); - px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, aa_color_ver, aa_opa); - px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, aa_color_ver, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, aa_color_ver, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, aa_color_ver, aa_opa); aa_color_ver = lv_color_mix(gcolor, mcolor, mix); - px_fp(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, aa_color_ver, aa_opa); - px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, aa_color_ver, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, aa_color_ver, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, aa_color_ver, aa_opa); } out_x_last = cir.x; @@ -304,7 +304,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mix = (uint32_t)((uint32_t)(coords->y2 - edge_top_area.y1) * 255) / height; act_color = lv_color_mix(mcolor, gcolor, mix); } - fill_fp(&edge_top_area, mask, act_color, opa); + lv_draw_fill(&edge_top_area, mask, act_color, opa); } if(mid_top_refr != 0) { @@ -313,7 +313,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mix = (uint32_t)((uint32_t)(coords->y2 - mid_top_area.y1) * 255) / height; act_color = lv_color_mix(mcolor, gcolor, mix); } - fill_fp(&mid_top_area, mask, act_color, opa); + lv_draw_fill(&mid_top_area, mask, act_color, opa); } if(mid_bot_refr != 0) { @@ -322,7 +322,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mix = (uint32_t)((uint32_t)(coords->y2 - mid_bot_area.y1) * 255) / height; act_color = lv_color_mix(mcolor, gcolor, mix); } - fill_fp(&mid_bot_area, mask, act_color, opa); + lv_draw_fill(&mid_bot_area, mask, act_color, opa); } if(edge_bot_refr != 0) { @@ -332,7 +332,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mix = (uint32_t)((uint32_t)(coords->y2 - edge_bot_area.y1) * 255) / height; act_color = lv_color_mix(mcolor, gcolor, mix); } - fill_fp(&edge_bot_area, mask, act_color, opa); + lv_draw_fill(&edge_bot_area, mask, act_color, opa); } /*Save the current coordinates*/ @@ -364,7 +364,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mix = (uint32_t)((uint32_t)(coords->y2 - edge_top_area.y1) * 255) / height; act_color = lv_color_mix(mcolor, gcolor, mix); } - fill_fp(&edge_top_area, mask, act_color, opa); + lv_draw_fill(&edge_top_area, mask, act_color, opa); if(edge_top_area.y1 != mid_top_area.y1) { @@ -373,7 +373,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mix = (uint32_t)((uint32_t)(coords->y2 - mid_top_area.y1) * 255) / height; act_color = lv_color_mix(mcolor, gcolor, mix); } - fill_fp(&mid_top_area, mask, act_color, opa); + lv_draw_fill(&mid_top_area, mask, act_color, opa); } if(mcolor.full == gcolor.full) act_color = mcolor; @@ -381,7 +381,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mix = (uint32_t)((uint32_t)(coords->y2 - mid_bot_area.y1) * 255) / height; act_color = lv_color_mix(mcolor, gcolor, mix); } - fill_fp(&mid_bot_area, mask, act_color, opa); + lv_draw_fill(&mid_bot_area, mask, act_color, opa); if(edge_bot_area.y1 != mid_bot_area.y1) { @@ -390,7 +390,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mix = (uint32_t)((uint32_t)(coords->y2 - edge_bot_area.y1) * 255) / height; act_color = lv_color_mix(mcolor, gcolor, mix); } - fill_fp(&edge_bot_area, mask, act_color, opa); + lv_draw_fill(&edge_bot_area, mask, act_color, opa); } @@ -400,11 +400,11 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * edge_top_area.x2 = coords->x2 - radius - 2; edge_top_area.y1 = coords->y1; edge_top_area.y2 = coords->y1; - fill_fp(&edge_top_area, mask, style->body.main_color, opa); + lv_draw_fill(&edge_top_area, mask, style->body.main_color, opa); edge_top_area.y1 = coords->y2; edge_top_area.y2 = coords->y2; - fill_fp(&edge_top_area, mask, style->body.grad_color, opa); + lv_draw_fill(&edge_top_area, mask, style->body.grad_color, opa); /*Last parts of the anti-alias*/ out_y_seg_end = cir.y; @@ -421,19 +421,19 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * lv_coord_t i; for(i = 0; i < seg_size; i++) { lv_opa_t aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa); - px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, aa_color_hor_top, aa_opa); - px_fp(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, aa_color_hor_top, aa_opa); - px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, aa_color_hor_bottom, aa_opa); - px_fp(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, aa_color_hor_bottom, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, aa_color_hor_top, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, aa_color_hor_top, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, aa_color_hor_bottom, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, aa_color_hor_bottom, aa_opa); mix = (uint32_t)((uint32_t)(radius - out_y_seg_start + i) * 255) / height; aa_color_ver = lv_color_mix(mcolor, gcolor, mix); - px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, aa_color_ver, aa_opa); - px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, aa_color_ver, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, aa_color_ver, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, aa_color_ver, aa_opa); aa_color_ver = lv_color_mix(gcolor, mcolor, mix); - px_fp(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, aa_color_ver, aa_opa); - px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, aa_color_ver, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, aa_color_ver, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, aa_color_ver, aa_opa); } /*In some cases the last pixel is not drawn*/ @@ -446,10 +446,10 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * aa_color_hor_bottom = lv_color_mix(mcolor, gcolor, mix); lv_opa_t aa_opa = opa >> 1; - px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, aa_color_hor_bottom, aa_opa); - px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask, aa_color_hor_bottom, aa_opa); - px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask, aa_color_hor_top, aa_opa); - px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), mask, aa_color_hor_top, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, aa_color_hor_bottom, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask, aa_color_hor_bottom, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask, aa_color_hor_top, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), mask, aa_color_hor_top, aa_opa); } #endif @@ -498,7 +498,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area work_area.x2 = coords->x2; work_area.y1 = coords->y1; work_area.y2 = coords->y1 + bwidth; - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } /*Right top corner*/ @@ -507,7 +507,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area work_area.x2 = coords->x2; work_area.y1 = coords->y1 + (part & LV_BORDER_TOP ? bwidth + 1 : 0); work_area.y2 = coords->y2 - (part & LV_BORDER_BOTTOM ? bwidth + 1 : 0); - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } /*Left bottom corner*/ @@ -516,7 +516,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area work_area.x2 = coords->x1 + bwidth; work_area.y1 = coords->y1 + (part & LV_BORDER_TOP ? bwidth + 1 : 0); work_area.y2 = coords->y2 - (part & LV_BORDER_BOTTOM ? bwidth + 1 : 0); - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } /*Right bottom corner*/ @@ -525,7 +525,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area work_area.x2 = coords->x2; work_area.y1 = coords->y2 - bwidth; work_area.y2 = coords->y2; - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } return; } @@ -544,14 +544,14 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area if(part & LV_BORDER_LEFT) { work_area.x1 = coords->x1; work_area.x2 = work_area.x1 + bwidth; - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } /*Right border*/ if(part & LV_BORDER_RIGHT) { work_area.x2 = coords->x2; work_area.x1 = work_area.x2 - bwidth; - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } work_area.x1 = coords->x1 + corner_size - length_corr; @@ -561,14 +561,14 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area if(part & LV_BORDER_TOP) { work_area.y1 = coords->y1; work_area.y2 = coords->y1 + bwidth; - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } /*Lower border*/ if(part & LV_BORDER_BOTTOM) { work_area.y2 = coords->y2; work_area.y1 = work_area.y2 - bwidth; - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } /*Draw the a remaining rectangles if the radius is smaller then bwidth */ @@ -579,7 +579,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area work_area.x2 = coords->x1 + radius + LV_ANTIALIAS; work_area.y1 = coords->y1 + radius + 1 + LV_ANTIALIAS; work_area.y2 = coords->y1 + bwidth; - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } /*Right top correction*/ @@ -588,7 +588,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area work_area.x2 = coords->x2; work_area.y1 = coords->y1 + radius + 1 + LV_ANTIALIAS; work_area.y2 = coords->y1 + bwidth; - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } /*Left bottom correction*/ @@ -597,7 +597,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area work_area.x2 = coords->x1 + radius + LV_ANTIALIAS; work_area.y1 = coords->y2 - bwidth; work_area.y2 = coords->y2 - radius - 1 - LV_ANTIALIAS; - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } /*Right bottom correction*/ @@ -606,7 +606,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area work_area.x2 = coords->x2; work_area.y1 = coords->y2 - bwidth; work_area.y2 = coords->y2 - radius - 1 - LV_ANTIALIAS; - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } } @@ -618,7 +618,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area work_area.x2 = coords->x1 + LV_ANTIALIAS; work_area.y1 = coords->y1; work_area.y2 = coords->y1 + LV_ANTIALIAS; - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } /*Right top corner*/ @@ -627,7 +627,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area work_area.x2 = coords->x2; work_area.y1 = coords->y1; work_area.y2 = coords->y1 + LV_ANTIALIAS; - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } /*Left bottom corner*/ @@ -636,7 +636,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area work_area.x2 = coords->x1 + LV_ANTIALIAS; work_area.y1 = coords->y2 - LV_ANTIALIAS; work_area.y2 = coords->y2; - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } /*Right bottom corner*/ @@ -645,7 +645,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area work_area.x2 = coords->x2; work_area.y1 = coords->y2 - LV_ANTIALIAS; work_area.y2 = coords->y2; - fill_fp(&work_area, mask, color, opa); + lv_draw_fill(&work_area, mask, color, opa); } } } @@ -756,24 +756,24 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) { - px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa); - px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) { - px_fp(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); - px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) { - px_fp(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa); - px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) { - px_fp(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); - px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa); } } @@ -801,37 +801,37 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) { - px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) { - px_fp(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) { - px_fp(lt_origo.x + LV_CIRC_OCT5_X(aa_p) + 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) + 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) { - px_fp(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); } /*Be sure the pixels on the middle are not drawn twice*/ if(LV_CIRC_OCT1_X(aa_p) - 1 != LV_CIRC_OCT2_X(aa_p) + i) { if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) { - px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) { - px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p) + 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) + 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) { - px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) { - px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p) - 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) - 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa); } } @@ -851,13 +851,13 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t circ_area.x2 = rb_origo.x + LV_CIRC_OCT1_X(cir_out); circ_area.y1 = rb_origo.y + LV_CIRC_OCT1_Y(cir_out); circ_area.y2 = rb_origo.y + LV_CIRC_OCT1_Y(cir_out); - fill_fp(&circ_area, mask, color, opa); + lv_draw_fill(&circ_area, mask, color, opa); circ_area.x1 = rb_origo.x + LV_CIRC_OCT2_X(cir_out); circ_area.x2 = rb_origo.x + LV_CIRC_OCT2_X(cir_out); circ_area.y1 = rb_origo.y + LV_CIRC_OCT2_Y(cir_out) - act_w1; circ_area.y2 = rb_origo.y + LV_CIRC_OCT2_Y(cir_out); - fill_fp(&circ_area, mask, color, opa); + lv_draw_fill(&circ_area, mask, color, opa); } /*Draw the octets to the left bottom corner*/ @@ -866,13 +866,13 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t circ_area.x2 = lb_origo.x + LV_CIRC_OCT3_X(cir_out); circ_area.y1 = lb_origo.y + LV_CIRC_OCT3_Y(cir_out) - act_w2; circ_area.y2 = lb_origo.y + LV_CIRC_OCT3_Y(cir_out); - fill_fp(&circ_area, mask, color, opa); + lv_draw_fill(&circ_area, mask, color, opa); circ_area.x1 = lb_origo.x + LV_CIRC_OCT4_X(cir_out); circ_area.x2 = lb_origo.x + LV_CIRC_OCT4_X(cir_out) + act_w1; circ_area.y1 = lb_origo.y + LV_CIRC_OCT4_Y(cir_out); circ_area.y2 = lb_origo.y + LV_CIRC_OCT4_Y(cir_out); - fill_fp(&circ_area, mask, color, opa); + lv_draw_fill(&circ_area, mask, color, opa); } /*Draw the octets to the left top corner*/ @@ -883,14 +883,14 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t circ_area.x2 = lt_origo.x + LV_CIRC_OCT5_X(cir_out) + act_w2; circ_area.y1 = lt_origo.y + LV_CIRC_OCT5_Y(cir_out); circ_area.y2 = lt_origo.y + LV_CIRC_OCT5_Y(cir_out); - fill_fp(&circ_area, mask, color, opa); + lv_draw_fill(&circ_area, mask, color, opa); } circ_area.x1 = lt_origo.x + LV_CIRC_OCT6_X(cir_out); circ_area.x2 = lt_origo.x + LV_CIRC_OCT6_X(cir_out); circ_area.y1 = lt_origo.y + LV_CIRC_OCT6_Y(cir_out); circ_area.y2 = lt_origo.y + LV_CIRC_OCT6_Y(cir_out) + act_w1; - fill_fp(&circ_area, mask, color, opa); + lv_draw_fill(&circ_area, mask, color, opa); } /*Draw the octets to the right top corner*/ @@ -899,7 +899,7 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t circ_area.x2 = rt_origo.x + LV_CIRC_OCT7_X(cir_out); circ_area.y1 = rt_origo.y + LV_CIRC_OCT7_Y(cir_out); circ_area.y2 = rt_origo.y + LV_CIRC_OCT7_Y(cir_out) + act_w2; - fill_fp(&circ_area, mask, color, opa); + lv_draw_fill(&circ_area, mask, color, opa); /*Don't draw if the lines are common in the middle*/ if(rb_origo.y + LV_CIRC_OCT1_Y(cir_out) > rt_origo.y + LV_CIRC_OCT8_Y(cir_out)) { @@ -907,7 +907,7 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t circ_area.x2 = rt_origo.x + LV_CIRC_OCT8_X(cir_out); circ_area.y1 = rt_origo.y + LV_CIRC_OCT8_Y(cir_out); circ_area.y2 = rt_origo.y + LV_CIRC_OCT8_Y(cir_out); - fill_fp(&circ_area, mask, color, opa); + lv_draw_fill(&circ_area, mask, color, opa); } } lv_circ_next(&cir_out, &tmp_out); @@ -934,23 +934,23 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t for(i = 0; i < seg_size; i++) { lv_opa_t aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa); if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) { - px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa); - px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) { - px_fp(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); - px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) { - px_fp(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa); - px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) { - px_fp(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); - px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa); } } @@ -962,19 +962,19 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t lv_opa_t aa_opa = opa >> 1; if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) { - px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, style->body.border.color, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) { - px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask, style->body.border.color, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) { - px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask, style->body.border.color, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) { - px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), mask, style->body.border.color, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), mask, style->body.border.color, aa_opa); } } @@ -987,36 +987,36 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t for(i = 0; i < seg_size; i++) { lv_opa_t aa_opa = lv_draw_aa_get_opa(seg_size, i, opa); if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) { - px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) { - px_fp(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) { - px_fp(lt_origo.x + LV_CIRC_OCT5_X(aa_p) + 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) + 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) { - px_fp(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); } if(LV_CIRC_OCT1_X(aa_p) - 1 != LV_CIRC_OCT2_X(aa_p) + i) { if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) { - px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) { - px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p) + 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) + 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) { - px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) { - px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p) - 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) - 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa); } } } @@ -1025,7 +1025,7 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t } -#if USE_LV_SHADOW && LV_VDB_SIZE +#if USE_LV_SHADOW /** * Draw a shadow @@ -1203,19 +1203,19 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask for(d = 1; d < col; d++) { if(point_lt.x < ofs_lt.x && point_lt.y < ofs_lt.y) { - px_fp(point_lt.x, point_lt.y, mask, style->body.shadow.color, line_2d_blur[d]); + lv_draw_px(point_lt.x, point_lt.y, mask, style->body.shadow.color, line_2d_blur[d]); } if(point_lb.x < ofs_lb.x && point_lb.y > ofs_lb.y) { - px_fp(point_lb.x, point_lb.y, mask, style->body.shadow.color, line_2d_blur[d]); + lv_draw_px(point_lb.x, point_lb.y, mask, style->body.shadow.color, line_2d_blur[d]); } if(point_rt.x > ofs_rt.x && point_rt.y < ofs_rt.y) { - px_fp(point_rt.x, point_rt.y, mask, style->body.shadow.color, line_2d_blur[d]); + lv_draw_px(point_rt.x, point_rt.y, mask, style->body.shadow.color, line_2d_blur[d]); } if(point_rb.x > ofs_rb.x && point_rb.y > ofs_rb.y) { - px_fp(point_rb.x, point_rb.y, mask, style->body.shadow.color, line_2d_blur[d]); + lv_draw_px(point_rb.x, point_rb.y, mask, style->body.shadow.color, line_2d_blur[d]); } point_rb.x++; @@ -1306,12 +1306,12 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma } else { px_opa = (uint16_t)((uint16_t)line_1d_blur[d] + line_1d_blur[d - diff]) >> 1; } - px_fp(point_l.x, point_l.y, mask, style->body.shadow.color, px_opa); + lv_draw_px(point_l.x, point_l.y, mask, style->body.shadow.color, px_opa); point_l.y ++; /*Don't overdraw the pixel on the middle*/ if(point_r.x > ofs_l.x) { - px_fp(point_r.x, point_r.y, mask, style->body.shadow.color, px_opa); + lv_draw_px(point_r.x, point_r.y, mask, style->body.shadow.color, px_opa); } point_r.y ++; } @@ -1325,7 +1325,7 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma uint16_t d; for(d = 0; d < swidth; d++) { - fill_fp(&area_mid, mask, style->body.shadow.color, line_1d_blur[d]); + lv_draw_fill(&area_mid, mask, style->body.shadow.color, line_1d_blur[d]); area_mid.y1 ++; area_mid.y2 ++; } @@ -1370,19 +1370,19 @@ static void lv_draw_shadow_full_straight(const lv_area_t * coords, const lv_area for(d = 1 /*+ LV_ANTIALIAS*/; d <= swidth/* - LV_ANTIALIAS*/; d++) { opa_act = map[d]; - fill_fp(&right_area, mask, style->body.shadow.color, opa_act); + lv_draw_fill(&right_area, mask, style->body.shadow.color, opa_act); right_area.x1++; right_area.x2++; - fill_fp(&left_area, mask, style->body.shadow.color, opa_act); + lv_draw_fill(&left_area, mask, style->body.shadow.color, opa_act); left_area.x1--; left_area.x2--; - fill_fp(&top_area, mask, style->body.shadow.color, opa_act); + lv_draw_fill(&top_area, mask, style->body.shadow.color, opa_act); top_area.y1--; top_area.y2--; - fill_fp(&bottom_area, mask, style->body.shadow.color, opa_act); + lv_draw_fill(&bottom_area, mask, style->body.shadow.color, opa_act); bottom_area.y1++; bottom_area.y2++; } diff --git a/lv_draw/lv_draw_triangle.c b/lv_draw/lv_draw_triangle.c index 84c9d3f31..954d3541b 100644 --- a/lv_draw/lv_draw_triangle.c +++ b/lv_draw/lv_draw_triangle.c @@ -98,7 +98,7 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, lv_colo draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2); draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2); draw_area.x2--; /*Do not draw most right pixel because it will be drawn by the adjacent triangle*/ - fill_fp(&draw_area, mask, color, LV_OPA_50); + lv_draw_fill(&draw_area, mask, color, LV_OPA_COVER); /*Calc. the next point of edge1*/ y1_tmp = edge1.y; diff --git a/lv_hal/lv_hal_disp.c b/lv_hal/lv_hal_disp.c index 8169a551b..4c15f28bf 100644 --- a/lv_hal/lv_hal_disp.c +++ b/lv_hal/lv_hal_disp.c @@ -53,8 +53,6 @@ */ void lv_disp_drv_init(lv_disp_drv_t * driver) { - driver->disp_fill = NULL; - driver->disp_map = NULL; driver->disp_flush = NULL; driver->hor_res = LV_HOR_RES_MAX; driver->ver_res = LV_VER_RES_MAX; @@ -64,13 +62,7 @@ void lv_disp_drv_init(lv_disp_drv_t * driver) driver->mem_fill = NULL; #endif -#if LV_VDB_SIZE driver->vdb_wr = NULL; - driver->vdb = NULL; - driver->vdb2 = NULL; - driver->vdb_size = 0; - driver->vdb_double = 0; -#endif } /** @@ -104,6 +96,11 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) return disp; } +/** + * Get the next display. + * @param disp pointer to the current display. NULL to initialize. + * @return the next display or NULL if no more. Give the first display when the parameter is NULL + */ lv_disp_t * lv_disp_get_next(lv_disp_t * disp) { if(disp == NULL) return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll)); @@ -116,16 +113,9 @@ lv_disp_t * lv_disp_get_last(void) return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll)); } - -/** - * Get the next display. - * @param disp pointer to the current display. NULL to initialize. - * @return the next display or NULL if no more. Give the first display when the parameter is NULL - */ -lv_disp_t * lv_disp_next(lv_disp_t * disp) +lv_vdb_t * lv_disp_get_vdb(lv_disp_t * disp) { - if(disp == NULL) return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll)); - else return lv_ll_get_next(&LV_GC_ROOT(_lv_disp_ll), disp); + return disp->driver.buffer; } lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp) @@ -145,6 +135,18 @@ lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp) else return disp->driver.ver_res; } +bool lv_disp_is_double_vdb(lv_disp_t * disp) +{ + if(disp->driver.buffer->buf1 && disp->driver.buffer->buf2) return true; + else return false; +} + +bool lv_disp_is_true_double_buffered(lv_disp_t * disp) +{ + if(lv_disp_is_double_vdb(disp) && disp->driver.buffer->size == disp->driver.hor_res * disp->driver.ver_res) return true; + else return false; +} + /********************** * STATIC FUNCTIONS **********************/ diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index 4d1601e19..08fbbfd5f 100644 --- a/lv_hal/lv_hal_disp.h +++ b/lv_hal/lv_hal_disp.h @@ -35,6 +35,25 @@ extern "C" { struct _disp_t; + +typedef struct +{ + void * buf_act; + void * buf1; + void * buf2; + uint32_t size; /*In pixel count*/ + struct { + uint32_t double_buffered :1; + uint32_t true_double_buffered :1; + }mode; + + lv_area_t area; + struct { + uint32_t flushing :1; + }internal; +}lv_vdb_t; + + /** * Display Driver structure to be registered by HAL */ @@ -45,15 +64,11 @@ typedef struct _disp_drv_t { lv_coord_t ver_res; + lv_vdb_t * buffer; + /*Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished*/ void (*disp_flush)(struct _disp_t * disp, const lv_area_t * area, lv_color_t * color_p); - /*Fill an area with a color on the display*/ - void (*disp_fill)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color); - - /*Write pixel map (e.g. image) to the display*/ - void (*disp_map)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p); - /*Optional interface functions to use GPU*/ #if USE_LV_GPU /*Blend two memories using opacity (GPU only)*/ @@ -63,15 +78,8 @@ typedef struct _disp_drv_t { void (*mem_fill)(lv_color_t * dest, uint32_t length, lv_color_t color); #endif -#if LV_VDB_SIZE - void * vdb; - void * vdb2; - uint32_t vdb_size; - uint32_t vdb_double :1; - /*Optional: Set a pixel in a buffer according to the requirements of the display*/ void (*vdb_wr)(uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa); -#endif } lv_disp_drv_t; struct _lv_obj_t; @@ -113,6 +121,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t *driver); lv_disp_t * lv_disp_get_last(void); +lv_vdb_t * lv_disp_get_vdb(lv_disp_t * disp); /** * Get the next display. * @param disp pointer to the current display. NULL to initialize. @@ -124,6 +133,9 @@ lv_disp_t * lv_disp_get_next(lv_disp_t * disp); lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp); lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp); +bool lv_disp_is_double_vdb(lv_disp_t * disp); + +bool lv_disp_is_true_double_buffered(lv_disp_t * disp); /********************** * MACROS **********************/ diff --git a/lv_objx/lv_cont.c b/lv_objx/lv_cont.c index 304852a22..c21511bef 100644 --- a/lv_objx/lv_cont.c +++ b/lv_objx/lv_cont.c @@ -15,7 +15,7 @@ #include #include "../lv_draw/lv_draw.h" -#include "../lv_draw/lv_draw_vbasic.h" +#include "../lv_draw/lv_draw_basic.h" #include "../lv_themes/lv_theme.h" #include "../lv_misc/lv_area.h" #include "../lv_misc/lv_color.h" diff --git a/lvgl.h b/lvgl.h index 6aab3e4e0..527ded834 100644 --- a/lvgl.h +++ b/lvgl.h @@ -24,7 +24,6 @@ extern "C" { #include "lv_core/lv_obj.h" #include "lv_core/lv_group.h" #include "lv_core/lv_lang.h" -#include "lv_core/lv_vdb.h" #include "lv_core/lv_refr.h" #include "lv_core/lv_disp.h" From ef8563c9bd3d347fb6306813c442b4658915965d Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 15 Feb 2019 06:20:48 +0100 Subject: [PATCH 09/17] multi-disp_: minor fixes --- lv_core/lv_lang.c | 2 +- lv_objx/lv_tabview.c | 2 +- lv_objx/lv_win.c | 5 ++++- lv_porting/lv_port_indev_templ.c | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lv_core/lv_lang.c b/lv_core/lv_lang.c index c96ed7883..ab35c2508 100644 --- a/lv_core/lv_lang.c +++ b/lv_core/lv_lang.c @@ -54,7 +54,7 @@ void lv_lang_set(uint8_t lang_id) lang_set_core(i); } - lang_set_core(lv_scr_act()); + lang_set_core(lv_scr_act(NULL)); } /** diff --git a/lv_objx/lv_tabview.c b/lv_objx/lv_tabview.c index ffe6f2147..44e166807 100644 --- a/lv_objx/lv_tabview.c +++ b/lv_objx/lv_tabview.c @@ -106,7 +106,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) ext->tab_name_ptr[0] = ""; ext->tab_cnt = 0; - lv_disp_t * disp = lv_obj_get_disp(par); + lv_disp_t * disp = lv_obj_get_disp(new_tabview); lv_obj_set_size(new_tabview, lv_disp_get_hor_res(disp), lv_disp_get_ver_res(disp)); ext->btns = lv_btnm_create(new_tabview, NULL); diff --git a/lv_objx/lv_win.c b/lv_objx/lv_win.c index 60dfe4784..c2abebb9e 100644 --- a/lv_objx/lv_win.c +++ b/lv_objx/lv_win.c @@ -70,7 +70,10 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new window object*/ if(copy == NULL) { - lv_obj_set_size(new_win, LV_DPI * 3, LV_DPI * 3); + lv_obj_t * disp = lv_obj_get_disp(new_win); + lv_coord_t hres = lv_disp_get_hor_res(disp); + lv_coord_t vres = lv_disp_get_ver_res(disp); + lv_obj_set_size(new_win, hres, vres); lv_obj_set_pos(new_win, 0, 0); lv_obj_set_style(new_win, &lv_style_pretty); diff --git a/lv_porting/lv_port_indev_templ.c b/lv_porting/lv_port_indev_templ.c index 102c16f90..60089270e 100644 --- a/lv_porting/lv_port_indev_templ.c +++ b/lv_porting/lv_port_indev_templ.c @@ -109,7 +109,7 @@ void lv_port_indev_init(void) indev_mouse = lv_indev_drv_register(&indev_drv); /*Set cursor. For simplicity set a HOME symbol now.*/ - lv_obj_t * mouse_cursor = lv_img_create(lv_scr_act(), NULL); + lv_obj_t * mouse_cursor = lv_img_create(lv_scr_act(NULL), NULL); lv_img_set_src(mouse_cursor, SYMBOL_HOME); lv_indev_set_cursor(indev_mouse, mouse_cursor); From 030fe60b34129d2faf2cdb3b5d4bc7a829283eac Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 20 Feb 2019 23:58:13 +0100 Subject: [PATCH 10/17] multi-disp: API updates --- README.md | 21 +++-- lv_core/lv_core.mk | 2 +- lv_core/lv_disp.c | 74 ++++++++++++++--- lv_core/lv_disp.h | 45 +++++++--- lv_core/lv_indev.c | 57 ++++++------- lv_core/lv_obj.c | 98 ++++------------------ lv_core/lv_obj.h | 40 ++------- lv_core/lv_refr.c | 76 ++++++----------- lv_core/lv_refr.h | 14 ---- lv_draw/lv_draw.mk | 3 +- lv_draw/lv_draw_basic.c | 32 ++++---- lv_hal/lv_hal_disp.c | 136 +++++++++++++++++++++---------- lv_hal/lv_hal_disp.h | 119 +++++++++++++++++++++------ lv_hal/lv_hal_indev.c | 11 +-- lv_hal/lv_hal_indev.h | 26 +++--- lv_objx/lv_win.c | 3 +- lv_porting/lv_port_disp_templ.c | 96 ++++++++++------------ lv_porting/lv_port_indev_templ.c | 34 ++++---- lv_version.h | 6 +- 19 files changed, 473 insertions(+), 420 deletions(-) diff --git a/README.md b/README.md index cb9a00527..6bfd28d7d 100644 --- a/README.md +++ b/README.md @@ -72,24 +72,31 @@ In the most simple case you need to do these steps: 1. Copy `lv_conf_templ.h` as `lv_conf.h` next to `lvgl` and set at least `LV_HOR_RES`, `LV_VER_RES` and `LV_COLOR_DEPTH`. 2. Call `lv_tick_inc(x)` every `x` milliseconds in a Timer or Task (`x` should be between 1 and 10) 3. Call `lv_init()` -4. Register a function which can **copy a pixel array** to an area of the screen: +4. Create a buffer for LittlevGL +```c +static lv_disp_buf_t disp_buf; +static lv_color_t buf[LV_HOR_RES_MAX * 10]; /*Declare a buffer for 10 lines*/ +v_disp_buf_init(&disp_buf1, buf, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/ +``` +4. Implement and register a function which can **copy a pixel array** to an area of your diplay: ```c lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ lv_disp_drv_init(&disp_drv); /*Basic initialization*/ -disp_drv.disp_flush = disp_flush; /*Set your driver function*/ +disp_drv.flush_cb = my_disp_flush; /*Set your driver function*/ +disp_drv.buffer = &disp_buf; /*Assign the buffer to teh display*/ lv_disp_drv_register(&disp_drv); /*Finally register the driver*/ -void disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p) +void my_disp_flush(lv_disp_t * disp, const lv_area_t * area, lv_color_t * color_p) { int32_t x, y; - for(y = y1; y <= y2; y++) { - for(x = x1; x <= x2; x++) { - sep_pixel(x, y, *color_p); /* Put a pixel to the display.*/ + for(y = area->y1; y <= area->y2; y++) { + for(x = area->x1; x <= area->x2; x++) { + set_pixel(x, y, *color_p); /* Put a pixel to the display.*/ color_p++; } } - lv_flush_ready(); /* Tell you are ready with the flushing*/ + lv_disp_flush_ready(disp); /* Tell you are ready with the flushing*/ } ``` diff --git a/lv_core/lv_core.mk b/lv_core/lv_core.mk index 9992e3fe7..ac69f25e3 100644 --- a/lv_core/lv_core.mk +++ b/lv_core/lv_core.mk @@ -1,9 +1,9 @@ CSRCS += lv_group.c CSRCS += lv_indev.c +CSRCS += lv_disp.c CSRCS += lv_obj.c CSRCS += lv_refr.c CSRCS += lv_style.c -CSRCS += lv_vdb.c CSRCS += lv_lang.c DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_core diff --git a/lv_core/lv_disp.c b/lv_core/lv_disp.c index 6017ba27c..dc4578d17 100644 --- a/lv_core/lv_disp.c +++ b/lv_core/lv_disp.c @@ -33,34 +33,82 @@ **********************/ /** - * Get the number of areas in the buffer - * @return number of invalid areas + * Return with a pointer to the active screen + * @param disp pointer to display which active screen should be get. (NULL to use the default screen) + * @return pointer to the active screen object (loaded by 'lv_scr_load()') */ -uint16_t lv_disp_get_inv_buf_size(lv_disp_t * disp) +lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp) { - return disp->inv_p; + if(!disp) disp = lv_disp_get_default(); + if(!disp) { + LV_LOG_WARN("lv_scr_act: no display registered to get its top layer"); + return NULL; + } + + return disp->act_scr; } /** - * Pop (delete) the last 'num' invalidated areas from the buffer - * @param num number of areas to delete + * Make a screen active + * @param scr pointer to a screen */ -void lv_disp_pop_from_inv_buf(lv_disp_t * disp, uint16_t num) +void lv_disp_set_scr_act(lv_obj_t * scr) { + lv_disp_t * d = lv_obj_get_disp(scr); - if(disp->inv_p < num) disp->inv_p = 0; - else disp->inv_p -= num; + d->act_scr = scr; + + lv_obj_invalidate(scr); } +/** + * Return with the top layer. (Same on every screen and it is above the normal screen layer) + * @param disp pointer to display which top layer should be get. (NULL to use the default screen) + * @return pointer to the top layer object (transparent screen sized lv_obj) + */ +lv_obj_t * lv_disp_get_layer_top(lv_disp_t * disp) +{ + if(!disp) disp = lv_disp_get_default(); + if(!disp) { + LV_LOG_WARN("lv_layer_top: no display registered to get its top layer"); + return NULL; + } + + return disp->top_layer; +} + +/** + * Return with the sys. layer. (Same on every screen and it is above the normal screen and the top layer) + * @param disp pointer to display which sys. layer should be get. (NULL to use the default screen) + * @return pointer to the sys layer object (transparent screen sized lv_obj) + */ +lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp) +{ + if(!disp) disp = lv_disp_get_default(); + if(!disp) { + LV_LOG_WARN("lv_layer_sys: no display registered to get its top layer"); + return NULL; + } + + return disp->sys_layer; +} + +/** + * Assign a screen to a display. + * @param disp pointer to a display where to assign the screen + * @param scr pointer to a screen object to assign + */ void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr) { - lv_disp_t * old_disp = lv_scr_get_disp(scr); - - if(old_disp == disp) { - LV_LOG_WARN("lv_disp_assign_screen: tried to assign to the same screen") + if(lv_obj_get_parent(scr) != NULL) { + LV_LOG_WARN("lv_disp_assign_screen: try to assign a non-screen object"); return; } + lv_disp_t * old_disp = lv_obj_get_disp(scr); + + if(old_disp == disp) return; + lv_ll_chg_list(&old_disp->scr_ll, &disp->scr_ll, scr); } diff --git a/lv_core/lv_disp.h b/lv_core/lv_disp.h index 62690f551..def7bceed 100644 --- a/lv_core/lv_disp.h +++ b/lv_core/lv_disp.h @@ -27,20 +27,41 @@ extern "C" { /********************** * GLOBAL PROTOTYPES **********************/ + +/** + * Return with a pointer to the active screen + * @param disp pointer to display which active screen should be get. (NULL to use the default screen) + * @return pointer to the active screen object (loaded by 'lv_scr_load()') + */ +lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp); + +/** + * Make a screen active + * @param scr pointer to a screen + */ +void lv_disp_set_scr_act(lv_obj_t * scr); + +/** + * Return with the top layer. (Same on every screen and it is above the normal screen layer) + * @param disp pointer to display which top layer should be get. (NULL to use the default screen) + * @return pointer to the top layer object (transparent screen sized lv_obj) + */ +lv_obj_t * lv_disp_get_layer_top(lv_disp_t * disp); + +/** + * Return with the sys. layer. (Same on every screen and it is above the normal screen and the top layer) + * @param disp pointer to display which sys. layer should be get. (NULL to use the default screen) + * @return pointer to the sys layer object (transparent screen sized lv_obj) + */ +lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp); + +/** + * Assign a screen to a display. + * @param disp pointer to a display where to assign the screen + * @param scr pointer to a screen object to assign + */ void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr); -/** - * Get the number of areas in the buffer - * @return number of invalid areas - */ -uint16_t lv_disp_get_inv_buf_size(lv_disp_t * disp); - -/** - * Pop (delete) the last 'num' invalidated areas from the buffer - * @param num number of areas to delete - */ -void lv_disp_pop_from_inv_buf(lv_disp_t * disp, uint16_t num); - /********************** * MACROS **********************/ diff --git a/lv_core/lv_indev.c b/lv_core/lv_indev.c index 01d1f03ce..989277c64 100644 --- a/lv_core/lv_indev.c +++ b/lv_core/lv_indev.c @@ -126,12 +126,12 @@ void lv_indev_reset_lpr(lv_indev_t * indev) void lv_indev_enable(lv_hal_indev_type_t type, bool enable) { -// lv_indev_t * i = lv_indev_next(NULL); -// -// while(i) { -// if(i->driver.type == type) i->proc.disabled = enable == false ? 1 : 0; -// i = lv_indev_next(i); -// } + lv_indev_t * i = lv_indev_next(NULL); + + while(i) { + if(i->driver.type == type) i->proc.disabled = enable == false ? 1 : 0; + i = lv_indev_next(i); + } } /** @@ -144,7 +144,7 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj) if(indev->driver.type != LV_INDEV_TYPE_POINTER) return; indev->cursor = cur_obj; - lv_obj_set_parent(indev->cursor, lv_layer_sys(indev->driver.disp)); + lv_obj_set_parent(indev->cursor, lv_disp_get_layer_sys(indev->driver.disp)); lv_obj_set_pos(indev->cursor, indev->proc.act_point.x, indev->proc.act_point.y); } @@ -250,22 +250,19 @@ void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point) uint32_t lv_indev_get_inactive_time(const lv_indev_t * indev) { - //TODO -// uint32_t t; -// -// if(indev) return t = lv_tick_elaps(indev->last_activity_time); -// -// lv_indev_t * i; -// t = UINT16_MAX; -// i = lv_indev_next(NULL); -// while(i) { -// t = LV_MATH_MIN(t, lv_tick_elaps(i->last_activity_time)); -// i = lv_indev_next(i); -// } -// -// return t; + uint32_t t; - return 0; + if(indev) return t = lv_tick_elaps(indev->last_activity_time); + + lv_indev_t * i; + t = UINT16_MAX; + i = lv_indev_next(NULL); + while(i) { + t = LV_MATH_MIN(t, lv_tick_elaps(i->last_activity_time)); + i = lv_indev_next(i); + } + + return t; } /** @@ -547,8 +544,8 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) */ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data) { - i->proc.act_point.x = i->btn_points[data->btn].x; - i->proc.act_point.y = i->btn_points[data->btn].y; + i->proc.act_point.x = i->btn_points[data->btn_id].x; + i->proc.act_point.y = i->btn_points[data->btn_id].y; /*Still the same point is pressed*/ if(i->proc.last_point.x == i->proc.act_point.x && @@ -586,16 +583,16 @@ static void indev_proc_press(lv_indev_proc_t * proc) /*If there is no last object then search*/ if(proc->act_obj == NULL) { - pr_obj = indev_search_obj(proc, lv_layer_sys(disp)); - if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_layer_top(disp)); - if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_scr_act(disp)); + pr_obj = indev_search_obj(proc, lv_disp_get_layer_sys(disp)); + if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_disp_get_layer_top(disp)); + if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_disp_get_scr_act(disp)); } /*If there is last object but it is not dragged and not protected also search*/ else if(proc->drag_in_prog == 0 && lv_obj_is_protected(proc->act_obj, LV_PROTECT_PRESS_LOST) == false) {/*Now act_obj != NULL*/ - pr_obj = indev_search_obj(proc, lv_layer_sys(disp)); - if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_layer_top(disp)); - if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_scr_act(disp)); + pr_obj = indev_search_obj(proc, lv_disp_get_layer_sys(disp)); + if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_disp_get_layer_top(disp)); + if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_disp_get_scr_act(disp)); } /*If a dragable or a protected object was the last then keep it*/ else { diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index 59c3d2c0f..16798ff87 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -10,6 +10,7 @@ #include "lv_indev.h" #include "lv_refr.h" #include "lv_group.h" +#include "lv_disp.h" #include "../lv_themes/lv_theme.h" #include "../lv_draw/lv_draw.h" #include "../lv_misc/lv_anim.h" @@ -356,7 +357,7 @@ lv_res_t lv_obj_del(lv_obj_t * obj) /*Remove the object from parent's children list*/ lv_obj_t * par = lv_obj_get_parent(obj); if(par == NULL) { /*It is a screen*/ - lv_disp_t * d = lv_scr_get_disp(obj); + lv_disp_t * d = lv_obj_get_disp(obj); lv_ll_rem(&d->scr_ll, obj); } else { lv_ll_rem(&(par->child_ll), obj); @@ -415,10 +416,10 @@ void lv_obj_invalidate(const lv_obj_t * obj) /*Invalidate the object only if it belongs to the 'LV_GC_ROOT(_lv_act_scr)'*/ lv_obj_t * obj_scr = lv_obj_get_screen(obj); - lv_disp_t * disp = lv_scr_get_disp(obj_scr); - if(obj_scr == lv_scr_act(disp) || - obj_scr == lv_layer_top(disp)|| - obj_scr == lv_layer_sys(disp)) { + lv_disp_t * disp = lv_obj_get_disp(obj_scr); + if(obj_scr == lv_disp_get_scr_act(disp) || + obj_scr == lv_disp_get_layer_top(disp)|| + obj_scr == lv_disp_get_layer_sys(disp)) { /*Truncate recursively to the parents*/ lv_area_t area_trunc; lv_obj_t * par = lv_obj_get_parent(obj); @@ -449,23 +450,6 @@ void lv_obj_invalidate(const lv_obj_t * obj) * Setter functions *====================*/ - -/*-------------- - * Screen set - *--------------*/ -/** - * Load a new screen - * @param scr pointer to a screen - */ -void lv_scr_load(lv_obj_t * scr) -{ - lv_disp_t * d = lv_scr_get_disp(scr); - - d->act_scr = scr; - - lv_obj_invalidate(scr); -} - /*-------------------- * Parent/children set *--------------------*/ @@ -1302,55 +1286,6 @@ void lv_obj_animate(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint1 * Getter functions *======================*/ -/*------------------ - * Screen get - *-----------------*/ - -/** - * Return with a pointer to the active screen - * @return pointer to the active screen object (loaded by 'lv_scr_load()') - */ -lv_obj_t * lv_scr_act(lv_disp_t * disp) -{ - if(!disp) disp = lv_disp_get_default(); - if(!disp) { - LV_LOG_WARN("lv_scr_act: no display registered to get its top layer"); - return NULL; - } - - return disp->act_scr; -} - -/** - * Return with the top layer. (Same on every screen and it is above the normal screen layer) - * @return pointer to the top layer object (transparent screen sized lv_obj) - */ -lv_obj_t * lv_layer_top(lv_disp_t * disp) -{ - if(!disp) disp = lv_disp_get_default(); - if(!disp) { - LV_LOG_WARN("lv_layer_top: no display registered to get its top layer"); - return NULL; - } - - return disp->top_layer; -} - -/** - * Return with the sys. layer. (Same on every screen and it is above the normal screen layer) - * @return pointer to the sys layer object (transparent screen sized lv_obj) - */ -lv_obj_t * lv_layer_sys(lv_disp_t * disp) -{ - if(!disp) disp = lv_disp_get_default(); - if(!disp) { - LV_LOG_WARN("lv_layer_sys: no display registered to get its top layer"); - return NULL; - } - - return disp->sys_layer; -} - /** * Return with the screen of an object * @param obj pointer to an object @@ -1369,10 +1304,19 @@ lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj) return (lv_obj_t *)act_p; } -lv_disp_t * lv_scr_get_disp(lv_obj_t * scr) +/** + * Get the display of an object + * @param scr pointer to an object + * @return pointer the object's display + */ +lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj) { - lv_disp_t * d; + const lv_obj_t * scr; + if(obj->par == NULL) scr = obj; /*`obj` is a screen*/ + else scr = lv_obj_get_screen(obj); /*get the screen of `obj`*/ + + lv_disp_t * d; LL_READ(LV_GC_ROOT(_lv_disp_ll), d) { lv_obj_t * s; LL_READ(d->scr_ll, s) { @@ -1384,14 +1328,6 @@ lv_disp_t * lv_scr_get_disp(lv_obj_t * scr) return NULL; } - - -lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj) -{ - lv_obj_t * scr = lv_obj_get_screen(obj); - return lv_scr_get_disp(scr); -} - /*--------------------- * Parent/children get *--------------------*/ diff --git a/lv_core/lv_obj.h b/lv_core/lv_obj.h index 29f3ac9dd..ca4380c0b 100644 --- a/lv_core/lv_obj.h +++ b/lv_core/lv_obj.h @@ -261,16 +261,6 @@ void lv_obj_invalidate(const lv_obj_t * obj); * Setter functions *====================*/ -/*-------------- - * Screen set - *--------------*/ - -/** - * Load a new screen - * @param scr pointer to a screen - */ -void lv_scr_load(lv_obj_t * scr); - /*-------------------- * Parent/children set *--------------------*/ @@ -540,28 +530,6 @@ void lv_obj_animate(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint1 * Getter functions *======================*/ -/*------------------ - * Screen get - *-----------------*/ - -/** - * Return with a pointer to the active screen - * @return pointer to the active screen object (loaded by 'lv_scr_load()') - */ -lv_obj_t * lv_scr_act(lv_disp_t * disp); - -/** - * Return with the top layer. (Same on every screen and it is above the normal screen layer) - * @return pointer to the top layer object (transparent screen sized lv_obj) - */ -lv_obj_t * lv_layer_top(lv_disp_t * disp); - -/** - * Return with the sys. layer. (Same on every screen and it is above the normal screen layer) - * @return pointer to the sys layer object (transparent screen sized lv_obj) - */ -lv_obj_t * lv_layer_sys(lv_disp_t * disp); - /** * Return with the screen of an object * @param obj pointer to an object @@ -569,9 +537,11 @@ lv_obj_t * lv_layer_sys(lv_disp_t * disp); */ lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj); - -lv_disp_t * lv_scr_get_disp(lv_obj_t * scr); - +/** + * Get the display of an object + * @param scr pointer to an object + * @return pointer the object's display + */ lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj); /*--------------------- diff --git a/lv_core/lv_refr.c b/lv_core/lv_refr.c index 3f854c1ad..e665e1a11 100644 --- a/lv_core/lv_refr.c +++ b/lv_core/lv_refr.c @@ -39,8 +39,6 @@ static void lv_refr_vdb_flush(void); /********************** * STATIC VARIABLES **********************/ -static void (*monitor_cb)(uint32_t, uint32_t); /*Monitor the rendering time*/ -static void (*round_cb)(lv_area_t *); /*If set then called to modify invalidated areas for special display controllers*/ static uint32_t px_num; static lv_disp_t * disp_refr; /*Display being refreshed*/ @@ -103,7 +101,7 @@ void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p) /*The area is truncated to the screen*/ if(suc != false) { - if(round_cb) round_cb(&com_area); + if(disp_refr->driver.rounder_cb) disp_refr->driver.rounder_cb(disp_refr, &com_area); /*Save only if this area is not in one of the saved areas*/ uint16_t i; @@ -122,29 +120,6 @@ void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p) } } - -/** - * Set a function to call after every refresh to announce the refresh time and the number of refreshed pixels - * @param cb pointer to a callback function (void my_refr_cb(uint32_t time_ms, uint32_t px_num)) - * time_ms: refresh time in [ms] - * px_num: not the drawn pixels but the number of affected pixels of the screen - * (more pixels are drawn because of overlapping objects) - */ -void lv_refr_set_monitor_cb(void (*cb)(uint32_t, uint32_t)) -{ - monitor_cb = cb; -} - -/** - * Called when an area is invalidated to modify the coordinates of the area. - * Special display controllers may require special coordinate rounding - * @param cb pointer to the a function which will modify the area - */ -void lv_refr_set_round_cb(void(*cb)(lv_area_t *)) -{ - round_cb = cb; -} - /** * Get the display which is being refreshed * @return the display being refreshed @@ -180,8 +155,8 @@ static void lv_refr_task(void * param) /*If refresh happened ...*/ if(disp_refr->inv_p != 0) { /*In true double buffered mode copy the refreshed areas to the new VDB to keep it up to date*/ - if(lv_disp_is_true_double_buffered(disp_refr)) { - lv_disp_buf_t * vdb = lv_disp_get_vdb(disp_refr); + if(lv_disp_is_true_double_buf(disp_refr)) { + lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr); /*Flush the content of the VDB*/ lv_refr_vdb_flush(); @@ -194,16 +169,17 @@ static void lv_refr_task(void * param) uint8_t * buf_act = (uint8_t *) vdb->buf_act; uint8_t * buf_ina = (uint8_t *) vdb->buf_act == vdb->buf1 ? vdb->buf2 : vdb->buf1; + lv_coord_t hres = lv_disp_get_hor_res(disp_refr); uint16_t a; for(a = 0; a < disp_refr->inv_p; a++) { if(disp_refr->inv_area_joined[a] == 0) { lv_coord_t y; - uint32_t start_offs = ((disp_refr->driver.hor_res * disp_refr->inv_areas[a].y1 + disp_refr->inv_areas[a].x1) * LV_VDB_PX_BPP) >> 3; - uint32_t line_length = (lv_area_get_width(&disp_refr->inv_areas[a]) * LV_VDB_PX_BPP) >> 3; + uint32_t start_offs = (hres * disp_refr->inv_areas[a].y1 + disp_refr->inv_areas[a].x1) * sizeof(lv_color_t); + uint32_t line_length = lv_area_get_width(&disp_refr->inv_areas[a]) * sizeof(lv_color_t); for(y = disp_refr->inv_areas[a].y1; y <= disp_refr->inv_areas[a].y2; y++) { memcpy(buf_act + start_offs, buf_ina + start_offs, line_length); - start_offs += (LV_HOR_RES * LV_VDB_PX_BPP) >> 3; + start_offs += hres * sizeof(lv_color_t); } } } @@ -215,8 +191,8 @@ static void lv_refr_task(void * param) disp_refr->inv_p = 0; /*Call monitor cb if present*/ - if(monitor_cb != NULL) { - monitor_cb(lv_tick_elaps(start), px_num); + if(disp_refr->driver.monitor_cb) { + disp_refr->driver.monitor_cb(disp_refr, lv_tick_elaps(start), px_num); } } } @@ -278,7 +254,7 @@ static void lv_refr_areas(void) lv_refr_area(&disp_refr->inv_areas[i]); - if(monitor_cb != NULL) px_num += lv_area_get_size(&disp_refr->inv_areas[i]); + if(disp_refr->driver.monitor_cb) px_num += lv_area_get_size(&disp_refr->inv_areas[i]); } } } @@ -290,17 +266,17 @@ static void lv_refr_areas(void) static void lv_refr_area(const lv_area_t * area_p) { /*True double buffering: there are two screen sized buffers. Just redraw directly into a buffer*/ - if(lv_disp_is_true_double_buffered(disp_refr)) { - lv_disp_buf_t * vdb = lv_disp_get_vdb(disp_refr); + if(lv_disp_is_true_double_buf(disp_refr)) { + lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr); vdb->area.x1 = 0; - vdb->area.x2 = LV_HOR_RES-1; + vdb->area.x2 = lv_disp_get_hor_res(disp_refr) - 1; vdb->area.y1 = 0; - vdb->area.y2 = LV_VER_RES - 1; + vdb->area.y2 = lv_disp_get_ver_res(disp_refr) - 1; lv_refr_area_part(area_p); } /*The buffer is smaller: refresh the area in parts*/ else { - lv_disp_buf_t * vdb = lv_disp_get_vdb(disp_refr); + lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr); /*Calculate the max row num*/ lv_coord_t w = lv_area_get_width(area_p); lv_coord_t h = lv_area_get_height(area_p); @@ -311,7 +287,7 @@ static void lv_refr_area(const lv_area_t * area_p) if(max_row > h) max_row = h; /*Round down the lines of VDB if rounding is added*/ - if(round_cb) { + if(disp_refr->driver.rounder_cb) { lv_area_t tmp; tmp.x1 = 0; tmp.x2 = 0; @@ -321,7 +297,7 @@ static void lv_refr_area(const lv_area_t * area_p) lv_coord_t y_tmp = max_row; do { tmp.y2 = y_tmp; - round_cb(&tmp); + disp_refr->driver.rounder_cb(disp_refr, &tmp); y_tmp --; /*Decrement the number of line until it is rounded to a smaller (or equal) value then the original. */ } while(lv_area_get_height(&tmp) > max_row && y_tmp != 0); @@ -368,10 +344,10 @@ static void lv_refr_area(const lv_area_t * area_p) static void lv_refr_area_part(const lv_area_t * area_p) { - lv_disp_buf_t * vdb = lv_disp_get_vdb(disp_refr); + lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr); /*In non double buffered mode, before rendering the next part wait until the previous image is flushed*/ - if(lv_disp_is_double_vdb(disp_refr) == false) { + if(lv_disp_is_double_buf(disp_refr) == false) { while(vdb->flushing); } @@ -383,18 +359,18 @@ static void lv_refr_area_part(const lv_area_t * area_p) lv_area_intersect(&start_mask, area_p, &vdb->area); /*Get the most top object which is not covered by others*/ - top_p = lv_refr_get_top_obj(&start_mask, lv_scr_act(disp_refr)); + top_p = lv_refr_get_top_obj(&start_mask, lv_disp_get_scr_act(disp_refr)); /*Do the refreshing from the top object*/ lv_refr_obj_and_children(top_p, &start_mask); /*Also refresh top and sys layer unconditionally*/ - lv_refr_obj_and_children(lv_layer_top(disp_refr), &start_mask); - lv_refr_obj_and_children(lv_layer_sys(disp_refr), &start_mask); + lv_refr_obj_and_children(lv_disp_get_layer_top(disp_refr), &start_mask); + lv_refr_obj_and_children(lv_disp_get_layer_sys(disp_refr), &start_mask); /* In true double buffered mode flush only once when all areas were rendered. * In normal mode flush after every area */ - if(lv_disp_is_true_double_buffered(disp_refr) == false) { + if(lv_disp_is_true_double_buf(disp_refr) == false) { lv_refr_vdb_flush(); } } @@ -445,7 +421,7 @@ static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p) /* Normally always will be a top_obj (at least the screen) * but in special cases (e.g. if the screen has alpha) it won't. * In this case use the screen directly */ - if(top_p == NULL) top_p = lv_scr_act(disp_refr); + if(top_p == NULL) top_p = lv_disp_get_scr_act(disp_refr); /*Refresh the top object and its children*/ lv_refr_obj(top_p, mask_p); @@ -552,7 +528,7 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p) */ static void lv_refr_vdb_flush(void) { - lv_disp_buf_t * vdb = lv_disp_get_vdb(lv_refr_get_disp_refreshing()); + lv_disp_buf_t * vdb = lv_disp_get_buf(lv_refr_get_disp_refreshing()); /*In double buffered mode wait until the other buffer is flushed before flushing the current one*/ if(vdb->buf1 && vdb->buf2) { @@ -563,7 +539,7 @@ static void lv_refr_vdb_flush(void) /*Flush the rendered content to the display*/ lv_disp_t * disp = lv_refr_get_disp_refreshing(); - if(disp->driver.disp_flush) disp->driver.disp_flush(disp, &vdb->area, vdb->buf_act); + if(disp->driver.flush_cb) disp->driver.flush_cb(disp, &vdb->area, vdb->buf_act); if(vdb->buf1 && vdb->buf2) { diff --git a/lv_core/lv_refr.h b/lv_core/lv_refr.h index a00e6ef92..2bd7d2b63 100644 --- a/lv_core/lv_refr.h +++ b/lv_core/lv_refr.h @@ -60,20 +60,6 @@ void lv_refr_now(void); */ void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p); - -/** - * Set a function to call after every refresh to announce the refresh time and the number of refreshed pixels - * @param cb pointer to a callback function (void my_refr_cb(uint32_t time_ms, uint32_t px_num)) - */ -void lv_refr_set_monitor_cb(void (*cb)(uint32_t, uint32_t)); - -/** - * Called when an area is invalidated to modify the coordinates of the area. - * Special display controllers may require special coordinate rounding - * @param cb pointer to the a function which will modify the area - */ -void lv_refr_set_round_cb(void(*cb)(lv_area_t*)); - /** * Get the number of areas in the buffer * @return number of invalid areas diff --git a/lv_draw/lv_draw.mk b/lv_draw/lv_draw.mk index a384eefea..70fa7103f 100644 --- a/lv_draw/lv_draw.mk +++ b/lv_draw/lv_draw.mk @@ -1,5 +1,4 @@ -CSRCS += lv_draw_vbasic.c -CSRCS += lv_draw_rbasic.c +CSRCS += lv_draw_basic.c CSRCS += lv_draw.c CSRCS += lv_draw_rect.c CSRCS += lv_draw_label.c diff --git a/lv_draw/lv_draw_basic.c b/lv_draw/lv_draw_basic.c index 516af1b9e..f675e54b5 100644 --- a/lv_draw/lv_draw_basic.c +++ b/lv_draw/lv_draw_basic.c @@ -79,15 +79,15 @@ void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t } lv_disp_t * disp = lv_refr_get_disp_refreshing(); - lv_disp_buf_t * vdb = lv_disp_get_vdb(disp); + lv_disp_buf_t * vdb = lv_disp_get_buf(disp); uint32_t vdb_width = lv_area_get_width(&vdb->area); /*Make the coordinates relative to VDB*/ x -= vdb->area.x1; y -= vdb->area.y1; - if(disp->driver.vdb_wr) { - disp->driver.vdb_wr((uint8_t *)vdb->buf_act, vdb_width, x, y, color, opa); + if(disp->driver.set_px_cb) { + disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width, x, y, color, opa); } else { lv_color_t * vdb_px_p = vdb->buf_act; vdb_px_p += y * vdb_width + x; @@ -129,7 +129,7 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, if(union_ok == false) return; lv_disp_t * disp = lv_refr_get_disp_refreshing(); - lv_disp_buf_t * vdb = lv_disp_get_vdb(disp); + lv_disp_buf_t * vdb = lv_disp_get_buf(disp); lv_area_t vdb_rel_a; /*Stores relative coordinates on vdb*/ vdb_rel_a.x1 = res_a.x1 - vdb->area.x1; @@ -290,7 +290,7 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, pos_y + letter_h < mask_p->y1 || pos_y > mask_p->y2) return; lv_disp_t * disp = lv_refr_get_disp_refreshing(); - lv_disp_buf_t * vdb = lv_disp_get_vdb(disp); + lv_disp_buf_t * vdb = lv_disp_get_buf(disp); lv_coord_t vdb_width = lv_area_get_width(&vdb->area); lv_color_t * vdb_buf_tmp = vdb->buf_act; @@ -335,8 +335,8 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, (uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8; } - if(disp->driver.vdb_wr) { - disp->driver.vdb_wr((uint8_t *)vdb->buf_act, vdb_width, + if(disp->driver.set_px_cb) { + disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width, (col + pos_x) - vdb->area.x1, (row + pos_y) - vdb->area.y1, color, px_opa); } else { @@ -409,7 +409,7 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, } lv_disp_t * disp = lv_refr_get_disp_refreshing(); - lv_disp_buf_t * vdb = lv_disp_get_vdb(disp); + lv_disp_buf_t * vdb = lv_disp_get_buf(disp); /*Stores coordinates relative to the current VDB*/ masked_a.x1 = masked_a.x1 - vdb->area.x1; @@ -429,12 +429,12 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, if(chroma_key == false && alpha_byte == false && opa == LV_OPA_COVER && recolor_opa == LV_OPA_TRANSP) { /*Use the custom VDB write function is exists*/ - if(disp->driver.vdb_wr) { + if(disp->driver.set_px_cb) { lv_coord_t col; for(row = masked_a.y1; row <= masked_a.y2; row++) { for(col = 0; col < map_useful_w; col++) { lv_color_t px_color = *((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]); - disp->driver.vdb_wr((uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa); + disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa); } map_p += map_width * px_size_byte; /*Next row on the map*/ } @@ -496,8 +496,8 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, recolored_px = lv_color_mix(recolor, last_img_px, recolor_opa); } /*Handle custom VDB write is present*/ - if(disp->driver.vdb_wr) { - disp->driver.vdb_wr((uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, recolored_px, opa_result); + if(disp->driver.set_px_cb) { + disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, recolored_px, opa_result); } /*Normal native VDB write*/ else { @@ -506,8 +506,8 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, } } else { /*Handle custom VDB write is present*/ - if(disp->driver.vdb_wr) { - disp->driver.vdb_wr((uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa_result); + if(disp->driver.set_px_cb) { + disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa_result); } /*Normal native VDB write*/ else { @@ -568,10 +568,10 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_ lv_coord_t mem_width = lv_area_get_width(mem_area); lv_disp_t * disp = lv_refr_get_disp_refreshing(); - if(disp->driver.vdb_wr) { + if(disp->driver.set_px_cb) { for(col = fill_area->x1; col <= fill_area->x2; col++) { for(row = fill_area->y1; row <= fill_area->y2; row++) { - disp->driver.vdb_wr((uint8_t *)mem, mem_width, col, row, color, opa); + disp->driver.set_px_cb(disp, (uint8_t *)mem, mem_width, col, row, color, opa); } } } else { diff --git a/lv_hal/lv_hal_disp.c b/lv_hal/lv_hal_disp.c index 9e02c1fab..82e597fb3 100644 --- a/lv_hal/lv_hal_disp.c +++ b/lv_hal/lv_hal_disp.c @@ -24,9 +24,6 @@ /********************* * DEFINES *********************/ -#ifndef LV_ATTRIBUTE_FLUSH_READY -# define LV_ATTRIBUTE_FLUSH_READY -#endif /********************** * TYPEDEFS @@ -59,7 +56,7 @@ void lv_disp_drv_init(lv_disp_drv_t * driver) { memset(driver, 0, sizeof(lv_disp_drv_t)); - driver->disp_flush = NULL; + driver->flush_cb = NULL; driver->hor_res = LV_HOR_RES_MAX; driver->ver_res = LV_VER_RES_MAX; driver->buffer = NULL; @@ -69,7 +66,7 @@ void lv_disp_drv_init(lv_disp_drv_t * driver) driver->mem_fill = NULL; #endif - driver->vdb_wr = NULL; + driver->set_px_cb = NULL; } @@ -119,54 +116,48 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) if(disp_def == NULL) disp_def = disp; + lv_disp_t * disp_def_tmp = disp_def; + disp_def = disp; /*Temporarily change the default screen to create the default screens on the new display*/ + disp->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/ disp->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/ disp->sys_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/ lv_obj_set_style(disp->top_layer, &lv_style_transp); lv_obj_set_style(disp->sys_layer, &lv_style_transp); - lv_disp_assign_screen(disp, disp->act_scr); - lv_disp_assign_screen(disp, disp->top_layer); - lv_disp_assign_screen(disp, disp->sys_layer); - disp->inv_p = 0; - disp->vdb_act = 0; - disp->vdb_flushing = 0; lv_obj_invalidate(disp->act_scr); + disp_def = disp_def_tmp; /*Revert the default display*/ + return disp; } /** - * Get the next display. - * @param disp pointer to the current display. NULL to initialize. - * @return the next display or NULL if no more. Give the first display when the parameter is NULL + * Set a default screen. The new screens will be created on it by default. + * @param disp pointer to a display */ -lv_disp_t * lv_disp_get_next(lv_disp_t * disp) -{ - if(disp == NULL) return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll)); - else return lv_ll_get_next(&LV_GC_ROOT(_lv_disp_ll), disp); -} - - void lv_disp_set_default(lv_disp_t * disp) { disp_def = disp; } - +/** + * Get the default display + * @return pointer to the default display + */ lv_disp_t * lv_disp_get_default(void) { return disp_def; } -lv_disp_buf_t * lv_disp_get_vdb(lv_disp_t * disp) -{ - return disp->driver.buffer; -} - +/** + * Get the horizontal resolution of a display + * @param disp pointer to a display (NULL to use the default display) + * @return the horizontal resolution of the display + */ lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp) { if(disp == NULL) disp = lv_disp_get_default(); @@ -175,7 +166,11 @@ lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp) else return disp->driver.hor_res; } - +/** + * Get the vertical resolution of a display + * @param disp pointer to a display (NULL to use the default display) + * @return the vertical resolution of the display + */ lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp) { if(disp == NULL) disp = lv_disp_get_default(); @@ -184,19 +179,6 @@ lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp) else return disp->driver.ver_res; } -bool lv_disp_is_double_vdb(lv_disp_t * disp) -{ - if(disp->driver.buffer->buf1 && disp->driver.buffer->buf2) return true; - else return false; -} - -bool lv_disp_is_true_double_buffered(lv_disp_t * disp) -{ - if(lv_disp_is_double_vdb(disp) && disp->driver.buffer->size == disp->driver.hor_res * disp->driver.ver_res) return true; - else return false; -} - - /** * Call in the display driver's `flush` function when the flushing is finished */ @@ -211,7 +193,77 @@ LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_t * disp) } +/** + * Get the next display. + * @param disp pointer to the current display. NULL to initialize. + * @return the next display or NULL if no more. Give the first display when the parameter is NULL + */ +lv_disp_t * lv_disp_get_next(lv_disp_t * disp) +{ + if(disp == NULL) return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll)); + else return lv_ll_get_next(&LV_GC_ROOT(_lv_disp_ll), disp); +} + +/** + * Get the internal buffer of a display + * @param disp pointer to a display + * @return pointer to the internal buffers + */ +lv_disp_buf_t * lv_disp_get_buf(lv_disp_t * disp) +{ + return disp->driver.buffer; +} + +/** + * Get the number of areas in the buffer + * @return number of invalid areas + */ +uint16_t lv_disp_get_inv_buf_size(lv_disp_t * disp) +{ + return disp->inv_p; +} + +/** + * Pop (delete) the last 'num' invalidated areas from the buffer + * @param num number of areas to delete + */ +void lv_disp_pop_from_inv_buf(lv_disp_t * disp, uint16_t num) +{ + + if(disp->inv_p < num) disp->inv_p = 0; + else disp->inv_p -= num; +} + +/** + * Check the driver configuration if it's double buffered (both `buf1` and `buf2` are set) + * @param disp pointer to to display to check + * @return true: double buffered; false: not double buffered + */ +bool lv_disp_is_double_buf(lv_disp_t * disp) +{ + if(disp->driver.buffer->buf1 && disp->driver.buffer->buf2) return true; + else return false; +} + +/** + * Check the driver configuration if it's TRUE double buffered (both `buf1` and `buf2` are set and `size` is screen sized) + * @param disp pointer to to display to check + * @return true: double buffered; false: not double buffered + */ +bool lv_disp_is_true_double_buf(lv_disp_t * disp) +{ + uint32_t scr_size = disp->driver.hor_res * disp->driver.ver_res; + + if(lv_disp_is_double_buf(disp) && + disp->driver.buffer->size == scr_size) { + return true; + } + else { + return false; + } +} + + /********************** * STATIC FUNCTIONS **********************/ - diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index 01be7003a..256e377f1 100644 --- a/lv_hal/lv_hal_disp.h +++ b/lv_hal/lv_hal_disp.h @@ -29,6 +29,10 @@ extern "C" { #define LV_INV_BUF_SIZE 32 /*Buffer size for invalid areas */ #endif +#ifndef LV_ATTRIBUTE_FLUSH_READY +# define LV_ATTRIBUTE_FLUSH_READY +#endif + /********************** * TYPEDEFS **********************/ @@ -53,28 +57,42 @@ typedef struct * Display Driver structure to be registered by HAL */ typedef struct _disp_drv_t { - int user_data; + /*Horizontal and vertical resolution*/ lv_coord_t hor_res; - lv_coord_t ver_res; + /* Pointer to a buffer initialized with `lv_disp_buf_init()`. + * LittlevGL will use this buffer(s) to draw the screens contents */ lv_disp_buf_t * buffer; - /*Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished*/ - void (*disp_flush)(struct _disp_t * disp, const lv_area_t * area, lv_color_t * color_p); + /* MANDATORY: Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished */ + void (*flush_cb)(struct _disp_t * disp, const lv_area_t * area, lv_color_t * color_p); + lv_disp_user_data_t flush_user_data; + + /* OPTIONAL: Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */ + void (*monitor_cb)(struct _disp_t * disp, uint32_t time, uint32_t px); + lv_disp_user_data_t monitor_user_data; + + /* OPTIONAL: Extend the invalidated areas to match with the display drivers requirements + * E.g. round `y` to, 8, 16 ..) on a monochrome display*/ + void (*rounder_cb)(struct _disp_t * disp, lv_area_t * area); + lv_disp_user_data_t rounder_user_data; + + /* OPTIONAL: Set a pixel in a buffer according to the special requirements of the display + * Can be used for color format not supported in LittelvGL. E.g. 2 bit -> 4 gray scales + * Note: Much slower then drawing with supported color formats. */ + void (*set_px_cb)(struct _disp_t * disp, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa); + lv_disp_user_data_t set_px_user_data; - /*Optional interface functions to use GPU*/ #if USE_LV_GPU - /*Blend two memories using opacity (GPU only)*/ + /*OPTIONAL: Blend two memories using opacity (GPU only)*/ void (*mem_blend)(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa); - /*Fill a memory with a color (GPU only)*/ + /*OPTIONAL: Fill a memory with a color (GPU only)*/ void (*mem_fill)(lv_color_t * dest, uint32_t length, lv_color_t color); #endif - /*Optional: Set a pixel in a buffer according to the requirements of the display*/ - void (*vdb_wr)(uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa); } lv_disp_drv_t; struct _lv_obj_t; @@ -88,9 +106,6 @@ typedef struct _disp_t { lv_area_t inv_areas[LV_INV_BUF_SIZE]; uint8_t inv_area_joined[LV_INV_BUF_SIZE]; uint32_t inv_p :10; - uint32_t orientation :2; - uint32_t vdb_flushing :1; - uint32_t vdb_act :1; } lv_disp_t; /********************** @@ -103,15 +118,7 @@ typedef struct _disp_t { * After it you can set the fields. * @param driver pointer to driver variable to initialize */ -void lv_disp_drv_init(lv_disp_drv_t *driver); - -/** - * Register an initialized display driver. - * Automatically set the first display as active. - * @param driver pointer to an initialized 'lv_disp_drv_t' variable (can be local variable) - * @return pointer to the new display or NULL on error - */ -lv_disp_t * lv_disp_drv_register(lv_disp_drv_t *driver); +void lv_disp_drv_init(lv_disp_drv_t * driver); /** @@ -131,12 +138,46 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t *driver); */ void lv_disp_buf_init(lv_disp_buf_t * disp_buf, void * buf1, void * buf2, uint32_t size); +/** + * Register an initialized display driver. + * Automatically set the first display as active. + * @param driver pointer to an initialized 'lv_disp_drv_t' variable (can be local variable) + * @return pointer to the new display or NULL on error + */ +lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver); +/** + * Set a default screen. The new screens will be created on it by default. + * @param disp pointer to a display + */ void lv_disp_set_default(lv_disp_t * disp); +/** + * Get the default display + * @return pointer to the default display + */ lv_disp_t * lv_disp_get_default(void); -lv_disp_buf_t * lv_disp_get_vdb(lv_disp_t * disp); +/** + * Get the horizontal resolution of a display + * @param disp pointer to a display (NULL to use the default display) + * @return the horizontal resolution of the display + */ +lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp); + +/** + * Get the vertical resolution of a display + * @param disp pointer to a display (NULL to use the default display) + * @return the vertical resolution of the display + */ +lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp); + +/** + * Call in the display driver's `flush` function when the flushing is finished + */ +LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_t * disp); + + /** * Get the next display. * @param disp pointer to the current display. NULL to initialize. @@ -144,13 +185,39 @@ lv_disp_buf_t * lv_disp_get_vdb(lv_disp_t * disp); */ lv_disp_t * lv_disp_get_next(lv_disp_t * disp); +/** + * Get the internal buffer of a display + * @param disp pointer to a display + * @return pointer to the internal buffers + */ +lv_disp_buf_t * lv_disp_get_buf(lv_disp_t * disp); -lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp); -lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp); +/** + * Get the number of areas in the buffer + * @return number of invalid areas + */ +uint16_t lv_disp_get_inv_buf_size(lv_disp_t * disp); -bool lv_disp_is_double_vdb(lv_disp_t * disp); +/** + * Pop (delete) the last 'num' invalidated areas from the buffer + * @param num number of areas to delete + */ +void lv_disp_pop_from_inv_buf(lv_disp_t * disp, uint16_t num); + +/** + * Check the driver configuration if it's double buffered (both `buf1` and `buf2` are set) + * @param disp pointer to to display to check + * @return true: double buffered; false: not double buffered + */ +bool lv_disp_is_double_buf(lv_disp_t * disp); + +/** + * Check the driver configuration if it's TRUE double buffered (both `buf1` and `buf2` are set and `size` is screen sized) + * @param disp pointer to to display to check + * @return true: double buffered; false: not double buffered + */ +bool lv_disp_is_true_double_buf(lv_disp_t * disp); -bool lv_disp_is_true_double_buffered(lv_disp_t * disp); /********************** * MACROS **********************/ diff --git a/lv_hal/lv_hal_indev.c b/lv_hal/lv_hal_indev.c index 6adb4be96..2604bc08c 100644 --- a/lv_hal/lv_hal_indev.c +++ b/lv_hal/lv_hal_indev.c @@ -50,10 +50,9 @@ */ void lv_indev_drv_init(lv_indev_drv_t * driver) { - driver->read = NULL; + memset(driver, 0, sizeof(lv_indev_drv_t)); + driver->type = LV_INDEV_TYPE_NONE; - driver->disp = NULL; - driver->user_data = NULL; } /** @@ -110,13 +109,11 @@ bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data) bool cont = false; memset(data, 0, sizeof(lv_indev_data_t)); - data->state = LV_INDEV_STATE_REL; - if(indev->driver.read) { - data->user_data = indev->driver.user_data; + if(indev->driver.read_cb) { LV_LOG_TRACE("idnev read started"); - cont = indev->driver.read(data); + cont = indev->driver.read_cb(indev, data); LV_LOG_TRACE("idnev read finished"); } else { LV_LOG_WARN("indev function registered"); diff --git a/lv_hal/lv_hal_indev.h b/lv_hal/lv_hal_indev.h index 2186e2dab..a9208d997 100644 --- a/lv_hal/lv_hal_indev.h +++ b/lv_hal/lv_hal_indev.h @@ -15,6 +15,12 @@ extern "C" { /********************* * INCLUDES *********************/ +#ifdef LV_CONF_INCLUDE_SIMPLE +#include "lv_conf.h" +#else +#include "../../lv_conf.h" +#endif + #include #include #include "../lv_misc/lv_area.h" @@ -28,6 +34,7 @@ extern "C" { **********************/ struct _disp_t; +struct _lv_indev_t; /*Possible input device types*/ enum { @@ -48,22 +55,23 @@ typedef uint8_t lv_indev_state_t; /*Data type when an input device is read */ typedef struct { - void *user_data; /*'lv_indev_drv_t.priv' for this driver*/ union { - lv_point_t point; /*For LV_INDEV_TYPE_POINTER the currently pressed point*/ - uint32_t key; /*For LV_INDEV_TYPE_KEYPAD the currently pressed key*/ - uint32_t btn; /*For LV_INDEV_TYPE_BUTTON the currently pressed button*/ - int16_t enc_diff; /*For LV_INDEV_TYPE_ENCODER number of steps since the previous read*/ + lv_point_t point; /*For LV_INDEV_TYPE_POINTER the currently pressed point*/ + uint32_t key; /*For LV_INDEV_TYPE_KEYPAD the currently pressed key*/ + uint32_t btn_id; /*For LV_INDEV_TYPE_BUTTON the currently pressed button*/ + int16_t enc_diff; /*For LV_INDEV_TYPE_ENCODER number of steps since the previous read*/ }; + lv_indev_state_t state; /*LV_INDEV_STATE_REL or LV_INDEV_STATE_PR*/ + } lv_indev_data_t; /*Initialized by the user and registered by 'lv_indev_add()'*/ typedef struct { - lv_hal_indev_type_t type; /*Input device type*/ - bool (*read)(lv_indev_data_t *data); /*Function pointer to read data. Return 'true' if there is still data to be read (buffered)*/ + lv_hal_indev_type_t type; /*Input device type*/ + bool (*read_cb)(struct _lv_indev_t * indev, lv_indev_data_t *data); /*Function pointer to read_cb data. Return 'true' if there is still data to be read_cb (buffered)*/ + lv_indev_user_data_t read_user_data; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/ struct _disp_t * disp; - void *user_data; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/ } lv_indev_drv_t; struct _lv_obj_t; @@ -100,8 +108,6 @@ typedef struct _lv_indev_proc_t { uint8_t disabled :1; } lv_indev_proc_t; -struct _lv_indev_t; - typedef void (*lv_indev_feedback_t)(struct _lv_indev_t *, uint8_t); struct _lv_obj_t; diff --git a/lv_objx/lv_win.c b/lv_objx/lv_win.c index 49fb3eb1c..bbeee6736 100644 --- a/lv_objx/lv_win.c +++ b/lv_objx/lv_win.c @@ -10,6 +10,7 @@ #if USE_LV_WIN != 0 #include "../lv_themes/lv_theme.h" +#include "../lv_core/lv_disp.h" /********************* * DEFINES @@ -70,7 +71,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new window object*/ if(copy == NULL) { - lv_obj_t * disp = lv_obj_get_disp(new_win); + lv_disp_t * disp = lv_obj_get_disp(new_win); lv_coord_t hres = lv_disp_get_hor_res(disp); lv_coord_t vres = lv_disp_get_ver_res(disp); lv_obj_set_size(new_win, hres, vres); diff --git a/lv_porting/lv_port_disp_templ.c b/lv_porting/lv_port_disp_templ.c index 18e676372..c2d819027 100644 --- a/lv_porting/lv_port_disp_templ.c +++ b/lv_porting/lv_port_disp_templ.c @@ -24,9 +24,7 @@ **********************/ static void disp_init(void); -static void disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p); -static void disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p); -static void disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color); +static void disp_flush(lv_disp_t * disp, const lv_area_t * area, lv_color_t * color_p); #if USE_LV_GPU static void mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa); static void mem_fill(lv_color_t * dest, uint32_t length, lv_color_t color); @@ -51,6 +49,41 @@ void lv_port_disp_init(void) * -----------------------*/ disp_init(); + /*----------------------------- + * Create a buffer for drawing + *----------------------------*/ + + /* LittlevGL requires a buffer where it draw the objects. The buffer's has to be greater than 1 display row + * + * There are three buffering configurations: + * 1. Create ONE buffer some rows: LittlevGL will draw the display's content here and writes it to your display + * 2. Create TWO buffer some rows: LittlevGL will draw the display's content to a buffer and writes it your display. + * You should use DMA to write the buffer's content to the display. + * It will enable LittlevGL to draw the next part of the screen to the other buffer while + * the data is being sent form the first buffer. It makes rendering and flushing parallel. + * 3. Create TWO screen buffer: Similar to 2) but the buffer have to be screen sized. When LittlevGL is ready it will give the + * whole frame to display. This way you only need to change the frame buffer's address instead of + * copying the pixels. + * */ + + /* Example for 1) */ + static lv_disp_buf_t disp_buf_1; + static lv_color_t buf1_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/ + lv_disp_buf_init(&disp_buf_1, buf1_1, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/ + + /* Example for 2) */ + static lv_disp_buf_t disp_buf_2; + static lv_color_t buf2_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/ + static lv_color_t buf2_2[LV_HOR_RES_MAX * 10]; /*An other buffer for 10 rows*/ + lv_disp_buf_init(&disp_buf_2, buf2_1, buf2_2, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/ + + /* Example for 3) */ + static lv_disp_buf_t disp_buf_3; + static lv_color_t buf3_1[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*A screen sized buffer*/ + static lv_color_t buf3_2[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*An other screen sized buffer*/ + lv_disp_buf_init(&disp_buf_3, buf3_1, buf3_2, LV_HOR_RES_MAX * LV_VER_RES_MAX); /*Initialize the display buffer*/ + + /*----------------------------------- * Register the display in LittlevGL *----------------------------------*/ @@ -60,14 +93,8 @@ void lv_port_disp_init(void) /*Set up the functions to access to your display*/ - /*Used in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/ - disp_drv.disp_flush = disp_flush; - - /*Used in unbuffered mode (LV_VDB_SIZE == 0 in lv_conf.h)*/ - disp_drv.disp_fill = disp_fill; - - /*Used in unbuffered mode (LV_VDB_SIZE == 0 in lv_conf.h)*/ - disp_drv.disp_map = disp_map; + /*Used to copy the buffer's content to the display*/ + disp_drv.flush_cb = disp_flush; #if USE_LV_GPU /*Optionally add functions to access the GPU. (Only in buffered mode, LV_VDB_SIZE != 0)*/ @@ -95,16 +122,15 @@ static void disp_init(void) /* Flush the content of the internal buffer the specific area on the display * You can use DMA or any hardware acceleration to do this operation in the background but - * 'lv_flush_ready()' has to be called when finished - * This function is required only when LV_VDB_SIZE != 0 in lv_conf.h*/ -static void disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p) + * 'lv_disp_flush_ready()' has to be called when finished. */ +static void disp_flush(lv_disp_t * disp, const lv_area_t * area, lv_color_t * color_p) { /*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/ int32_t x; int32_t y; - for(y = y1; y <= y2; y++) { - for(x = x1; x <= x2; x++) { + for(y = area->y1; y <= area->y2; y++) { + for(x = area->x1; x <= area->x2; x++) { /* Put a pixel to the display. For example: */ /* put_px(x, y, *color_p)*/ color_p++; @@ -113,46 +139,10 @@ static void disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_ /* IMPORTANT!!! * Inform the graphics library that you are ready with the flushing*/ - lv_flush_ready(); + lv_disp_flush_ready(disp); } -/* Write a pixel array (called 'map') to the a specific area on the display - * This function is required only when LV_VDB_SIZE == 0 in lv_conf.h*/ -static void disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p) -{ - /*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/ - - int32_t x; - int32_t y; - for(y = y1; y <= y2; y++) { - for(x = x1; x <= x2; x++) { - /* Put a pixel to the display. For example: */ - /* put_px(x, y, *color_p)*/ - color_p++; - } - } -} - - -/* Write a pixel array (called 'map') to the a specific area on the display - * This function is required only when LV_VDB_SIZE == 0 in lv_conf.h*/ -static void disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color) -{ - /*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/ - - int32_t x; - int32_t y; - for(y = y1; y <= y2; y++) { - for(x = x1; x <= x2; x++) { - /* Put a pixel to the display. For example: */ - /* put_px(x, y, *color)*/ - } - } - - (void)color; /*Just to avid warnings*/ -} - /*OPTIONAL: GPU INTERFACE*/ #if USE_LV_GPU diff --git a/lv_porting/lv_port_indev_templ.c b/lv_porting/lv_port_indev_templ.c index 60089270e..c89eb0744 100644 --- a/lv_porting/lv_port_indev_templ.c +++ b/lv_porting/lv_port_indev_templ.c @@ -24,25 +24,25 @@ **********************/ static void touchpad_init(void); -static bool touchpad_read(lv_indev_data_t * data); +static bool touchpad_read(lv_indev_t * indev, lv_indev_data_t * data); static bool touchpad_is_pressed(void); static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y); static void mouse_init(void); -static bool mouse_read(lv_indev_data_t * data); +static bool mouse_read(lv_indev_t * indev, lv_indev_data_t * data); static bool mouse_is_pressed(void); static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y); static void keypad_init(void); -static bool keypad_read(lv_indev_data_t * data); +static bool keypad_read(lv_indev_t * indev, lv_indev_data_t * data); static uint32_t keypad_get_key(void); static void encoder_init(void); -static bool encoder_read(lv_indev_data_t * data); +static bool encoder_read(lv_indev_t * indev, lv_indev_data_t * data); static void encoder_handler(void); static void button_init(void); -static bool button_read(lv_indev_data_t * data); +static bool button_read(lv_indev_t * indev, lv_indev_data_t * data); static int8_t button_get_pressed_id(void); static bool button_is_pressed(uint8_t id); @@ -92,7 +92,7 @@ void lv_port_indev_init(void) /*Register a touchpad input device*/ lv_indev_drv_init(&indev_drv); indev_drv.type = LV_INDEV_TYPE_POINTER; - indev_drv.read = touchpad_read; + indev_drv.read_cb = touchpad_read; indev_touchpad = lv_indev_drv_register(&indev_drv); /*------------------ @@ -105,11 +105,11 @@ void lv_port_indev_init(void) /*Register a mouse input device*/ lv_indev_drv_init(&indev_drv); indev_drv.type = LV_INDEV_TYPE_POINTER; - indev_drv.read = mouse_read; + indev_drv.read_cb = mouse_read; indev_mouse = lv_indev_drv_register(&indev_drv); /*Set cursor. For simplicity set a HOME symbol now.*/ - lv_obj_t * mouse_cursor = lv_img_create(lv_scr_act(NULL), NULL); + lv_obj_t * mouse_cursor = lv_img_create(lv_disp_get_scr_act(NULL), NULL); lv_img_set_src(mouse_cursor, SYMBOL_HOME); lv_indev_set_cursor(indev_mouse, mouse_cursor); @@ -123,7 +123,7 @@ void lv_port_indev_init(void) /*Register a keypad input device*/ lv_indev_drv_init(&indev_drv); indev_drv.type = LV_INDEV_TYPE_KEYPAD; - indev_drv.read = keypad_read; + indev_drv.read_cb = keypad_read; indev_keypad = lv_indev_drv_register(&indev_drv); /* Later you should create group(s) with `lv_group_t * group = lv_group_create()`, @@ -141,7 +141,7 @@ void lv_port_indev_init(void) /*Register a encoder input device*/ lv_indev_drv_init(&indev_drv); indev_drv.type = LV_INDEV_TYPE_KEYPAD; - indev_drv.read = encoder_read; + indev_drv.read_cb = encoder_read; indev_encoder = lv_indev_drv_register(&indev_drv); /* Later you should create group(s) with `lv_group_t * group = lv_group_create()`, @@ -159,7 +159,7 @@ void lv_port_indev_init(void) /*Register a button input device*/ lv_indev_drv_init(&indev_drv); indev_drv.type = LV_INDEV_TYPE_BUTTON; - indev_drv.read = button_read; + indev_drv.read_cb = button_read; indev_button = lv_indev_drv_register(&indev_drv); /*Assign buttons to points on the screen*/ @@ -187,7 +187,7 @@ static void touchpad_init(void) } /* Will be called by the library to read the touchpad */ -static bool touchpad_read(lv_indev_data_t * data) +static bool touchpad_read(lv_indev_t * indev, lv_indev_data_t * data) { static lv_coord_t last_x = 0; static lv_coord_t last_y = 0; @@ -237,7 +237,7 @@ static void mouse_init(void) } /* Will be called by the library to read the mouse */ -static bool mouse_read(lv_indev_data_t * data) +static bool mouse_read(lv_indev_t * indev, lv_indev_data_t * data) { /*Get the current x and y coordinates*/ mouse_get_xy(&data->point.x, &data->point.y); @@ -281,7 +281,7 @@ static void keypad_init(void) } /* Will be called by the library to read the mouse */ -static bool keypad_read(lv_indev_data_t * data) +static bool keypad_read(lv_indev_t * indev, lv_indev_data_t * data) { static uint32_t last_key = 0; @@ -342,7 +342,7 @@ static void encoder_init(void) } /* Will be called by the library to read the encoder */ -static bool encoder_read(lv_indev_data_t * data) +static bool encoder_read(lv_indev_t * indev, lv_indev_data_t * data) { data->enc_diff = encoder_diff; @@ -373,7 +373,7 @@ static void button_init(void) } /* Will be called by the library to read the button */ -static bool button_read(lv_indev_data_t * data) +static bool button_read(lv_indev_t * indev, lv_indev_data_t * data) { static uint8_t last_btn = 0; @@ -389,7 +389,7 @@ static bool button_read(lv_indev_data_t * data) } /*Save the last pressed button's ID*/ - data->btn = last_btn; + data->btn_id = last_btn; /*Return `false` because we are not buffering and no more data to read*/ return false; diff --git a/lv_version.h b/lv_version.h index 1e62e1e2b..b718be951 100644 --- a/lv_version.h +++ b/lv_version.h @@ -14,10 +14,10 @@ extern "C" { * INCLUDES *********************/ /*Current version of LittlevGL*/ -#define LVGL_VERSION_MAJOR 5 -#define LVGL_VERSION_MINOR 3 +#define LVGL_VERSION_MAJOR 6 +#define LVGL_VERSION_MINOR 0 #define LVGL_VERSION_PATCH 0 -#define LVGL_VERSION_INFO "" +#define LVGL_VERSION_INFO "dev" /********************* From 0ccaac4e002897a9e135d78a0269c93de37dbecf Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 21 Feb 2019 00:21:59 +0100 Subject: [PATCH 11/17] updade lv_conf_templ.h --- lv_conf_templ.h | 47 ++------------------------------------------ lv_core/lv_refr.c | 2 +- lv_hal/lv_hal_disp.h | 13 ++++++++---- 3 files changed, 12 insertions(+), 50 deletions(-) diff --git a/lv_conf_templ.h b/lv_conf_templ.h index a4712fea6..790648067 100644 --- a/lv_conf_templ.h +++ b/lv_conf_templ.h @@ -43,8 +43,8 @@ *===================*/ /* Horizontal and vertical resolution of the library.*/ -#define LV_HOR_RES (480) -#define LV_VER_RES (320) +#define LV_HOR_RES_MAX (480) +#define LV_VER_RES_MAX (320) /* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide * (Not so important, you can adjust it to modify default sizes and spaces)*/ @@ -56,49 +56,6 @@ /*Screen refresh period in milliseconds*/ #define LV_REFR_PERIOD 30 -/*----------------- - * VDB settings - *----------------*/ - -/* VDB (Virtual Display Buffer) is an internal graphics buffer. - * The GUI will be drawn into this buffer first and then - * the buffer will be passed to your `disp_drv.disp_flush` function to - * copy it to your frame buffer. - * VDB is required for: buffered drawing, opacity, anti-aliasing and shadows - * Learn more: https://docs.littlevgl.com/#Drawing*/ - -/* Size of the VDB in pixels. Typical size: ~1/10 screen. Must be >= LV_HOR_RES - * Setting it to 0 will disable VDB and `disp_drv.disp_fill` and `disp_drv.disp_map` functions - * will be called to draw to the frame buffer directly*/ -#define LV_VDB_SIZE ((LV_VER_RES * LV_HOR_RES) / 10) - - /* Bit-per-pixel of VDB. Useful for monochrome or non-standard color format displays. - * Special formats are handled with `disp_drv.vdb_wr`)*/ -#define LV_VDB_PX_BPP LV_COLOR_SIZE /*LV_COLOR_SIZE comes from LV_COLOR_DEPTH below to set 8, 16 or 32 bit pixel size automatically */ - - /* Place VDB to a specific address (e.g. in external RAM) - * 0: allocate automatically into RAM - * LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/ -#define LV_VDB_ADR 0 - -/* Use two Virtual Display buffers (VDB) to parallelize rendering and flushing - * The flushing should use DMA to write the frame buffer in the background */ -#define LV_VDB_DOUBLE 0 - -/* Place VDB2 to a specific address (e.g. in external RAM) - * 0: allocate automatically into RAM - * LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/ -#define LV_VDB2_ADR 0 - -/* Using true double buffering in `disp_drv.disp_flush` you will always get the image of the whole screen. - * Your only task is to set the rendered image (`color_p` parameter) as frame buffer address or send it to your display. - * The best if you do in the blank period of you display to avoid tearing effect. - * Requires: - * - LV_VDB_SIZE = LV_HOR_RES * LV_VER_RES - * - LV_VDB_DOUBLE = 1 - */ -#define LV_VDB_TRUE_DOUBLE_BUFFERED 0 - /*================= Misc. setting *=================*/ diff --git a/lv_core/lv_refr.c b/lv_core/lv_refr.c index e665e1a11..d17d83917 100644 --- a/lv_core/lv_refr.c +++ b/lv_core/lv_refr.c @@ -101,7 +101,7 @@ void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p) /*The area is truncated to the screen*/ if(suc != false) { - if(disp_refr->driver.rounder_cb) disp_refr->driver.rounder_cb(disp_refr, &com_area); + if(disp->driver.rounder_cb) disp->driver.rounder_cb(disp_refr, &com_area); /*Save only if this area is not in one of the saved areas*/ uint16_t i; diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index 256e377f1..0f83d82a2 100644 --- a/lv_hal/lv_hal_disp.h +++ b/lv_hal/lv_hal_disp.h @@ -70,10 +70,6 @@ typedef struct _disp_drv_t { void (*flush_cb)(struct _disp_t * disp, const lv_area_t * area, lv_color_t * color_p); lv_disp_user_data_t flush_user_data; - /* OPTIONAL: Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */ - void (*monitor_cb)(struct _disp_t * disp, uint32_t time, uint32_t px); - lv_disp_user_data_t monitor_user_data; - /* OPTIONAL: Extend the invalidated areas to match with the display drivers requirements * E.g. round `y` to, 8, 16 ..) on a monochrome display*/ void (*rounder_cb)(struct _disp_t * disp, lv_area_t * area); @@ -85,6 +81,10 @@ typedef struct _disp_drv_t { void (*set_px_cb)(struct _disp_t * disp, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa); lv_disp_user_data_t set_px_user_data; + /* Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */ + void (*monitor_cb)(struct _disp_t * disp, uint32_t time, uint32_t px); + lv_disp_user_data_t monitor_user_data; + #if USE_LV_GPU /*OPTIONAL: Blend two memories using opacity (GPU only)*/ void (*mem_blend)(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa); @@ -98,11 +98,16 @@ typedef struct _disp_drv_t { struct _lv_obj_t; typedef struct _disp_t { + /*Driver to the display*/ lv_disp_drv_t driver; + + /*Screens of the display*/ lv_ll_t scr_ll; struct _lv_obj_t * act_scr; struct _lv_obj_t * top_layer; struct _lv_obj_t * sys_layer; + + /*Invalidated (marked to redraw) areas*/ lv_area_t inv_areas[LV_INV_BUF_SIZE]; uint8_t inv_area_joined[LV_INV_BUF_SIZE]; uint32_t inv_p :10; From d27dfbd6d77d4e32021c407ac779686cb0cbabd1 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 21 Feb 2019 00:50:06 +0100 Subject: [PATCH 12/17] update README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6bfd28d7d..b98d36152 100644 --- a/README.md +++ b/README.md @@ -104,10 +104,10 @@ void my_disp_flush(lv_disp_t * disp, const lv_area_t * area, lv_color_t * color_ ```c lv_indev_drv_init(&indev_drv); /*Descriptor of a input device driver*/ indev_drv.type = LV_INDEV_TYPE_POINTER; /*Touch pad is a pointer-like device*/ -indev_drv.read = touchpad_read; /*Set your driver function*/ +indev_drv.read_cb = my_touchpad_read; /*Set your driver function*/ lv_indev_drv_register(&indev_drv); /*Finally register the driver*/ -bool touchpad_read(lv_indev_data_t * data) +bool my_touchpad_read(lv_indev_t * indev, lv_indev_data_t * data) { static lv_coord_t last_x = 0; static lv_coord_t last_y = 0; @@ -123,9 +123,9 @@ bool touchpad_read(lv_indev_data_t * data) return false; /*Return `false` because we are not buffering and no more data to read*/ } ``` -6. Call `lv_task_handler()` periodically every few milliseconds in the main `while(1)` loop, in Timer interrupt or in an Operation system task. +6. Call `lv_task_handler()` periodically every few milliseconds in the main `while(1)` loop, in a Timer interrupt or in an Operation system task. -For a detailed description check the [Documentation](https://docs.littlevgl.com/#Porting) or the [Porting tutorial](https://github.com/littlevgl/lv_examples/blob/master/lv_tutorial/0_porting/lv_tutorial_porting.c) +For a detailed description check the [Documentation](https://docs.littlevgl.com/#Porting) or the [Porting examples](https://github.com/littlevgl/lvgl/tree/multi-disp/lv_porting). ### Code examples From 69456cd3f5b81f287ae8b5ac081ffa8b54d551f8 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 21 Feb 2019 00:50:14 +0100 Subject: [PATCH 13/17] minor fixes --- lv_porting/lv_port_disp_templ.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lv_porting/lv_port_disp_templ.c b/lv_porting/lv_port_disp_templ.c index c2d819027..bcd251a8a 100644 --- a/lv_porting/lv_port_disp_templ.c +++ b/lv_porting/lv_port_disp_templ.c @@ -96,6 +96,9 @@ void lv_port_disp_init(void) /*Used to copy the buffer's content to the display*/ disp_drv.flush_cb = disp_flush; + /*Set a display buffer*/ + disp_drv.buffer = &disp_buf_2; + #if USE_LV_GPU /*Optionally add functions to access the GPU. (Only in buffered mode, LV_VDB_SIZE != 0)*/ From fd6e5ae3ef564244bc5dd44d8fc56ff9bfa2d490 Mon Sep 17 00:00:00 2001 From: manison Date: Thu, 21 Feb 2019 13:46:32 +0100 Subject: [PATCH 14/17] fix compilation errors when compiler does not support VLAs --- lv_draw/lv_draw_img.c | 2 +- lv_draw/lv_draw_rect.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lv_draw/lv_draw_img.c b/lv_draw/lv_draw_img.c index 0f3d94fe8..369fbb761 100644 --- a/lv_draw/lv_draw_img.c +++ b/lv_draw/lv_draw_img.c @@ -325,7 +325,7 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas #if LV_COMPILER_VLA_SUPPORTED uint8_t buf[(lv_area_get_width(&mask_com) * ((LV_COLOR_DEPTH >> 3) + 1))]; #else - uint8_t buf[LV_HOR_RES * ((LV_COLOR_DEPTH >> 3) + 1)]; /*+1 because of the possible alpha byte*/ + uint8_t buf[LV_HOR_RES_MAX * ((LV_COLOR_DEPTH >> 3) + 1)]; /*+1 because of the possible alpha byte*/ #endif lv_area_t line; lv_area_copy(&line, &mask_com); diff --git a/lv_draw/lv_draw_rect.c b/lv_draw/lv_draw_rect.c index 0d2e5cfa4..b1d341ad8 100644 --- a/lv_draw/lv_draw_rect.c +++ b/lv_draw/lv_draw_rect.c @@ -1089,9 +1089,9 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask lv_coord_t curve_x[radius + swidth + 1]; /*Stores the 'x' coordinates of a quarter circle.*/ #else # if LV_HOR_RES > LV_VER_RES - lv_coord_t curve_x[LV_HOR_RES]; + lv_coord_t curve_x[LV_HOR_RES_MAX]; # else - lv_coord_t curve_x[LV_VER_RES]; + lv_coord_t curve_x[LV_VER_RES_MAX]; # endif #endif memset(curve_x, 0, sizeof(curve_x)); @@ -1110,9 +1110,9 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask uint32_t line_1d_blur[filter_width]; #else # if LV_HOR_RES > LV_VER_RES - uint32_t line_1d_blur[LV_HOR_RES]; + uint32_t line_1d_blur[LV_HOR_RES_MAX]; # else - uint32_t line_1d_blur[LV_VER_RES]; + uint32_t line_1d_blur[LV_VER_RES_MAX]; # endif #endif /*1D Blur horizontally*/ @@ -1126,9 +1126,9 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask lv_opa_t line_2d_blur[radius + swidth + 1]; #else # if LV_HOR_RES > LV_VER_RES - lv_opa_t line_2d_blur[LV_HOR_RES]; + lv_opa_t line_2d_blur[LV_HOR_RES_MAX]; # else - lv_opa_t line_2d_blur[LV_VER_RES]; + lv_opa_t line_2d_blur[LV_VER_RES_MAX]; # endif #endif @@ -1247,9 +1247,9 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma lv_coord_t curve_x[radius + 1]; /*Stores the 'x' coordinates of a quarter circle.*/ #else # if LV_HOR_RES > LV_VER_RES - lv_coord_t curve_x[LV_HOR_RES]; + lv_coord_t curve_x[LV_HOR_RES_MAX]; # else - lv_coord_t curve_x[LV_VER_RES]; + lv_coord_t curve_x[LV_VER_RES_MAX]; # endif #endif lv_point_t circ; @@ -1266,9 +1266,9 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma lv_opa_t line_1d_blur[swidth]; #else # if LV_HOR_RES > LV_VER_RES - lv_opa_t line_1d_blur[LV_HOR_RES]; + lv_opa_t line_1d_blur[LV_HOR_RES_MAX]; # else - lv_opa_t line_1d_blur[LV_VER_RES]; + lv_opa_t line_1d_blur[LV_VER_RES_MAX]; # endif #endif From c34d5a4f6b3b49242d6c4e807874a61e6705de5f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 22 Feb 2019 14:22:11 +0100 Subject: [PATCH 15/17] init disp resolution --- README.md | 2 ++ lv_porting/lv_port_disp_templ.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index b98d36152..980785eb4 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,8 @@ v_disp_buf_init(&disp_buf1, buf, NULL, LV_HOR_RES_MAX * 10); /*Initialize the ```c lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ lv_disp_drv_init(&disp_drv); /*Basic initialization*/ +disp_drv.hor_res = 480; /*Set the horizontal resolution*/ +disp_drv.ver_res = 320; /*Set the vertical resolution*/ disp_drv.flush_cb = my_disp_flush; /*Set your driver function*/ disp_drv.buffer = &disp_buf; /*Assign the buffer to teh display*/ lv_disp_drv_register(&disp_drv); /*Finally register the driver*/ diff --git a/lv_porting/lv_port_disp_templ.c b/lv_porting/lv_port_disp_templ.c index bcd251a8a..39f928d23 100644 --- a/lv_porting/lv_port_disp_templ.c +++ b/lv_porting/lv_port_disp_templ.c @@ -93,6 +93,10 @@ void lv_port_disp_init(void) /*Set up the functions to access to your display*/ + /*Set the resolution of the display*/ + disp_drv.hor_res = 480; + disp_drv.ver_res = 320; + /*Used to copy the buffer's content to the display*/ disp_drv.flush_cb = disp_flush; From 054e43e6e9bdfbf0f15193c494844fa11e8f6cd9 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 24 Feb 2019 21:20:51 +0100 Subject: [PATCH 16/17] indev/disp cb: pass driver as first argument --- lv_core/lv_refr.c | 8 ++++---- lv_draw/lv_draw_basic.c | 12 ++++++------ lv_hal/lv_hal_disp.c | 7 ++++--- lv_hal/lv_hal_disp.h | 16 +++++++++------- lv_hal/lv_hal_indev.c | 2 +- lv_hal/lv_hal_indev.h | 13 +++++++------ 6 files changed, 31 insertions(+), 27 deletions(-) diff --git a/lv_core/lv_refr.c b/lv_core/lv_refr.c index d17d83917..7ac2c6c14 100644 --- a/lv_core/lv_refr.c +++ b/lv_core/lv_refr.c @@ -101,7 +101,7 @@ void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p) /*The area is truncated to the screen*/ if(suc != false) { - if(disp->driver.rounder_cb) disp->driver.rounder_cb(disp_refr, &com_area); + if(disp->driver.rounder_cb) disp->driver.rounder_cb(&disp_refr->driver, &com_area); /*Save only if this area is not in one of the saved areas*/ uint16_t i; @@ -192,7 +192,7 @@ static void lv_refr_task(void * param) /*Call monitor cb if present*/ if(disp_refr->driver.monitor_cb) { - disp_refr->driver.monitor_cb(disp_refr, lv_tick_elaps(start), px_num); + disp_refr->driver.monitor_cb(&disp_refr->driver, lv_tick_elaps(start), px_num); } } } @@ -297,7 +297,7 @@ static void lv_refr_area(const lv_area_t * area_p) lv_coord_t y_tmp = max_row; do { tmp.y2 = y_tmp; - disp_refr->driver.rounder_cb(disp_refr, &tmp); + disp_refr->driver.rounder_cb(&disp_refr->driver, &tmp); y_tmp --; /*Decrement the number of line until it is rounded to a smaller (or equal) value then the original. */ } while(lv_area_get_height(&tmp) > max_row && y_tmp != 0); @@ -539,7 +539,7 @@ static void lv_refr_vdb_flush(void) /*Flush the rendered content to the display*/ lv_disp_t * disp = lv_refr_get_disp_refreshing(); - if(disp->driver.flush_cb) disp->driver.flush_cb(disp, &vdb->area, vdb->buf_act); + if(disp->driver.flush_cb) disp->driver.flush_cb(&disp->driver, &vdb->area, vdb->buf_act); if(vdb->buf1 && vdb->buf2) { diff --git a/lv_draw/lv_draw_basic.c b/lv_draw/lv_draw_basic.c index f675e54b5..31b8ba481 100644 --- a/lv_draw/lv_draw_basic.c +++ b/lv_draw/lv_draw_basic.c @@ -87,7 +87,7 @@ void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t y -= vdb->area.y1; if(disp->driver.set_px_cb) { - disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width, x, y, color, opa); + disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, x, y, color, opa); } else { lv_color_t * vdb_px_p = vdb->buf_act; vdb_px_p += y * vdb_width + x; @@ -336,7 +336,7 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, } if(disp->driver.set_px_cb) { - disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width, + disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, (col + pos_x) - vdb->area.x1, (row + pos_y) - vdb->area.y1, color, px_opa); } else { @@ -434,7 +434,7 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, for(row = masked_a.y1; row <= masked_a.y2; row++) { for(col = 0; col < map_useful_w; col++) { lv_color_t px_color = *((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]); - disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa); + disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa); } map_p += map_width * px_size_byte; /*Next row on the map*/ } @@ -497,7 +497,7 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, } /*Handle custom VDB write is present*/ if(disp->driver.set_px_cb) { - disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, recolored_px, opa_result); + disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, recolored_px, opa_result); } /*Normal native VDB write*/ else { @@ -507,7 +507,7 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, } else { /*Handle custom VDB write is present*/ if(disp->driver.set_px_cb) { - disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa_result); + disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa_result); } /*Normal native VDB write*/ else { @@ -571,7 +571,7 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_ if(disp->driver.set_px_cb) { for(col = fill_area->x1; col <= fill_area->x2; col++) { for(row = fill_area->y1; row <= fill_area->y2; row++) { - disp->driver.set_px_cb(disp, (uint8_t *)mem, mem_width, col, row, color, opa); + disp->driver.set_px_cb(&disp->driver, (uint8_t *)mem, mem_width, col, row, color, opa); } } } else { diff --git a/lv_hal/lv_hal_disp.c b/lv_hal/lv_hal_disp.c index 82e597fb3..339f2853e 100644 --- a/lv_hal/lv_hal_disp.c +++ b/lv_hal/lv_hal_disp.c @@ -180,11 +180,12 @@ lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp) } /** - * Call in the display driver's `flush` function when the flushing is finished + * Call in the display driver's `flush_cb` function when the flushing is finished + * @param disp_drv pointer to display driver in `flush_cb` where this function is called */ -LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_t * disp) +LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_drv_t * disp_drv) { - disp->driver.buffer->flushing = 0; + disp_drv->buffer->flushing = 0; /*If the screen is transparent initialize it when the flushing is ready*/ #if LV_COLOR_SCREEN_TRANSP diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index 0f83d82a2..0fed2c454 100644 --- a/lv_hal/lv_hal_disp.h +++ b/lv_hal/lv_hal_disp.h @@ -38,6 +38,7 @@ extern "C" { **********************/ struct _disp_t; +struct _disp_drv_t; typedef struct @@ -67,22 +68,22 @@ typedef struct _disp_drv_t { lv_disp_buf_t * buffer; /* MANDATORY: Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished */ - void (*flush_cb)(struct _disp_t * disp, const lv_area_t * area, lv_color_t * color_p); + void (*flush_cb)(struct _disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p); lv_disp_user_data_t flush_user_data; /* OPTIONAL: Extend the invalidated areas to match with the display drivers requirements * E.g. round `y` to, 8, 16 ..) on a monochrome display*/ - void (*rounder_cb)(struct _disp_t * disp, lv_area_t * area); + void (*rounder_cb)(struct _disp_drv_t * disp_drv, lv_area_t * area); lv_disp_user_data_t rounder_user_data; /* OPTIONAL: Set a pixel in a buffer according to the special requirements of the display * Can be used for color format not supported in LittelvGL. E.g. 2 bit -> 4 gray scales * Note: Much slower then drawing with supported color formats. */ - void (*set_px_cb)(struct _disp_t * disp, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa); + void (*set_px_cb)(struct _disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa); lv_disp_user_data_t set_px_user_data; - /* Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */ - void (*monitor_cb)(struct _disp_t * disp, uint32_t time, uint32_t px); + /* OPTIONAL: Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */ + void (*monitor_cb)(struct _disp_drv_t * disp_drv, uint32_t time, uint32_t px); lv_disp_user_data_t monitor_user_data; #if USE_LV_GPU @@ -178,9 +179,10 @@ lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp); lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp); /** - * Call in the display driver's `flush` function when the flushing is finished + * Call in the display driver's `flush_cb` function when the flushing is finished + * @param disp_drv pointer to display driver in `flush_cb` where this function is called */ -LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_t * disp); +LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_drv_t * disp_drv); /** diff --git a/lv_hal/lv_hal_indev.c b/lv_hal/lv_hal_indev.c index 2604bc08c..7ee8530e3 100644 --- a/lv_hal/lv_hal_indev.c +++ b/lv_hal/lv_hal_indev.c @@ -113,7 +113,7 @@ bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data) if(indev->driver.read_cb) { LV_LOG_TRACE("idnev read started"); - cont = indev->driver.read_cb(indev, data); + cont = indev->driver.read_cb(&indev->driver, data); LV_LOG_TRACE("idnev read finished"); } else { LV_LOG_WARN("indev function registered"); diff --git a/lv_hal/lv_hal_indev.h b/lv_hal/lv_hal_indev.h index a9208d997..ed488ba96 100644 --- a/lv_hal/lv_hal_indev.h +++ b/lv_hal/lv_hal_indev.h @@ -33,8 +33,10 @@ extern "C" { * TYPEDEFS **********************/ +struct _lv_obj_t; struct _disp_t; struct _lv_indev_t; +struct _lv_indev_drv_t; /*Possible input device types*/ enum { @@ -67,14 +69,13 @@ typedef struct { } lv_indev_data_t; /*Initialized by the user and registered by 'lv_indev_add()'*/ -typedef struct { - lv_hal_indev_type_t type; /*Input device type*/ - bool (*read_cb)(struct _lv_indev_t * indev, lv_indev_data_t *data); /*Function pointer to read_cb data. Return 'true' if there is still data to be read_cb (buffered)*/ - lv_indev_user_data_t read_user_data; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/ - struct _disp_t * disp; +typedef struct _lv_indev_drv_t { + lv_hal_indev_type_t type; /*Input device type*/ + bool (*read_cb)(struct _lv_indev_drv_t * indev_drv, lv_indev_data_t *data); /*Function pointer to read_cb data. Return 'true' if there is still data to be read_cb (buffered)*/ + lv_indev_user_data_t read_user_data; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/ + struct _disp_t * disp; /*Pointer to the assigned display*/ } lv_indev_drv_t; -struct _lv_obj_t; /*Run time data of input devices*/ typedef struct _lv_indev_proc_t { From 54778eb3037fc767e56d1eb99f5204b2d5f5455f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 25 Feb 2019 06:50:20 +0100 Subject: [PATCH 17/17] update lv_conf files --- lv_conf_checker.h | 191 +++++++++++++++--------------------------- lv_conf_templ.h | 105 +++++++++++------------ lv_core/lv_disp.h | 40 +++++++++ lv_core/lv_indev.c | 11 +-- lv_hal/lv_hal_disp.h | 8 +- lv_hal/lv_hal_indev.h | 2 +- 6 files changed, 165 insertions(+), 192 deletions(-) diff --git a/lv_conf_checker.h b/lv_conf_checker.h index fa8748d8f..a04afe745 100644 --- a/lv_conf_checker.h +++ b/lv_conf_checker.h @@ -6,6 +6,50 @@ #ifndef LV_CONF_CHECKER_H #define LV_CONF_CHECKER_H + +/*=================== + Graphical settings + *===================*/ + +/* Horizontal and vertical resolution of the library.*/ +#ifndef LV_HOR_RES_MAX +#define LV_HOR_RES_MAX (480) +#endif +#ifndef LV_VER_RES_MAX +#define LV_VER_RES_MAX (320) +#endif + +/*Color settings*/ +#ifndef LV_COLOR_DEPTH +#define LV_COLOR_DEPTH 16 /*Color depth: 1/8/16/32*/ +#endif +#ifndef LV_COLOR_16_SWAP +#define LV_COLOR_16_SWAP 0 /*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/ +#endif +#ifndef LV_COLOR_SCREEN_TRANSP +#define LV_COLOR_SCREEN_TRANSP 0 /*1: Enable screen transparency. Useful for OSD or other overlapping GUIs. Requires ARGB8888 colors*/ +#endif +#ifndef LV_COLOR_TRANSP +#define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (with chroma keying)*/ +#endif + +/* Enable anti-aliasing (lines, and radiuses will be smoothed) */ +#ifndef LV_ANTIALIAS +#define LV_ANTIALIAS 1 /*1: Enable anti-aliasing*/ +#endif + + +/*Screen refresh period in milliseconds. LittlevGL will redraw the screen with this period*/ +#ifndef LV_REFR_PERIOD +#define LV_REFR_PERIOD 30 /*[ms]*/ +#endif + +/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide + * (Not so important, you can adjust it to modify default sizes and spaces)*/ +#ifndef LV_DPI +#define LV_DPI 100 /*[px]*/ +#endif + /*=================== Dynamic memory *===================*/ @@ -17,7 +61,7 @@ #endif #if LV_MEM_CUSTOM == 0 #ifndef LV_MEM_SIZE -# define LV_MEM_SIZE (64U * 1024U) /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/ +# define LV_MEM_SIZE (16U * 1024U) /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/ #endif #ifndef LV_MEM_ATTR # define LV_MEM_ATTR /*Complier prefix for big array declaration*/ @@ -57,96 +101,13 @@ #endif #endif /* LV_ENABLE_GC */ -/*=================== - Graphical settings - *===================*/ - -/* Horizontal and vertical resolution of the library.*/ -#ifndef LV_HOR_RES -//#define LV_HOR_RES (480) -#endif -#ifndef LV_VER_RES -//#define LV_VER_RES (320) -#endif - -/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide - * (Not so important, you can adjust it to modify default sizes and spaces)*/ -#ifndef LV_DPI -#define LV_DPI 100 -#endif - -/* Enable anti-aliasing (lines, and radiuses will be smoothed) */ -#ifndef LV_ANTIALIAS -#define LV_ANTIALIAS 1 /*1: Enable anti-aliasing*/ -#endif - -/*Screen refresh period in milliseconds*/ -#ifndef LV_REFR_PERIOD -#define LV_REFR_PERIOD 30 -#endif - -/*----------------- - * VDB settings - *----------------*/ - -/* VDB (Virtual Display Buffer) is an internal graphics buffer. - * The GUI will be drawn into this buffer first and then - * the buffer will be passed to your `disp_drv.disp_flush` function to - * copy it to your frame buffer. - * VDB is required for: buffered drawing, opacity, anti-aliasing and shadows - * Learn more: https://docs.littlevgl.com/#Drawing*/ - -/* Size of the VDB in pixels. Typical size: ~1/10 screen. Must be >= LV_HOR_RES - * Setting it to 0 will disable VDB and `disp_drv.disp_fill` and `disp_drv.disp_map` functions - * will be called to draw to the frame buffer directly*/ -#ifndef LV_VDB_SIZE -//#define LV_VDB_SIZE ((LV_VER_RES * LV_HOR_RES) / 10) -#endif - - /* Bit-per-pixel of VDB. Useful for monochrome or non-standard color format displays. - * Special formats are handled with `disp_drv.vdb_wr`)*/ -#ifndef LV_VDB_PX_BPP -#define LV_VDB_PX_BPP LV_COLOR_SIZE /*LV_COLOR_SIZE comes from LV_COLOR_DEPTH below to set 8, 16 or 32 bit pixel size automatically */ -#endif - - /* Place VDB to a specific address (e.g. in external RAM) - * 0: allocate automatically into RAM - * LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/ -#ifndef LV_VDB_ADR -//#define LV_VDB_ADR 0 -#endif - -/* Use two Virtual Display buffers (VDB) to parallelize rendering and flushing - * The flushing should use DMA to write the frame buffer in the background */ -#ifndef LV_VDB_DOUBLE -#define LV_VDB_DOUBLE 0 -#endif - -/* Place VDB2 to a specific address (e.g. in external RAM) - * 0: allocate automatically into RAM - * LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/ -#ifndef LV_VDB2_ADR -#define LV_VDB2_ADR 0 -#endif - -/* Using true double buffering in `disp_drv.disp_flush` you will always get the image of the whole screen. - * Your only task is to set the rendered image (`color_p` parameter) as frame buffer address or send it to your display. - * The best if you do in the blank period of you display to avoid tearing effect. - * Requires: - * - LV_VDB_SIZE = LV_HOR_RES * LV_VER_RES - * - LV_VDB_DOUBLE = 1 - */ -#ifndef LV_VDB_TRUE_DOUBLE_BUFFERED -#define LV_VDB_TRUE_DOUBLE_BUFFERED 0 -#endif - /*================= Misc. setting *=================*/ /*Input device settings*/ #ifndef LV_INDEV_READ_PERIOD -#define LV_INDEV_READ_PERIOD 50 /*Input device read period in milliseconds*/ +#define LV_INDEV_READ_PERIOD 30 /*Input device read period in milliseconds*/ #endif #ifndef LV_INDEV_POINT_MARKER #define LV_INDEV_POINT_MARKER 0 /*Mark the pressed points (required: USE_LV_REAL_DRAW = 1)*/ @@ -164,20 +125,6 @@ #define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */ #endif -/*Color settings*/ -#ifndef LV_COLOR_DEPTH -#define LV_COLOR_DEPTH 16 /*Color depth: 1/8/16/32*/ -#endif -#ifndef LV_COLOR_16_SWAP -#define LV_COLOR_16_SWAP 0 /*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/ -#endif -#ifndef LV_COLOR_SCREEN_TRANSP -#define LV_COLOR_SCREEN_TRANSP 0 /*1: Enable screen transparency. Useful for OSD or other overlapping GUIs. Requires ARGB8888 colors*/ -#endif -#ifndef LV_COLOR_TRANSP -#define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (with chroma keying)*/ -#endif - /*Text settings*/ #ifndef LV_TXT_UTF8 #define LV_TXT_UTF8 1 /*Enable UTF-8 coded Unicode character usage */ @@ -208,14 +155,11 @@ #ifndef USE_LV_GPU #define USE_LV_GPU 1 /*1: Enable GPU interface*/ #endif -#ifndef USE_LV_REAL_DRAW -#define USE_LV_REAL_DRAW 1 /*1: Enable function which draw directly to the frame buffer instead of VDB (required if LV_VDB_SIZE = 0)*/ -#endif #ifndef USE_LV_FILESYSTEM #define USE_LV_FILESYSTEM 1 /*1: Enable file system (might be required for images*/ #endif -#ifndef USE_LV_MULTI_LANG -#define USE_LV_MULTI_LANG 0 /* Number of languages for labels to store (0: to disable this feature)*/ +#ifndef USE_LV_I18N +#define USE_LV_I18N 1 /*1: Enable InternationalizatioN (multi-language) support*/ #endif /*Compiler settings*/ @@ -225,9 +169,6 @@ #ifndef LV_ATTRIBUTE_TASK_HANDLER #define LV_ATTRIBUTE_TASK_HANDLER /* Define a custom attribute to `lv_task_handler` function */ #endif -#ifndef LV_ATTRIBUTE_MEM_ALIGN -#define LV_ATTRIBUTE_MEM_ALIGN /* With size optimization (-Os) the compiler might not align data to 4 or 8 byte boundary. This alignment will be explicitly applied where needed.*/ -#endif #ifndef LV_COMPILER_VLA_SUPPORTED #define LV_COMPILER_VLA_SUPPORTED 1 /* 1: Variable length array is supported*/ #endif @@ -241,13 +182,15 @@ #endif #if LV_TICK_CUSTOM == 1 #ifndef LV_TICK_CUSTOM_INCLUDE -#define LV_TICK_CUSTOM_INCLUDE "sonething.h" /*Header for the sys time function*/ +#define LV_TICK_CUSTOM_INCLUDE "something.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*/ #endif -#endif /*LV_TICK_CUSTOM*/ +#endif /*LV_TICK_CUSTOM*/ +typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/ +typedef void * lv_indev_drv_user_data_t; /*Type of user data in the display driver*/ /*Log settings*/ #ifndef USE_LV_LOG @@ -257,14 +200,14 @@ /* 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 caused problem + * 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 */ #ifndef LV_LOG_LEVEL # define LV_LOG_LEVEL LV_LOG_LEVEL_WARN #endif -/* 1: Print the log with 'printf'; 0: user need to register a callback*/ +/* 1: Print the log with 'printf'; 0: user need to register a callback*/ #ifndef LV_LOG_PRINTF # define LV_LOG_PRINTF 0 #endif @@ -274,7 +217,7 @@ * THEME USAGE *================*/ #ifndef LV_THEME_LIVE_UPDATE -#define LV_THEME_LIVE_UPDATE 1 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/ +#define LV_THEME_LIVE_UPDATE 0 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/ #endif #ifndef USE_LV_THEME_TEMPL @@ -310,16 +253,16 @@ * To enable a built-in font use 1,2,4 or 8 values * which will determine the bit-per-pixel. Higher value means smoother fonts */ #ifndef USE_LV_FONT_DEJAVU_10 -#define USE_LV_FONT_DEJAVU_10 4 +#define USE_LV_FONT_DEJAVU_10 0 #endif #ifndef USE_LV_FONT_DEJAVU_10_LATIN_SUP -#define USE_LV_FONT_DEJAVU_10_LATIN_SUP 4 +#define USE_LV_FONT_DEJAVU_10_LATIN_SUP 0 #endif #ifndef USE_LV_FONT_DEJAVU_10_CYRILLIC -#define USE_LV_FONT_DEJAVU_10_CYRILLIC 4 +#define USE_LV_FONT_DEJAVU_10_CYRILLIC 0 #endif #ifndef USE_LV_FONT_SYMBOL_10 -#define USE_LV_FONT_SYMBOL_10 4 +#define USE_LV_FONT_SYMBOL_10 0 #endif #ifndef USE_LV_FONT_DEJAVU_20 @@ -336,29 +279,29 @@ #endif #ifndef USE_LV_FONT_DEJAVU_30 -#define USE_LV_FONT_DEJAVU_30 4 +#define USE_LV_FONT_DEJAVU_30 0 #endif #ifndef USE_LV_FONT_DEJAVU_30_LATIN_SUP -#define USE_LV_FONT_DEJAVU_30_LATIN_SUP 4 +#define USE_LV_FONT_DEJAVU_30_LATIN_SUP 0 #endif #ifndef USE_LV_FONT_DEJAVU_30_CYRILLIC -#define USE_LV_FONT_DEJAVU_30_CYRILLIC 4 +#define USE_LV_FONT_DEJAVU_30_CYRILLIC 0 #endif #ifndef USE_LV_FONT_SYMBOL_30 -#define USE_LV_FONT_SYMBOL_30 4 +#define USE_LV_FONT_SYMBOL_30 0 #endif #ifndef USE_LV_FONT_DEJAVU_40 -#define USE_LV_FONT_DEJAVU_40 4 +#define USE_LV_FONT_DEJAVU_40 0 #endif #ifndef USE_LV_FONT_DEJAVU_40_LATIN_SUP -#define USE_LV_FONT_DEJAVU_40_LATIN_SUP 4 +#define USE_LV_FONT_DEJAVU_40_LATIN_SUP 0 #endif #ifndef USE_LV_FONT_DEJAVU_40_CYRILLIC -#define USE_LV_FONT_DEJAVU_40_CYRILLIC 4 +#define USE_LV_FONT_DEJAVU_40_CYRILLIC 0 #endif #ifndef USE_LV_FONT_SYMBOL_40 -#define USE_LV_FONT_SYMBOL_40 4 +#define USE_LV_FONT_SYMBOL_40 0 #endif #ifndef USE_LV_FONT_MONOSPACE_8 diff --git a/lv_conf_templ.h b/lv_conf_templ.h index 790648067..80c7bc397 100644 --- a/lv_conf_templ.h +++ b/lv_conf_templ.h @@ -9,8 +9,35 @@ #if 0 /*Set it to "1" to enable content*/ + #ifndef LV_CONF_H #define LV_CONF_H + +/*=================== + Graphical settings + *===================*/ + +/* Horizontal and vertical resolution of the library.*/ +#define LV_HOR_RES_MAX (480) +#define LV_VER_RES_MAX (320) + +/*Color settings*/ +#define LV_COLOR_DEPTH 16 /*Color depth: 1/8/16/32*/ +#define LV_COLOR_16_SWAP 0 /*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/ +#define LV_COLOR_SCREEN_TRANSP 0 /*1: Enable screen transparency. Useful for OSD or other overlapping GUIs. Requires ARGB8888 colors*/ +#define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (with chroma keying)*/ + +/* Enable anti-aliasing (lines, and radiuses will be smoothed) */ +#define LV_ANTIALIAS 1 /*1: Enable anti-aliasing*/ + + +/*Screen refresh period in milliseconds. LittlevGL will redraw the screen with this period*/ +#define LV_REFR_PERIOD 30 /*[ms]*/ + +/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide + * (Not so important, you can adjust it to modify default sizes and spaces)*/ +#define LV_DPI 100 /*[px]*/ + /*=================== Dynamic memory *===================*/ @@ -19,7 +46,7 @@ * to store the graphical objects and other data */ #define LV_MEM_CUSTOM 0 /*1: use custom malloc/free, 0: use the built-in lv_mem_alloc/lv_mem_free*/ #if LV_MEM_CUSTOM == 0 -# define LV_MEM_SIZE (64U * 1024U) /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/ +# define LV_MEM_SIZE (16U * 1024U) /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/ # define LV_MEM_ATTR /*Complier prefix for big array declaration*/ # define LV_MEM_ADR 0 /*Set an address for memory pool instead of allocation it as an array. Can be in external SRAM too.*/ # define LV_MEM_AUTO_DEFRAG 1 /*Automatically defrag on free*/ @@ -38,42 +65,18 @@ # define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ #endif /* LV_ENABLE_GC */ -/*=================== - Graphical settings - *===================*/ - -/* Horizontal and vertical resolution of the library.*/ -#define LV_HOR_RES_MAX (480) -#define LV_VER_RES_MAX (320) - -/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide - * (Not so important, you can adjust it to modify default sizes and spaces)*/ -#define LV_DPI 100 - -/* Enable anti-aliasing (lines, and radiuses will be smoothed) */ -#define LV_ANTIALIAS 1 /*1: Enable anti-aliasing*/ - -/*Screen refresh period in milliseconds*/ -#define LV_REFR_PERIOD 30 - /*================= Misc. setting *=================*/ /*Input device settings*/ -#define LV_INDEV_READ_PERIOD 50 /*Input device read period in milliseconds*/ +#define LV_INDEV_READ_PERIOD 30 /*Input device read period in milliseconds*/ #define LV_INDEV_POINT_MARKER 0 /*Mark the pressed points (required: USE_LV_REAL_DRAW = 1)*/ #define LV_INDEV_DRAG_LIMIT 10 /*Drag threshold in pixels */ -#define LV_INDEV_DRAG_THROW 20 /*Drag throw slow-down in [%] (must be > 0). Greater value means faster slow-down */ +#define LV_INDEV_DRAG_THROW 20 /*Drag throw slow-down in [%]. Greater value means faster slow-down */ #define LV_INDEV_LONG_PRESS_TIME 400 /*Long press time in milliseconds*/ #define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */ -/*Color settings*/ -#define LV_COLOR_DEPTH 16 /*Color depth: 1/8/16/32*/ -#define LV_COLOR_16_SWAP 0 /*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/ -#define LV_COLOR_SCREEN_TRANSP 0 /*1: Enable screen transparency. Useful for OSD or other overlapping GUIs. Requires ARGB8888 colors*/ -#define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (with chroma keying)*/ - /*Text settings*/ #define LV_TXT_UTF8 1 /*Enable UTF-8 coded Unicode character usage */ #define LV_TXT_BREAK_CHARS " ,.;:-_" /*Can break texts on these chars*/ @@ -86,24 +89,24 @@ #define USE_LV_SHADOW 1 /*1: Enable shadows*/ #define USE_LV_GROUP 1 /*1: Enable object groups (for keyboards)*/ #define USE_LV_GPU 1 /*1: Enable GPU interface*/ -#define USE_LV_REAL_DRAW 1 /*1: Enable function which draw directly to the frame buffer instead of VDB (required if LV_VDB_SIZE = 0)*/ #define USE_LV_FILESYSTEM 1 /*1: Enable file system (might be required for images*/ -#define USE_LV_MULTI_LANG 0 /* Number of languages for labels to store (0: to disable this feature)*/ +#define USE_LV_I18N 1 /*1: Enable InternationalizatioN (multi-language) support*/ /*Compiler settings*/ #define LV_ATTRIBUTE_TICK_INC /* Define a custom attribute to `lv_tick_inc` function */ #define LV_ATTRIBUTE_TASK_HANDLER /* Define a custom attribute to `lv_task_handler` function */ -#define LV_ATTRIBUTE_MEM_ALIGN /* With size optimization (-Os) the compiler might not align data to 4 or 8 byte boundary. This alignment will be explicitly applied where needed.*/ #define LV_COMPILER_VLA_SUPPORTED 1 /* 1: Variable length array is supported*/ #define LV_COMPILER_NON_CONST_INIT_SUPPORTED 1 /* 1: Initialization with non constant values are supported */ /*HAL settings*/ #define LV_TICK_CUSTOM 0 /*1: use a custom tick source (removing the need to manually update the tick with `lv_tick_inc`) */ #if LV_TICK_CUSTOM == 1 -#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/ +#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*/ -#endif /*LV_TICK_CUSTOM*/ +#endif /*LV_TICK_CUSTOM*/ +typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/ +typedef void * lv_indev_drv_user_data_t; /*Type of user data in the display driver*/ /*Log settings*/ #define USE_LV_LOG 1 /*Enable/disable the log module*/ @@ -111,19 +114,19 @@ /* 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 caused problem + * 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 */ # define LV_LOG_LEVEL LV_LOG_LEVEL_WARN -/* 1: Print the log with 'printf'; 0: user need to register a callback*/ +/* 1: Print the log with 'printf'; 0: user need to register a callback*/ # define LV_LOG_PRINTF 0 #endif /*USE_LV_LOG*/ /*================ * THEME USAGE *================*/ -#define LV_THEME_LIVE_UPDATE 1 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/ +#define LV_THEME_LIVE_UPDATE 0 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/ #define USE_LV_THEME_TEMPL 0 /*Just for test*/ #define USE_LV_THEME_DEFAULT 1 /*Built mainly from the built-in styles. Consumes very few RAM*/ @@ -141,25 +144,25 @@ /* More info about fonts: https://docs.littlevgl.com/#Fonts * To enable a built-in font use 1,2,4 or 8 values * which will determine the bit-per-pixel. Higher value means smoother fonts */ -#define USE_LV_FONT_DEJAVU_10 4 -#define USE_LV_FONT_DEJAVU_10_LATIN_SUP 4 -#define USE_LV_FONT_DEJAVU_10_CYRILLIC 4 -#define USE_LV_FONT_SYMBOL_10 4 +#define USE_LV_FONT_DEJAVU_10 0 +#define USE_LV_FONT_DEJAVU_10_LATIN_SUP 0 +#define USE_LV_FONT_DEJAVU_10_CYRILLIC 0 +#define USE_LV_FONT_SYMBOL_10 0 #define USE_LV_FONT_DEJAVU_20 4 #define USE_LV_FONT_DEJAVU_20_LATIN_SUP 4 #define USE_LV_FONT_DEJAVU_20_CYRILLIC 4 #define USE_LV_FONT_SYMBOL_20 4 -#define USE_LV_FONT_DEJAVU_30 4 -#define USE_LV_FONT_DEJAVU_30_LATIN_SUP 4 -#define USE_LV_FONT_DEJAVU_30_CYRILLIC 4 -#define USE_LV_FONT_SYMBOL_30 4 +#define USE_LV_FONT_DEJAVU_30 0 +#define USE_LV_FONT_DEJAVU_30_LATIN_SUP 0 +#define USE_LV_FONT_DEJAVU_30_CYRILLIC 0 +#define USE_LV_FONT_SYMBOL_30 0 -#define USE_LV_FONT_DEJAVU_40 4 -#define USE_LV_FONT_DEJAVU_40_LATIN_SUP 4 -#define USE_LV_FONT_DEJAVU_40_CYRILLIC 4 -#define USE_LV_FONT_SYMBOL_40 4 +#define USE_LV_FONT_DEJAVU_40 0 +#define USE_LV_FONT_DEJAVU_40_LATIN_SUP 0 +#define USE_LV_FONT_DEJAVU_40_CYRILLIC 0 +#define USE_LV_FONT_SYMBOL_40 0 #define USE_LV_FONT_MONOSPACE_8 1 @@ -339,13 +342,6 @@ /************************* * Non-user section *************************/ - -#if LV_INDEV_DRAG_THROW <= 0 -#warning "LV_INDEV_DRAG_THROW must be greater than 0" -#undef LV_INDEV_DRAG_THROW -#define LV_INDEV_DRAG_THROW 1 -#endif - #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/ # define _CRT_SECURE_NO_WARNINGS #endif @@ -357,4 +353,5 @@ #endif /*LV_CONF_H*/ + #endif /*End of "Content enable"*/ diff --git a/lv_core/lv_disp.h b/lv_core/lv_disp.h index def7bceed..e304fc43e 100644 --- a/lv_core/lv_disp.h +++ b/lv_core/lv_disp.h @@ -62,10 +62,50 @@ lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp); */ void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr); +/*------------------------------------------------ + * To improve backward compatibility + * Recommended only if you have one display + *------------------------------------------------*/ + +/** + * Get the active screen of the default display + * @return pointer to the active screen + */ +static inline lv_obj_t * lv_scr_act(void) +{ + return lv_disp_get_scr_act(lv_disp_get_default()); + +} + +/** + * Get the top layer of the default display + * @return pointer to the top layer + */ +static inline lv_obj_t * lv_top_layer(void) +{ + return lv_disp_get_layer_top(lv_disp_get_default()); +} + +/** + * Get the active screen of the deafult display + * @return pointer to the sys layer + */ +static inline lv_obj_t * lv_sys_layer(void) +{ + return lv_disp_get_layer_sys(lv_disp_get_default()); +} + /********************** * MACROS **********************/ +/*------------------------------------------------ + * To improve backward compatibility + * Recommended only if you have one display + *------------------------------------------------*/ + +#define LV_HOR_RES (lv_disp_get_hor_res(lv_disp_get_default());) +#define LV_VER_RES (lv_disp_get_ver_res(lv_disp_get_default());) #ifdef __cplusplus } /* extern "C" */ diff --git a/lv_core/lv_indev.c b/lv_core/lv_indev.c index 989277c64..15ddf39ad 100644 --- a/lv_core/lv_indev.c +++ b/lv_core/lv_indev.c @@ -550,15 +550,8 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data) /*Still the same point is pressed*/ if(i->proc.last_point.x == i->proc.act_point.x && i->proc.last_point.y == i->proc.act_point.y && - data->state == LV_INDEV_STATE_PR) { -#if LV_INDEV_POINT_MARKER != 0 - lv_area_t area; - area.x1 = i->proc.act_point.x - (LV_INDEV_POINT_MARKER >> 1); - area.y1 = i->proc.act_point.y - (LV_INDEV_POINT_MARKER >> 1); - area.x2 = i->proc.act_point.x + ((LV_INDEV_POINT_MARKER >> 1) | 0x1); - area.y2 = i->proc.act_point.y + ((LV_INDEV_POINT_MARKER >> 1) | 0x1); - lv_rfill(&area, NULL, LV_COLOR_MAKE(0xFF, 0, 0), LV_OPA_COVER); -#endif + data->state == LV_INDEV_STATE_PR) + { indev_proc_press(&i->proc); } else { /*If a new point comes always make a release*/ diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index 0fed2c454..4b820e49c 100644 --- a/lv_hal/lv_hal_disp.h +++ b/lv_hal/lv_hal_disp.h @@ -69,22 +69,22 @@ typedef struct _disp_drv_t { /* MANDATORY: Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished */ void (*flush_cb)(struct _disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p); - lv_disp_user_data_t flush_user_data; + lv_disp_drv_user_data_t flush_user_data; /* OPTIONAL: Extend the invalidated areas to match with the display drivers requirements * E.g. round `y` to, 8, 16 ..) on a monochrome display*/ void (*rounder_cb)(struct _disp_drv_t * disp_drv, lv_area_t * area); - lv_disp_user_data_t rounder_user_data; + lv_disp_drv_user_data_t rounder_user_data; /* OPTIONAL: Set a pixel in a buffer according to the special requirements of the display * Can be used for color format not supported in LittelvGL. E.g. 2 bit -> 4 gray scales * Note: Much slower then drawing with supported color formats. */ void (*set_px_cb)(struct _disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa); - lv_disp_user_data_t set_px_user_data; + lv_disp_drv_user_data_t set_px_user_data; /* OPTIONAL: Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */ void (*monitor_cb)(struct _disp_drv_t * disp_drv, uint32_t time, uint32_t px); - lv_disp_user_data_t monitor_user_data; + lv_disp_drv_user_data_t monitor_user_data; #if USE_LV_GPU /*OPTIONAL: Blend two memories using opacity (GPU only)*/ diff --git a/lv_hal/lv_hal_indev.h b/lv_hal/lv_hal_indev.h index ed488ba96..7fb638706 100644 --- a/lv_hal/lv_hal_indev.h +++ b/lv_hal/lv_hal_indev.h @@ -72,7 +72,7 @@ typedef struct { typedef struct _lv_indev_drv_t { lv_hal_indev_type_t type; /*Input device type*/ bool (*read_cb)(struct _lv_indev_drv_t * indev_drv, lv_indev_data_t *data); /*Function pointer to read_cb data. Return 'true' if there is still data to be read_cb (buffered)*/ - lv_indev_user_data_t read_user_data; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/ + lv_indev_drv_user_data_t read_user_data; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/ struct _disp_t * disp; /*Pointer to the assigned display*/ } lv_indev_drv_t;