Skip to content

"Readable" LV_COLOR_DEPTH option in lv_conf.h #216

@C47D

Description

@C47D

Hi,

@embeddedt I think you can help me out on this one, I'm comparing the current lv_conf.h with the lv_conf_internal.h. This is because we want to handle all configurations inside lv_conf_internal.h so we don't need lv_conf.h to use LVGL as an ESP-IDF component.

Here's the issue:

Currently the LV_COLOR_DEPTH configuration looks like this in lv_conf.h:

/* Color depth:
 * - 1:  1 byte per pixel
 * - 8:  RGB233
 * - 16: RGB565
 * - 32: ARGB8888
 */
#if defined (CONFIG_LV_COLOR_DEPTH_1)
#define LV_COLOR_DEPTH     1
#elif defined (CONFIG_LV_COLOR_DEPTH_8)
#define LV_COLOR_DEPTH     8
#elif defined (CONFIG_LV_COLOR_DEPTH_16)
#define LV_COLOR_DEPTH     16
#elif defined (CONFIG_LV_COLOR_DEPTH_32)
#define LV_COLOR_DEPTH     32
#endif

In lv_conf_internal.h:

/* Color depth:
 * - 1:  1 byte per pixel
 * - 8:  RGB332
 * - 16: RGB565
 * - 32: ARGB8888
 */
#ifndef LV_COLOR_DEPTH
#  ifdef CONFIG_LV_COLOR_DEPTH
#    define LV_COLOR_DEPTH CONFIG_LV_COLOR_DEPTH
#  else
#    define  LV_COLOR_DEPTH     16
#  endif
#endif

To make them look alike we need to define CONFIG_LV_COLOR_DEPTH as an integer out of a Kconfig choice (which I don't think is possible), but applying this workaround it is.

Applying the workaround to our Kconfig it looks like this:

choice LV_COLOR_DEPTH_BOOL
        prompt "Color depth."
        default LV_COLOR_DEPTH_16
        help
            Color depth to be used.

        config LV_COLOR_DEPTH_32
            bool "32: ARGB8888"
        config LV_COLOR_DEPTH_16
            bool "16: RGB565"
        config LV_COLOR_DEPTH_8
            bool "8: RGB232"
        config LV_COLOR_DEPTH_1
            bool "1: 1 byte per pixel"
    endchoice

# Without prompt the user don't see this configuration but the symbol is generated
config LV_COLOR_DEPTH
   int
   default 16
   default 1 if LV_COLOR_DEPTH_1
   default 8 if LV_COLOR_DEPTH_8
   default 16 if LV_COLOR_DEPTH_16
   default 32 if LV_COLOR_DEPTH_32

And the generated symbols:

#define CONFIG_LV_COLOR_DEPTH_16 1
#define CONFIG_LV_COLOR_DEPTH 16

New lv_conf.h

/* Color depth:
 * - 1:  1 byte per pixel
 * - 8:  RGB233
 * - 16: RGB565
 * - 32: ARGB8888
 */
#define LV_COLOR_DEPTH     CONFIG_LV_COLOR_DEPTH

Which pretty much matches the lv_conf_internal.h and personally I think it's much easier to read.

What do you think @embeddedt and @kisvegabor? Should I apply this change and maybe find more places to apply it to?

Metadata

Metadata

Assignees

No one assigned

    Labels

    pinnedDoesn't get closed automatically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions