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

@@ -59,7 +59,7 @@ fout.write(
# endif # endif
#endif #endif
#ifdef CONFIG_LV_COLOR_DEPTH #ifdef CONFIG_LV_COLOR_DEPTH
# define _LV_KCONFIG_PRESENT # define _LV_KCONFIG_PRESENT
#endif #endif
@@ -88,44 +88,44 @@ 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
#3. In not Kconfig environment use the LVGL's default value #3. In not Kconfig environment use the LVGL's default value
fout.write( fout.write(
f'#ifndef {name}\n' f'#ifndef {name}\n'
f'# ifdef _LV_KCONFIG_PRESENT\n' f'# ifdef _LV_KCONFIG_PRESENT\n'
f'# ifdef CONFIG_{name.upper()}\n' f'# ifdef CONFIG_{name.upper()}\n'
f'# define {name} CONFIG_{name.upper()}\n' f'# define {name} CONFIG_{name.upper()}\n'
f'# else\n' f'# else\n'
f'# define {name} 0\n' f'# define {name} 0\n'
f'# endif\n' f'# endif\n'
f'# else\n' f'# else\n'
f'# define {name_and_value}\n' f'# define{name_and_value}\n'
f'# endif\n' f'# endif\n'
f'#endif\n' f'#endif\n'
) )
else: else:
#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. Use the Kconfig value if set #2. Use the Kconfig value if set
#3. Use the LVGL's default value #3. Use the LVGL's default value
fout.write( fout.write(
f'#ifndef {name}\n' f'#ifndef {name}\n'
f'# ifdef CONFIG_{name.upper()}\n' f'# ifdef CONFIG_{name.upper()}\n'
f'# define {name} CONFIG_{name.upper()}\n' f'# define {name} CONFIG_{name.upper()}\n'
f'# else\n' f'# else\n'
f'# define {name_and_value}\n' f'# define{name_and_value}\n'
f'# endif\n' f'# endif\n'
f'#endif\n' f'#endif\n'
) )
elif re.search('^ *typedef .*;.*$', line): elif re.search('^ *typedef .*;.*$', line):
continue #ignore typedefs to avoide redeclaration continue #ignore typedefs to avoide redeclaration
else: else:

File diff suppressed because it is too large Load Diff

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