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
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
hex "Images pixels with this color will not be drawn (if they are chroma keyed)."
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*/
#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)*/
#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 = 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 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):
#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
@@ -107,7 +107,7 @@ for line in fin.read().splitlines():
f'# define {name} 0\n'
f'# endif\n'
f'# else\n'
f'# define {name_and_value}\n'
f'# define{name_and_value}\n'
f'# endif\n'
f'#endif\n'
)
@@ -121,7 +121,7 @@ for line in fin.read().splitlines():
f'# ifdef CONFIG_{name.upper()}\n'
f'# define {name} CONFIG_{name.upper()}\n'
f'# else\n'
f'# define {name_and_value}\n'
f'# define{name_and_value}\n'
f'# endif\n'
f'#endif\n'
)

View File

@@ -58,13 +58,9 @@
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
#ifndef LV_COLOR_DEPTH
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_COLOR_DEPTH
# define LV_COLOR_DEPTH CONFIG_LV_COLOR_DEPTH
# else
# define LV_COLOR_DEPTH 0
# endif
# else
# define LV_COLOR_DEPTH 16
# endif
#endif
@@ -89,6 +85,16 @@
# 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)*/
#ifndef 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.
*You will see an error log message if there wasn't enough buffers. */
#ifndef LV_MEM_BUF_MAX_NUM
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_MEM_BUF_MAX_NUM
# define LV_MEM_BUF_MAX_NUM CONFIG_LV_MEM_BUF_MAX_NUM
# else
# define LV_MEM_BUF_MAX_NUM 0
# endif
# else
# define LV_MEM_BUF_MAX_NUM 16
# endif
#endif
@@ -239,13 +241,9 @@
/*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)*/
#ifndef LV_DPI_DEF
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_DPI_DEF
# define LV_DPI_DEF CONFIG_LV_DPI_DEF
# else
# define LV_DPI_DEF 0
# endif
# else
# define LV_DPI_DEF 130 /*[px/inch]*/
# 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.
*If LV_USE_LOG is enabled an error message will be printed on failure*/
#ifndef LV_USE_ASSERT_NULL
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_USE_ASSERT_NULL
# define LV_USE_ASSERT_NULL CONFIG_LV_USE_ASSERT_NULL
# else
# define LV_USE_ASSERT_NULL 0
# endif
# else
# define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/
# endif
#endif
#ifndef LV_USE_ASSERT_MALLOC
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_USE_ASSERT_MALLOC
# define LV_USE_ASSERT_MALLOC CONFIG_LV_USE_ASSERT_MALLOC
# 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)*/
# endif
#endif
@@ -1293,25 +1283,17 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
#endif
#ifndef LV_USE_DROPDOWN
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_USE_DROPDOWN
# define LV_USE_DROPDOWN CONFIG_LV_USE_DROPDOWN
# else
# define LV_USE_DROPDOWN 0
# endif
# else
# define LV_USE_DROPDOWN 1 /*Requires: lv_label*/
# endif
#endif
#ifndef LV_USE_IMG
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_USE_IMG
# define LV_USE_IMG CONFIG_LV_USE_IMG
# else
# define LV_USE_IMG 0
# endif
# else
# define LV_USE_IMG 1 /*Requires: lv_label*/
# endif
#endif
@@ -1329,24 +1311,16 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
#endif
#if LV_USE_LABEL
#ifndef LV_LABEL_TEXT_SELECTION
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_LABEL_TEXT_SELECTION
# define LV_LABEL_TEXT_SELECTION CONFIG_LV_LABEL_TEXT_SELECTION
# else
# define LV_LABEL_TEXT_SELECTION 0
# endif
# else
# define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/
# endif
#endif
#ifndef LV_LABEL_LONG_TXT_HINT
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_LABEL_LONG_TXT_HINT
# define LV_LABEL_LONG_TXT_HINT CONFIG_LV_LABEL_LONG_TXT_HINT
# 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*/
# endif
#endif
@@ -1365,13 +1339,9 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
#endif
#ifndef LV_USE_ROLLER
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_USE_ROLLER
# define LV_USE_ROLLER CONFIG_LV_USE_ROLLER
# else
# define LV_USE_ROLLER 0
# endif
# else
# define LV_USE_ROLLER 1 /*Requires: lv_label*/
# endif
#endif
@@ -1386,13 +1356,9 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
#endif
#ifndef LV_USE_SLIDER
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_USE_SLIDER
# define LV_USE_SLIDER CONFIG_LV_USE_SLIDER
# else
# define LV_USE_SLIDER 0
# endif
# else
# define LV_USE_SLIDER 1 /*Requires: lv_bar*/
# endif
#endif
@@ -1410,25 +1376,17 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
#endif
#ifndef LV_USE_TEXTAREA
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_USE_TEXTAREA
# define LV_USE_TEXTAREA CONFIG_LV_USE_TEXTAREA
# else
# define LV_USE_TEXTAREA 0
# endif
# else
# define LV_USE_TEXTAREA 1 /*Requires: lv_label*/
# endif
#endif
#if LV_USE_TEXTAREA != 0
#ifndef LV_TEXTAREA_DEF_PWD_SHOW_TIME
# ifdef _LV_KCONFIG_PRESENT
# ifdef CONFIG_LV_TEXTAREA_DEF_PWD_SHOW_TIME
# define LV_TEXTAREA_DEF_PWD_SHOW_TIME CONFIG_LV_TEXTAREA_DEF_PWD_SHOW_TIME
# else
# define LV_TEXTAREA_DEF_PWD_SHOW_TIME 0
# endif
# else
# define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/
# 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!"
#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)
/**
* MSVC compiler's definition of the __cplusplus indicating 199711L regardless to C++ standard version