fix(conf): Make LV_COLOR_MIX_ROUND_OFS configurable (#2766)

* fix(config): check macro equal one correctly

1.remove all tabs from lv_conf_internal_gen.py
2.make the generated code align each other

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

* fix(conf): Make LV_COLOR_MIX_ROUND_OFS configurable

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2021-11-08 07:40:08 -06:00
committed by GitHub
parent dfb036e42c
commit ddfdccac3c
5 changed files with 263 additions and 306 deletions

12
Kconfig
View File

@@ -48,6 +48,18 @@ menu "LVGL configuration"
Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to
non LV_OPA_COVER value non LV_OPA_COVER value
config LV_COLOR_MIX_ROUND_OFS
int "Adjust color mix functions rounding"
default 128 if !LV_COLOR_DEPTH_32
default 0 if LV_COLOR_DEPTH_32
range 0 254
help
0: no adjustment, get the integer part of the result (round down)
64: round up from x.75
128: round up from half
192: round up from x.25
254: round up
config LV_COLOR_CHROMA_KEY_HEX config LV_COLOR_CHROMA_KEY_HEX
hex "Images pixels with this color will not be drawn (if they are chroma keyed)." hex "Images pixels with this color will not be drawn (if they are chroma keyed)."
range 0x000000 0xFFFFFF range 0x000000 0xFFFFFF

View File

@@ -34,6 +34,10 @@
*Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to non LV_OPA_COVER value*/ *Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to non LV_OPA_COVER value*/
#define LV_COLOR_SCREEN_TRANSP 0 #define LV_COLOR_SCREEN_TRANSP 0
/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently.
* 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */
#define LV_COLOR_MIX_ROUND_OFS (LV_COLOR_DEPTH == 32 ? 0: 128)
/*Images pixels with this color will not be drawn if they are chroma keyed)*/ /*Images pixels with this color will not be drawn if they are chroma keyed)*/
#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/ #define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/

View File

@@ -88,11 +88,11 @@ for line in fin.read().splitlines():
name = r[1] name = r[1]
name = re.sub('\(.*?\)', '', name, 1) #remove parentheses from macros. E.g. MY_FUNC(5) -> MY_FUNC name = re.sub('\(.*?\)', '', name, 1) #remove parentheses from macros. E.g. MY_FUNC(5) -> MY_FUNC
name_and_value = re.sub('.*# *define', '', line, 1) name_and_value = re.sub('[\s]*#[\s]*define', '', line, 1)
#If the value should be 1 (enabled) by default use a more complex structure for Kconfig checks because #If the value should be 1 (enabled) by default use a more complex structure for Kconfig checks because
#if a not defined CONFIG_... value should be interpreted as 0 and not the LVGL default #if a not defined CONFIG_... value should be interpreted as 0 and not the LVGL default
is_one = re.search(r'.*#.*define +[A-Z0-9_]+ +1[^0-9]*', line) is_one = re.search(r'[\s]*#[\s]*define[\s]*[A-Z0-9_]+[\s]+1[\s]*$', line)
if(is_one): if(is_one):
#1. Use the value if already set from lv_conf.h or anything else (i.e. do nothing) #1. Use the value if already set from lv_conf.h or anything else (i.e. do nothing)
#2. In Kconfig environment use the CONFIG_... value if set, else use 0 #2. In Kconfig environment use the CONFIG_... value if set, else use 0

View File

@@ -58,13 +58,9 @@
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/ /*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
#ifndef LV_COLOR_DEPTH #ifndef LV_COLOR_DEPTH
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_COLOR_DEPTH # ifdef CONFIG_LV_COLOR_DEPTH
# define LV_COLOR_DEPTH CONFIG_LV_COLOR_DEPTH # define LV_COLOR_DEPTH CONFIG_LV_COLOR_DEPTH
# else # else
# define LV_COLOR_DEPTH 0
# endif
# else
# define LV_COLOR_DEPTH 16 # define LV_COLOR_DEPTH 16
# endif # endif
#endif #endif
@@ -89,6 +85,16 @@
# endif # endif
#endif #endif
/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently.
* 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */
#ifndef LV_COLOR_MIX_ROUND_OFS
# ifdef CONFIG_LV_COLOR_MIX_ROUND_OFS
# define LV_COLOR_MIX_ROUND_OFS CONFIG_LV_COLOR_MIX_ROUND_OFS
# else
# define LV_COLOR_MIX_ROUND_OFS (LV_COLOR_DEPTH == 32 ? 0: 128)
# endif
#endif
/*Images pixels with this color will not be drawn if they are chroma keyed)*/ /*Images pixels with this color will not be drawn if they are chroma keyed)*/
#ifndef LV_COLOR_CHROMA_KEY #ifndef LV_COLOR_CHROMA_KEY
# ifdef CONFIG_LV_COLOR_CHROMA_KEY # ifdef CONFIG_LV_COLOR_CHROMA_KEY
@@ -168,13 +174,9 @@
/*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms. /*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms.
*You will see an error log message if there wasn't enough buffers. */ *You will see an error log message if there wasn't enough buffers. */
#ifndef LV_MEM_BUF_MAX_NUM #ifndef LV_MEM_BUF_MAX_NUM
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_MEM_BUF_MAX_NUM # ifdef CONFIG_LV_MEM_BUF_MAX_NUM
# define LV_MEM_BUF_MAX_NUM CONFIG_LV_MEM_BUF_MAX_NUM # define LV_MEM_BUF_MAX_NUM CONFIG_LV_MEM_BUF_MAX_NUM
# else # else
# define LV_MEM_BUF_MAX_NUM 0
# endif
# else
# define LV_MEM_BUF_MAX_NUM 16 # define LV_MEM_BUF_MAX_NUM 16
# endif # endif
#endif #endif
@@ -239,13 +241,9 @@
/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. /*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
*(Not so important, you can adjust it to modify default sizes and spaces)*/ *(Not so important, you can adjust it to modify default sizes and spaces)*/
#ifndef LV_DPI_DEF #ifndef LV_DPI_DEF
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_DPI_DEF # ifdef CONFIG_LV_DPI_DEF
# define LV_DPI_DEF CONFIG_LV_DPI_DEF # define LV_DPI_DEF CONFIG_LV_DPI_DEF
# else # else
# define LV_DPI_DEF 0
# endif
# else
# define LV_DPI_DEF 130 /*[px/inch]*/ # define LV_DPI_DEF 130 /*[px/inch]*/
# endif # endif
#endif #endif
@@ -541,24 +539,16 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
/*Enable asserts if an operation is failed or an invalid data is found. /*Enable asserts if an operation is failed or an invalid data is found.
*If LV_USE_LOG is enabled an error message will be printed on failure*/ *If LV_USE_LOG is enabled an error message will be printed on failure*/
#ifndef LV_USE_ASSERT_NULL #ifndef LV_USE_ASSERT_NULL
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_USE_ASSERT_NULL # ifdef CONFIG_LV_USE_ASSERT_NULL
# define LV_USE_ASSERT_NULL CONFIG_LV_USE_ASSERT_NULL # define LV_USE_ASSERT_NULL CONFIG_LV_USE_ASSERT_NULL
# else # else
# define LV_USE_ASSERT_NULL 0
# endif
# else
# define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/ # define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/
# endif # endif
#endif #endif
#ifndef LV_USE_ASSERT_MALLOC #ifndef LV_USE_ASSERT_MALLOC
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_USE_ASSERT_MALLOC # ifdef CONFIG_LV_USE_ASSERT_MALLOC
# define LV_USE_ASSERT_MALLOC CONFIG_LV_USE_ASSERT_MALLOC # define LV_USE_ASSERT_MALLOC CONFIG_LV_USE_ASSERT_MALLOC
# else # else
# define LV_USE_ASSERT_MALLOC 0
# endif
# else
# define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/ # define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/
# endif # endif
#endif #endif
@@ -1293,25 +1283,17 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
#endif #endif
#ifndef LV_USE_DROPDOWN #ifndef LV_USE_DROPDOWN
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_USE_DROPDOWN # ifdef CONFIG_LV_USE_DROPDOWN
# define LV_USE_DROPDOWN CONFIG_LV_USE_DROPDOWN # define LV_USE_DROPDOWN CONFIG_LV_USE_DROPDOWN
# else # else
# define LV_USE_DROPDOWN 0
# endif
# else
# define LV_USE_DROPDOWN 1 /*Requires: lv_label*/ # define LV_USE_DROPDOWN 1 /*Requires: lv_label*/
# endif # endif
#endif #endif
#ifndef LV_USE_IMG #ifndef LV_USE_IMG
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_USE_IMG # ifdef CONFIG_LV_USE_IMG
# define LV_USE_IMG CONFIG_LV_USE_IMG # define LV_USE_IMG CONFIG_LV_USE_IMG
# else # else
# define LV_USE_IMG 0
# endif
# else
# define LV_USE_IMG 1 /*Requires: lv_label*/ # define LV_USE_IMG 1 /*Requires: lv_label*/
# endif # endif
#endif #endif
@@ -1329,24 +1311,16 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
#endif #endif
#if LV_USE_LABEL #if LV_USE_LABEL
#ifndef LV_LABEL_TEXT_SELECTION #ifndef LV_LABEL_TEXT_SELECTION
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_LABEL_TEXT_SELECTION # ifdef CONFIG_LV_LABEL_TEXT_SELECTION
# define LV_LABEL_TEXT_SELECTION CONFIG_LV_LABEL_TEXT_SELECTION # define LV_LABEL_TEXT_SELECTION CONFIG_LV_LABEL_TEXT_SELECTION
# else # else
# define LV_LABEL_TEXT_SELECTION 0
# endif
# else
# define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/ # define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/
# endif # endif
#endif #endif
#ifndef LV_LABEL_LONG_TXT_HINT #ifndef LV_LABEL_LONG_TXT_HINT
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_LABEL_LONG_TXT_HINT # ifdef CONFIG_LV_LABEL_LONG_TXT_HINT
# define LV_LABEL_LONG_TXT_HINT CONFIG_LV_LABEL_LONG_TXT_HINT # define LV_LABEL_LONG_TXT_HINT CONFIG_LV_LABEL_LONG_TXT_HINT
# else # else
# define LV_LABEL_LONG_TXT_HINT 0
# endif
# else
# define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/ # define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/
# endif # endif
#endif #endif
@@ -1365,13 +1339,9 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
#endif #endif
#ifndef LV_USE_ROLLER #ifndef LV_USE_ROLLER
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_USE_ROLLER # ifdef CONFIG_LV_USE_ROLLER
# define LV_USE_ROLLER CONFIG_LV_USE_ROLLER # define LV_USE_ROLLER CONFIG_LV_USE_ROLLER
# else # else
# define LV_USE_ROLLER 0
# endif
# else
# define LV_USE_ROLLER 1 /*Requires: lv_label*/ # define LV_USE_ROLLER 1 /*Requires: lv_label*/
# endif # endif
#endif #endif
@@ -1386,13 +1356,9 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
#endif #endif
#ifndef LV_USE_SLIDER #ifndef LV_USE_SLIDER
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_USE_SLIDER # ifdef CONFIG_LV_USE_SLIDER
# define LV_USE_SLIDER CONFIG_LV_USE_SLIDER # define LV_USE_SLIDER CONFIG_LV_USE_SLIDER
# else # else
# define LV_USE_SLIDER 0
# endif
# else
# define LV_USE_SLIDER 1 /*Requires: lv_bar*/ # define LV_USE_SLIDER 1 /*Requires: lv_bar*/
# endif # endif
#endif #endif
@@ -1410,25 +1376,17 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
#endif #endif
#ifndef LV_USE_TEXTAREA #ifndef LV_USE_TEXTAREA
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_USE_TEXTAREA # ifdef CONFIG_LV_USE_TEXTAREA
# define LV_USE_TEXTAREA CONFIG_LV_USE_TEXTAREA # define LV_USE_TEXTAREA CONFIG_LV_USE_TEXTAREA
# else # else
# define LV_USE_TEXTAREA 0
# endif
# else
# define LV_USE_TEXTAREA 1 /*Requires: lv_label*/ # define LV_USE_TEXTAREA 1 /*Requires: lv_label*/
# endif # endif
#endif #endif
#if LV_USE_TEXTAREA != 0 #if LV_USE_TEXTAREA != 0
#ifndef LV_TEXTAREA_DEF_PWD_SHOW_TIME #ifndef LV_TEXTAREA_DEF_PWD_SHOW_TIME
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_TEXTAREA_DEF_PWD_SHOW_TIME # ifdef CONFIG_LV_TEXTAREA_DEF_PWD_SHOW_TIME
# define LV_TEXTAREA_DEF_PWD_SHOW_TIME CONFIG_LV_TEXTAREA_DEF_PWD_SHOW_TIME # define LV_TEXTAREA_DEF_PWD_SHOW_TIME CONFIG_LV_TEXTAREA_DEF_PWD_SHOW_TIME
# else # else
# define LV_TEXTAREA_DEF_PWD_SHOW_TIME 0
# endif
# else
# define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ # define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/
# endif # endif
#endif #endif

View File

@@ -73,23 +73,6 @@ enum {
#error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!" #error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!"
#endif #endif
/**
* Adjust color mix functions rounding.
* GPUs might calculate color mix (blending) differently.
* Should be in range of 0..254
* 0: no adjustment, get the integer part of the result (round down)
* 64: round up from x.75
* 128: round up from half
* 192: round up from x.25
* 254: round up*/
#ifndef LV_COLOR_MIX_ROUND_OFS
#if LV_COLOR_DEPTH == 32
#define LV_COLOR_MIX_ROUND_OFS 0
#else
#define LV_COLOR_MIX_ROUND_OFS 128
#endif
#endif
#if defined(__cplusplus) && !defined(_LV_COLOR_HAS_MODERN_CPP) #if defined(__cplusplus) && !defined(_LV_COLOR_HAS_MODERN_CPP)
/** /**
* MSVC compiler's definition of the __cplusplus indicating 199711L regardless to C++ standard version * MSVC compiler's definition of the __cplusplus indicating 199711L regardless to C++ standard version