diff --git a/README.md b/README.md index 48a7a6a25..aa82ed46e 100644 --- a/README.md +++ b/README.md @@ -72,24 +72,33 @@ 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.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*/ -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*/ } ``` @@ -97,10 +106,10 @@ void disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t ```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; @@ -116,9 +125,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 diff --git a/lv_conf_checker.h b/lv_conf_checker.h index 8751c74e9..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 a4712fea6..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,85 +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 (480) -#define LV_VER_RES (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 - -/*----------------- - * 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 *=================*/ /*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*/ @@ -129,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*/ @@ -154,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*/ @@ -184,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 @@ -382,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 @@ -400,4 +353,5 @@ #endif /*LV_CONF_H*/ + #endif /*End of "Content enable"*/ 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 new file mode 100644 index 000000000..dc4578d17 --- /dev/null +++ b/lv_core/lv_disp.c @@ -0,0 +1,117 @@ +/** + * @file lv_disp.c + * + */ + +/********************* + * INCLUDES + *********************/ +#include "lv_disp.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ + +/********************** + * STATIC VARIABLES + **********************/ + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +/** + * 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) +{ + 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; +} + +/** + * Make a screen active + * @param scr pointer to a screen + */ +void lv_disp_set_scr_act(lv_obj_t * scr) +{ + lv_disp_t * d = lv_obj_get_disp(scr); + + 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) +{ + 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); +} + +/********************** + * STATIC FUNCTIONS + **********************/ diff --git a/lv_core/lv_disp.h b/lv_core/lv_disp.h new file mode 100644 index 000000000..e304fc43e --- /dev/null +++ b/lv_core/lv_disp.h @@ -0,0 +1,114 @@ +/** + * @file lv_disp.h + * + */ + +#ifndef LV_DISP_H +#define LV_DISP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "../lv_hal/lv_hal.h" +#include "lv_obj.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * 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); + +/*------------------------------------------------ + * 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" */ +#endif + +#endif /*LV_TEMPL_H*/ diff --git a/lv_core/lv_indev.c b/lv_core/lv_indev.c index d3ae93f00..15ddf39ad 100644 --- a/lv_core/lv_indev.c +++ b/lv_core/lv_indev.c @@ -7,14 +7,14 @@ * 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" #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" -#include "lv_obj.h" /********************* * DEFINES @@ -125,6 +125,7 @@ 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) { @@ -143,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()); + 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); } @@ -248,6 +249,7 @@ 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); @@ -361,14 +363,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); @@ -550,21 +544,14 @@ 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 && 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*/ @@ -585,16 +572,20 @@ static void indev_proc_press(lv_indev_proc_t * proc) if(proc->wait_unil_release != 0) return; + lv_disp_t * disp = indev_act->driver.disp; + /*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_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_top()); - if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_scr_act()); + 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 { @@ -870,7 +861,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; @@ -896,8 +887,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_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_core/lv_obj.c b/lv_core/lv_obj.c index 914ef64de..45c5404cd 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -10,13 +10,14 @@ #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_draw/lv_draw_rbasic.h" #include "../lv_misc/lv_anim.h" #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" @@ -65,15 +66,10 @@ static bool _lv_initialized = false; void lv_init(void) { /* Do nothing if already initialized */ - if (_lv_initialized) - return; - - 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; + if (_lv_initialized) { + LV_LOG_WARN("lv_init: already inited"); + return; + } LV_LOG_TRACE("lv_init started"); @@ -101,20 +97,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*/ @@ -143,8 +128,13 @@ 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_default(); + if(!disp) { + LV_LOG_WARN("lv_obj_create: not display created to so far. No place to assign the new screen"); + return NULL; + } - 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; @@ -154,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*/ @@ -367,7 +357,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_obj_get_disp(obj); + lv_ll_rem(&d->scr_ll, obj); } else { lv_ll_rem(&(par->child_ll), obj); } @@ -425,9 +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); - if(obj_scr == lv_scr_act() || - obj_scr == lv_layer_top() || - obj_scr == lv_layer_sys()) { + 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,7 +441,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); } } @@ -458,21 +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_GC_ROOT(_lv_act_scr) = scr; - - lv_obj_invalidate(LV_GC_ROOT(_lv_act_scr)); -} - /*-------------------- * Parent/children set *--------------------*/ @@ -1022,13 +999,18 @@ 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); + } + d = lv_disp_get_next(d); } } @@ -1310,38 +1292,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(void) -{ - return LV_GC_ROOT(_lv_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) -{ - return LV_GC_ROOT(_lv_top_layer); -} - -/** - * 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 with the screen of an object * @param obj pointer to an object @@ -1360,6 +1310,30 @@ lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj) return (lv_obj_t *)act_p; } +/** + * 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) +{ + 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) { + if(s == scr) return d; + } + } + + LV_LOG_WARN("lv_scr_get_disp: screen not found") + return NULL; +} + /*--------------------- * Parent/children get *--------------------*/ diff --git a/lv_core/lv_obj.h b/lv_core/lv_obj.h index c5e6068a3..9df6506d6 100644 --- a/lv_core/lv_obj.h +++ b/lv_core/lv_obj.h @@ -27,13 +27,14 @@ 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 *********************/ /*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 @@ -41,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*/ @@ -274,16 +262,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 *--------------------*/ @@ -553,29 +531,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(void); - -/** - * 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); - /** * Return with the screen of an object * @param obj pointer to an object @@ -583,6 +538,13 @@ lv_obj_t * lv_layer_sys(void); */ lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj); +/** + * 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); + /*--------------------- * Parent/children get *--------------------*/ diff --git a/lv_core/lv_refr.c b/lv_core/lv_refr.c index d6987832a..7ac2c6c14 100644 --- a/lv_core/lv_refr.c +++ b/lv_core/lv_refr.c @@ -8,26 +8,20 @@ *********************/ #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" #include "../lv_misc/lv_task.h" #include "../lv_misc/lv_mem.h" +#include "../lv_misc/lv_gc.h" /********************* * 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 @@ -35,24 +29,18 @@ typedef struct { 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 **********************/ -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; +static lv_disp_t * disp_refr; /*Display being refreshed*/ /********************** * MACROS @@ -67,9 +55,6 @@ static uint32_t px_num; */ 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*/ @@ -88,22 +73,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_default(); + 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 - 1; - scr_area.y2 = LV_VER_RES - 1; + scr_area.x2 = disp->driver.hor_res - 1; + scr_area.y2 = disp->driver.ver_res - 1; lv_area_t com_area; bool suc; @@ -112,64 +101,32 @@ void lv_inv_area(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->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; - 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 ++; } } /** - * 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) + * Get the display which is being refreshed + * @return the display being refreshed */ -void lv_refr_set_monitor_cb(void (*cb)(uint32_t, uint32_t)) +lv_disp_t * lv_refr_get_disp_refreshing(void) { - 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 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; + return disp_refr; } /********************** @@ -184,69 +141,63 @@ static void lv_refr_task(void * param) { (void)param; - LV_LOG_TRACE("display refresh task started"); + LV_LOG_TRACE("lv_refr_task: started"); uint32_t start = lv_tick_get(); - if(lv_disp_get_active() == NULL) { - LV_LOG_TRACE("No display is registered"); - return; - } + LL_READ(LV_GC_ROOT(_lv_disp_ll), disp_refr) { + LV_LOG_TRACE("lv_refr_task: refreshing a display"); - lv_refr_join_area(); + lv_refr_join_area(); - lv_refr_areas(); + lv_refr_areas(); - /*If refresh happened ...*/ - if(inv_buf_p != 0) { + /*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_buf(disp_refr)) { + lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr); - /*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; + /*Flush the content of the VDB*/ + lv_refr_vdb_flush(); - /*Flush the content of the VDB*/ - lv_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 changed content to the other frame buffer (new active VDB) + * to keep the buffers synchronized*/ + while(vdb->flushing); - /* 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(); + uint8_t * buf_act = (uint8_t *) vdb->buf_act; + uint8_t * buf_ina = (uint8_t *) vdb->buf_act == vdb->buf1 ? vdb->buf2 : vdb->buf1; - uint8_t * buf_act = (uint8_t *) vdb_act->buf; - uint8_t * buf_ina = (uint8_t *) vdb_ina->buf; + 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 = (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); - 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; - - 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 += hres * sizeof(lv_color_t); + } + } } + } /*End of true double buffer handling*/ + + /*Clean up*/ + 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(disp_refr->driver.monitor_cb) { + disp_refr->driver.monitor_cb(&disp_refr->driver, lv_tick_elaps(start), px_num); } } - -#endif - - /*Clean up*/ - memset(inv_buf, 0, sizeof(inv_buf)); - inv_buf_p = 0; - - /*Call monitor cb if present*/ - if(monitor_cb != NULL) { - monitor_cb(lv_tick_elaps(start), px_num); - } } - LV_LOG_TRACE("display refresh task finished"); + LV_LOG_TRACE("lv_refr_task: ready"); } @@ -258,32 +209,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; } } } @@ -297,170 +248,133 @@ 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 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); -#endif - if(monitor_cb != NULL) px_num += lv_area_get_size(&inv_buf[i].area); + if(disp_refr->inv_area_joined[i] == 0) { + + lv_refr_area(&disp_refr->inv_areas[i]); + + if(disp_refr->driver.monitor_cb) 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_VER_RES ? y2 = LV_VER_RES - 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_buf(disp_refr)) { + lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr); + vdb->area.x1 = 0; + vdb->area.x2 = lv_disp_get_hor_res(disp_refr) - 1; + vdb->area.y1 = 0; + 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_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); + 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(disp_refr->driver.rounder_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; + 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); + + 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_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_buf(disp_refr) == false) { + while(vdb->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()); + 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(), &start_mask); - lv_refr_obj_and_children(lv_layer_sys(), &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_VDB_TRUE_DOUBLE_BUFFERED == 0 - /*Flush the content of the VDB*/ - lv_vdb_flush(); -#endif + if(lv_disp_is_true_double_buf(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 @@ -507,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(); + 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); @@ -608,3 +522,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_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) { + while(vdb->flushing); + } + + vdb->flushing = 1; + + /*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->driver, &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 75b22d017..2bd7d2b63 100644 --- a/lv_core/lv_refr.h +++ b/lv_core/lv_refr.h @@ -54,23 +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); - -/** - * 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*)); +void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p); /** * Get the number of areas in the buffer @@ -83,6 +71,13 @@ uint16_t lv_refr_get_buf_size(void); * @param num number of areas to delete */ void lv_refr_pop_from_buf(uint16_t num); + +/** + * Get the display which is being refreshed + * @return the display being refreshed + */ +lv_disp_t * lv_refr_get_disp_refreshing(void); + /********************** * STATIC FUNCTIONS **********************/ diff --git a/lv_core/lv_vdb.c b/lv_core/lv_vdb.c deleted file mode 100644 index 38aae34f4..000000000 --- a/lv_core/lv_vdb.c +++ /dev/null @@ -1,207 +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 - -/********************* - * 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) -{ -#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_flush(vdb_act->area.x1, vdb_act->area.y1, vdb_act->area.x2, vdb_act->area.y2, 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.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_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 84% rename from lv_draw/lv_draw_vbasic.c rename to lv_draw/lv_draw_basic.c index 4d1506d9a..31b8ba481 100644 --- a/lv_draw/lv_draw_vbasic.c +++ b/lv_draw/lv_draw_basic.c @@ -1,24 +1,22 @@ /** - * @file lv_vdraw.c + * @file lv_draw_basic.c * */ -#include "lv_draw_vbasic.h" +#include "lv_draw_basic.h" #include #include #include -#include "../lv_hal/lv_hal_disp.h" +#include "../lv_core/lv_refr.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" #include "../lv_misc/lv_log.h" -#if LV_VDB_SIZE != 0 - #include -#include "../lv_core/lv_vdb.h" #include "lv_draw.h" /********************* @@ -68,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 || @@ -85,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_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_p->area.x1; - y -= vdb_p->area.y1; + x -= vdb->area.x1; + y -= vdb->area.y1; - lv_disp_t * disp = lv_disp_get_active(); - if(disp->driver.vdb_wr) { - disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, x, y, color, opa); + if(disp->driver.set_px_cb) { + 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_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; @@ -116,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; @@ -124,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 @@ -138,40 +128,43 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, /*If there are common part of the three area then draw to the vdb*/ if(union_ok == false) return; - 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; + lv_disp_t * disp = lv_refr_get_disp_refreshing(); + lv_disp_buf_t * vdb = lv_disp_get_buf(disp); - lv_color_t * vdb_buf_tmp = vdb_p->buf; - uint32_t vdb_width = lv_area_get_width(&vdb_p->area); + lv_area_t vdb_rel_a; /*Stores relative coordinates on vdb*/ + 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->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; #if USE_LV_GPU - static LV_ATTRIBUTE_MEM_ALIGN lv_color_t color_array_tmp[LV_HOR_RES]; /*Used by 'lv_disp_mem_blend'*/ + static LV_ATTRIBUTE_MEM_ALIGN 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); /*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) { /*Use hw fill if present*/ - if(lv_disp_is_mem_fill_supported()) { + if(disp->driver.mem_fill) { lv_coord_t row; for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) { - lv_disp_mem_fill(&vdb_buf_tmp[vdb_rel_a.x1], w, color); + disp->driver.mem_fill(&vdb_buf_tmp[vdb_rel_a.x1], w, color); vdb_buf_tmp += vdb_width; } } /*Use hw blend if present and the area is not too small*/ else if(lv_area_get_height(&vdb_rel_a) > VFILL_HW_ACC_SIZE_LIMIT && - lv_disp_is_mem_blend_supported()) { + disp->driver.mem_blend) { /*Fill a one line sized buffer with a color and blend this later*/ if(color_array_tmp[0].full != color.full || last_width != w) { uint16_t i; @@ -184,21 +177,21 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, /*Blend the filled line to every line VDB line-by-line*/ lv_coord_t row; for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) { - lv_disp_mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa); + disp->driver.mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa); vdb_buf_tmp += vdb_width; } } /*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); } } /*Fill with opacity*/ else { /*Use hw blend if present*/ - if(lv_disp_is_mem_blend_supported()) { + if(disp->driver.mem_blend) { if(color_array_tmp[0].full != color.full || last_width != w) { uint16_t i; for(i = 0; i < w; i++) { @@ -209,19 +202,19 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, } lv_coord_t row; for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) { - lv_disp_mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa); + disp->driver.mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa); vdb_buf_tmp += vdb_width; } } /*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 } @@ -234,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) { @@ -296,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_disp_buf_t * vdb = lv_disp_get_buf(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; @@ -319,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; @@ -328,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_disp_get_active(); - uint8_t letter_px; lv_opa_t px_opa; for(row = row_start; row < row_end; row ++) { @@ -347,9 +335,9 @@ void lv_vletter(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_p->buf, vdb_width, - (col + pos_x) - vdb_p->area.x1, (row + pos_y) - vdb_p->area.y1, + if(disp->driver.set_px_cb) { + 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 { #if LV_COLOR_SCREEN_TRANSP == 0 @@ -389,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) { @@ -399,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 @@ -425,32 +408,33 @@ 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_disp_buf_t * vdb = lv_disp_get_buf(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_disp_get_active(); - /*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) { /*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_p->buf, 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*/ } @@ -459,10 +443,10 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p, else { for(row = masked_a.y1; row <= masked_a.y2; row++) { #if USE_LV_GPU - if(lv_disp_is_mem_blend_supported() == false) { + if(disp->driver.mem_blend == false) { sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa); } else { - lv_disp_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa); + disp->driver.mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa); } #else sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa); @@ -512,8 +496,8 @@ void lv_vmap(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_p->buf, vdb_width, col + masked_a.x1, row, recolored_px, opa_result); + if(disp->driver.set_px_cb) { + 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 { @@ -522,8 +506,8 @@ 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); + if(disp->driver.set_px_cb) { + 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 { @@ -583,11 +567,11 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_ lv_coord_t col; lv_coord_t mem_width = lv_area_get_width(mem_area); - lv_disp_t * disp = lv_disp_get_active(); - if(disp->driver.vdb_wr) { + lv_disp_t * disp = lv_refr_get_disp_refreshing(); + 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->driver, (uint8_t *)mem, mem_width, col, row, color, opa); } } } else { @@ -689,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..369fbb761 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 { @@ -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); @@ -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 0744ff114..2441d90be 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 lv_color_t recolor; lv_coord_t letter_w; - /*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 369adf523..000000000 --- a/lv_draw/lv_draw_rbasic.c +++ /dev/null @@ -1,269 +0,0 @@ -/** - * @file lv_draw_rbasic.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include "lv_draw_rbasic.h" -#if USE_LV_REAL_DRAW != 0 - -#include "../lv_hal/lv_hal_disp.h" -#include "../lv_misc/lv_font.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_HOR_RES - 1, LV_VER_RES - 1); - union_ok = lv_area_intersect(&masked_area, cords_p, &scr_area); - } - - if(union_ok != false) { - lv_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; - - /*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++) { - lv_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..b1d341ad8 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 @@ -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 @@ -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++; @@ -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 @@ -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.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..339f2853e 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" @@ -36,7 +36,7 @@ /********************** * STATIC VARIABLES **********************/ -static lv_disp_t * active; +static lv_disp_t * disp_def; /********************** * MACROS @@ -54,20 +54,48 @@ static lv_disp_t * active; */ void lv_disp_drv_init(lv_disp_drv_t * driver) { - driver->disp_fill = NULL; - driver->disp_map = NULL; - driver->disp_flush = NULL; + memset(driver, 0, sizeof(lv_disp_drv_t)); + + driver->flush_cb = NULL; + driver->hor_res = LV_HOR_RES_MAX; + driver->ver_res = LV_VER_RES_MAX; + driver->buffer = NULL; #if USE_LV_GPU driver->mem_blend = NULL; driver->mem_fill = NULL; #endif -#if LV_VDB_SIZE - driver->vdb_wr = NULL; -#endif + driver->set_px_cb = NULL; } + +/** + * Initialize a display buffer + * @param disp_buf pointer `lv_disp_buf_t` variable to initialize + * @param buf1 A buffer to be used by LittlevGL to draw the image. + * Always has to specified and can't be NULL. + * Can be an array allocated by the user. E.g. `static lv_color_t disp_buf1[1024 * 10]` + * Or a memory address e.g. in external SRAM + * @param buf2 Optionally specify a second buffer to make image rendering and image flushing + * (sending to the display) parallel. + * In the `disp_drv->flush` you should use DMA or similar hardware to send + * the image to the display in the background. + * It lets LittlevGL to render next frame into the other buffer while previous is being sent. + * Set to `NULL` if unused. + * @param size size of the `buf1` and `buf2` in pixel count. + */ +void lv_disp_buf_init(lv_disp_buf_t * disp_buf, void * buf1, void * buf2, uint32_t size) +{ + memset(disp_buf, 0, sizeof(lv_disp_buf_t)); + + disp_buf->buf1 = buf1; + disp_buf->buf2 = buf2; + disp_buf->buf_act = disp_buf->buf1; + disp_buf->size = size; +} + + /** * Register an initialized display driver. * Automatically set the first display as active. @@ -76,167 +104,167 @@ 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; - - 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_disp_t * disp = lv_ll_ins_head(&LV_GC_ROOT(_lv_disp_ll)); + if(!disp) { + lv_mem_assert(disp); + return NULL; } - return node; -} + memcpy(&disp->driver, driver, sizeof(lv_disp_drv_t)); + + lv_ll_init(&disp->scr_ll, sizeof(lv_obj_t)); + + 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); + + disp->inv_p = 0; + + lv_obj_invalidate(disp->act_scr); + + disp_def = disp_def_tmp; /*Revert the default display*/ -/** - * 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) -{ - active = disp; - lv_obj_invalidate(lv_scr_act()); + return disp; } /** - * Get a pointer to the active display - * @return pointer to the active display + * 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_active(void) +void lv_disp_set_default(lv_disp_t * disp) { - return active; + disp_def = disp; } +/** + * Get the default display + * @return pointer to the default display + */ +lv_disp_t * lv_disp_get_default(void) +{ + return disp_def; +} + +/** + * 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(); + + if(disp == NULL) return LV_HOR_RES_MAX; + 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(); + + if(disp == NULL) return LV_VER_RES_MAX; + else return disp->driver.ver_res; +} + +/** + * 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_drv_t * disp_drv) +{ + disp_drv->buffer->flushing = 0; + + /*If the screen is transparent initialize it when the flushing is ready*/ +#if LV_COLOR_SCREEN_TRANSP + memset(vdb_buf, 0x00, LV_VDB_SIZE_IN_BYTES); +#endif +} + + /** * 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_disp_t * lv_disp_get_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); } /** - * Write the content of the internal buffer (VDB) to the display - * @param x1 left coordinate of the rectangle - * @param x2 right coordinate of the rectangle - * @param y1 top coordinate of the rectangle - * @param y2 bottom coordinate of the rectangle - * @param color_p fill color + * Get the internal buffer of a display + * @param disp pointer to a display + * @return pointer to the internal buffers */ -void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color) +lv_disp_buf_t * lv_disp_get_buf(lv_disp_t * disp) { - if(active == NULL) return; - if(active->driver.disp_fill != NULL) active->driver.disp_fill(x1, y1, x2, y2, color); + return disp->driver.buffer; } /** - * Fill a rectangular area with a color on the active display - * @param x1 left coordinate of the rectangle - * @param x2 right coordinate of the rectangle - * @param y1 top coordinate of the rectangle - * @param y2 bottom coordinate of the rectangle - * @param color_p pointer to an array of colors + * Get the number of areas in the buffer + * @return number of invalid areas */ -void lv_disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t * color_p) +uint16_t lv_disp_get_inv_buf_size(lv_disp_t * disp) { - if(active == NULL) return; - if(active->driver.disp_flush != NULL) { - - LV_LOG_TRACE("disp flush started"); - active->driver.disp_flush(x1, y1, x2, y2, color_p); - LV_LOG_TRACE("disp flush ready"); - - } else { - LV_LOG_WARN("disp flush function registered"); - } + return disp->inv_p; } /** - * Put a color map to a rectangular area on the active display - * @param x1 left coordinate of the rectangle - * @param x2 right coordinate of the rectangle - * @param y1 top coordinate of the rectangle - * @param y2 bottom coordinate of the rectangle - * @param color_map pointer to an array of colors + * Pop (delete) the last 'num' invalidated areas from the buffer + * @param num number of areas to delete */ -void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_map) +void lv_disp_pop_from_inv_buf(lv_disp_t * disp, uint16_t num) { - if(active == NULL) return; - if(active->driver.disp_map != NULL) active->driver.disp_map(x1, y1, x2, y2, color_map); -} -#if USE_LV_GPU - -/** - * Blend pixels to a destination memory from a source memory - * In 'lv_disp_drv_t' 'mem_blend' is optional. (NULL if not available) - * @param dest a memory address. Blend 'src' here. - * @param src pointer to pixel map. Blend it to 'dest'. - * @param length number of pixels in 'src' - * @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover) - */ -void lv_disp_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa) -{ - if(active == NULL) return; - if(active->driver.mem_blend != NULL) active->driver.mem_blend(dest, src, length, opa); + if(disp->inv_p < num) disp->inv_p = 0; + else disp->inv_p -= num; } /** - * Fill a memory with a color (GPUs may support it) - * In 'lv_disp_drv_t' 'mem_fill' is optional. (NULL if not available) - * @param dest a memory address. Copy 'src' here. - * @param src pointer to pixel map. Copy it to 'dest'. - * @param length number of pixels in 'src' - * @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover) + * 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 */ -void lv_disp_mem_fill(lv_color_t * dest, uint32_t length, lv_color_t color) +bool lv_disp_is_double_buf(lv_disp_t * disp) { - if(active == NULL) return; - if(active->driver.mem_fill != NULL) active->driver.mem_fill(dest, length, color); -} - -/** - * Shows if memory blending (by GPU) is supported or not - * @return false: 'mem_blend' is not supported in the driver; true: 'mem_blend' is supported in the driver - */ -bool lv_disp_is_mem_blend_supported(void) -{ - if(active == NULL) return false; - if(active->driver.mem_blend) return true; + if(disp->driver.buffer->buf1 && disp->driver.buffer->buf2) return true; else return false; } /** - * Shows if memory fill (by GPU) is supported or not - * @return false: 'mem_fill' is not supported in the drover; true: 'mem_fill' is supported in the driver + * 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_mem_fill_supported(void) +bool lv_disp_is_true_double_buf(lv_disp_t * disp) { - if(active == NULL) return false; - if(active->driver.mem_fill) return true; - else return false; + 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; + } } -#endif /********************** * STATIC FUNCTIONS **********************/ - diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index 131b948cc..4b820e49c 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,46 +20,98 @@ extern "C" { #include "lv_hal.h" #include "../lv_misc/lv_color.h" #include "../lv_misc/lv_area.h" +#include "../lv_misc/lv_ll.h" /********************* * DEFINES *********************/ +#ifndef LV_INV_BUF_SIZE +#define LV_INV_BUF_SIZE 32 /*Buffer size for invalid areas */ +#endif + +#ifndef LV_ATTRIBUTE_FLUSH_READY +# define LV_ATTRIBUTE_FLUSH_READY +#endif /********************** * TYPEDEFS **********************/ +struct _disp_t; +struct _disp_drv_t; + + +typedef struct +{ + void * buf1; + void * buf2; + + /*Used by the library*/ + void * buf_act; + uint32_t size; /*In pixel count*/ + lv_area_t area; + uint32_t flushing :1; +}lv_disp_buf_t; + + /** * Display Driver structure to be registered by HAL */ typedef struct _disp_drv_t { - /*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); - /*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); + /*Horizontal and vertical resolution*/ + lv_coord_t hor_res; + lv_coord_t ver_res; - /*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); + /* 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; + + /* 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_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_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_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_drv_user_data_t monitor_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 -#if LV_VDB_SIZE - /*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; + typedef struct _disp_t { + /*Driver to the display*/ lv_disp_drv_t driver; - struct _disp_t *next; + + /*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; } lv_disp_t; /********************** @@ -72,7 +124,25 @@ 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); +void lv_disp_drv_init(lv_disp_drv_t * driver); + + +/** + * Initialize a display buffer + * @param disp_buf pointer `lv_disp_buf_t` variable to initialize + * @param buf1 A buffer to be used by LittlevGL to draw the image. + * Always has to specified and can't be NULL. + * Can be an array allocated by the user. E.g. `static lv_color_t disp_buf1[1024 * 10]` + * Or a memory address e.g. in external SRAM + * @param buf2 Optionally specify a second buffer to make image rendering and image flushing + * (sending to the display) parallel. + * In the `disp_drv->flush` you should use DMA or similar hardware to send + * the image to the display in the background. + * It lets LittlevGL to render next frame into the other buffer while previous is being sent. + * Set to `NULL` if unused. + * @param size size of the `buf1` and `buf2` in pixel count. + */ +void lv_disp_buf_init(lv_disp_buf_t * disp_buf, void * buf1, void * buf2, uint32_t size); /** * Register an initialized display driver. @@ -80,89 +150,81 @@ void lv_disp_drv_init(lv_disp_drv_t *driver); * @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); +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') + * Set a default screen. The new screens will be created on it by default. + * @param disp pointer to a display */ -void lv_disp_set_active(lv_disp_t * disp); +void lv_disp_set_default(lv_disp_t * disp); /** - * Get a pointer to the active display - * @return pointer to the active display + * Get the default display + * @return pointer to the default display */ -lv_disp_t * lv_disp_get_active(void); +lv_disp_t * lv_disp_get_default(void); + +/** + * 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_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_drv_t * disp_drv); + /** * 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_disp_t * lv_disp_get_next(lv_disp_t * disp); /** - * Fill a rectangular area with a color on the active display - * @param x1 left coordinate of the rectangle - * @param x2 right coordinate of the rectangle - * @param y1 top coordinate of the rectangle - * @param y2 bottom coordinate of the rectangle - * @param color_p pointer to an array of colors + * Get the internal buffer of a display + * @param disp pointer to a display + * @return pointer to the internal buffers */ -void lv_disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color_p); +lv_disp_buf_t * lv_disp_get_buf(lv_disp_t * disp); /** - * Fill a rectangular area with a color on the active display - * @param x1 left coordinate of the rectangle - * @param x2 right coordinate of the rectangle - * @param y1 top coordinate of the rectangle - * @param y2 bottom coordinate of the rectangle - * @param color fill color + * Get the number of areas in the buffer + * @return number of invalid areas */ -void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color); +uint16_t lv_disp_get_inv_buf_size(lv_disp_t * disp); /** - * Put a color map to a rectangular area on the active display - * @param x1 left coordinate of the rectangle - * @param x2 right coordinate of the rectangle - * @param y1 top coordinate of the rectangle - * @param y2 bottom coordinate of the rectangle - * @param color_map pointer to an array of colors + * Pop (delete) the last 'num' invalidated areas from the buffer + * @param num number of areas to delete */ -void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_map); - -#if USE_LV_GPU -/** - * Blend pixels to a destination memory from a source memory - * In 'lv_disp_drv_t' 'mem_blend' is optional. (NULL if not available) - * @param dest a memory address. Blend 'src' here. - * @param src pointer to pixel map. Blend it to 'dest'. - * @param length number of pixels in 'src' - * @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover) - */ -void lv_disp_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa); +void lv_disp_pop_from_inv_buf(lv_disp_t * disp, uint16_t num); /** - * Fill a memory with a color (GPUs may support it) - * In 'lv_disp_drv_t' 'mem_fill' is optional. (NULL if not available) - * @param dest a memory address. Copy 'src' here. - * @param src pointer to pixel map. Copy it to 'dest'. - * @param length number of pixels in 'src' - * @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover) + * 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 */ -void lv_disp_mem_fill(lv_color_t * dest, uint32_t length, lv_color_t color); -/** - * Shows if memory blending (by GPU) is supported or not - * @return false: 'mem_blend' is not supported in the driver; true: 'mem_blend' is supported in the driver - */ -bool lv_disp_is_mem_blend_supported(void); +bool lv_disp_is_double_buf(lv_disp_t * disp); /** - * Shows if memory fill (by GPU) is supported or not - * @return false: 'mem_fill' is not supported in the drover; true: 'mem_fill' is supported in the driver + * 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_mem_fill_supported(void); -#endif +bool lv_disp_is_true_double_buf(lv_disp_t * disp); + /********************** * MACROS **********************/ diff --git a/lv_hal/lv_hal_indev.c b/lv_hal/lv_hal_indev.c index 6083c3fd2..7ee8530e3 100644 --- a/lv_hal/lv_hal_indev.c +++ b/lv_hal/lv_hal_indev.c @@ -11,6 +11,7 @@ #include "../lv_hal/lv_hal_indev.h" #include "../lv_misc/lv_mem.h" #include "../lv_misc/lv_gc.h" +#include "lv_hal_disp.h" #if defined(LV_GC_INCLUDE) # include LV_GC_INCLUDE @@ -49,9 +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->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_default(); + + 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); } /** @@ -115,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->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 214b02754..7fb638706 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" { @@ -15,11 +15,15 @@ extern "C" { /********************* * INCLUDES *********************/ +#ifdef LV_CONF_INCLUDE_SIMPLE +#include "lv_conf.h" +#else +#include "../../lv_conf.h" +#endif + #include #include -#include "lv_hal.h" #include "../lv_misc/lv_area.h" -#include "../lv_core/lv_obj.h" /********************* * DEFINES @@ -29,6 +33,11 @@ extern "C" { * TYPEDEFS **********************/ +struct _lv_obj_t; +struct _disp_t; +struct _lv_indev_t; +struct _lv_indev_drv_t; + /*Possible input device types*/ enum { LV_INDEV_TYPE_NONE, /*Show uninitialized state*/ @@ -49,23 +58,24 @@ typedef uint8_t lv_indev_state_t; /*Data type when an input device is read */ typedef struct { 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*/ }; - 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; /*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)*/ - void *user_data; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/ +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_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; -struct _lv_obj_t; /*Run time data of input devices*/ typedef struct _lv_indev_proc_t { @@ -99,9 +109,7 @@ 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 *, lv_signal_t); +typedef void (*lv_indev_feedback_t)(struct _lv_indev_t *, uint8_t); struct _lv_obj_t; struct _lv_group_t; @@ -118,7 +126,6 @@ typedef struct _lv_indev_t { 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 +150,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 38090f044..35559f39b 100644 --- a/lv_misc/lv_gc.h +++ b/lv_misc/lv_gc.h @@ -31,18 +31,13 @@ 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 lv_ll_t _lv_group_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 diff --git a/lv_objx/lv_btnm.c b/lv_objx/lv_btnm.c index 0128614f7..dca929111 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*/ @@ -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_chart.c b/lv_objx/lv_chart.c index 778f24b1f..8d3e97359 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_cont.c b/lv_objx/lv_cont.c index f45a9cb01..b39b44e3b 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/lv_objx/lv_kb.c b/lv_objx/lv_kb.c index 3259ffe59..be7684760 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 1f09c1dbd..adaf4ad42 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_fit2(new_mbox, LV_FIT_NONE, LV_FIT_TIGHT); - 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_page.c b/lv_objx/lv_page.c index 46b9a2c33..8b2f602d8 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -998,6 +998,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); @@ -1005,7 +1006,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) { @@ -1014,7 +1015,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; } } @@ -1066,6 +1067,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); @@ -1073,7 +1075,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); @@ -1081,7 +1083,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); } @@ -1135,7 +1137,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); @@ -1143,7 +1145,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 7f85c7952..2465524a1 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -1232,13 +1232,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); } } } @@ -1423,13 +1424,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); @@ -1438,7 +1440,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); } static void placeholder_update(lv_obj_t * ta) diff --git a/lv_objx/lv_tabview.c b/lv_objx/lv_tabview.c index 1ba09268f..a777f33d5 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_HOR_RES, LV_VER_RES); + 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); lv_obj_set_height(ext->btns, 3 * LV_DPI / 4); @@ -123,7 +124,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) lv_cont_set_fit2(ext->content, LV_FIT_TIGHT, LV_FIT_NONE); 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 9528a17ed..b1586a0ba 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, LV_FIT_TIGHT); /*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 db7205ae9..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,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_HOR_RES, LV_VER_RES); + 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); lv_obj_set_pos(new_win, 0, 0); lv_obj_set_style(new_win, &lv_style_pretty); @@ -107,7 +111,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/lv_porting/lv_port_disp_templ.c b/lv_porting/lv_port_disp_templ.c index 18e676372..39f928d23 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,15 @@ 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; + /*Set the resolution of the display*/ + disp_drv.hor_res = 480; + disp_drv.ver_res = 320; - /*Used in unbuffered mode (LV_VDB_SIZE == 0 in lv_conf.h)*/ - disp_drv.disp_fill = disp_fill; + /*Used to copy the buffer's content to the display*/ + disp_drv.flush_cb = disp_flush; - /*Used in unbuffered mode (LV_VDB_SIZE == 0 in lv_conf.h)*/ - disp_drv.disp_map = disp_map; + /*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)*/ @@ -95,16 +129,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 +146,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 102c16f90..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); + 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" /********************* diff --git a/lvgl.h b/lvgl.h index 2d0dd560d..527ded834 100644 --- a/lvgl.h +++ b/lvgl.h @@ -24,8 +24,8 @@ 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" #include "lv_themes/lv_theme.h"