Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/gui/lvgl: Add user config file #36479

Closed

Conversation

krip-tip
Copy link
Contributor

Add custom preferences file, for example
to enable custom fonts and change preferences.

Signed-off-by: Krivorot Oleg [email protected]

@krip-tip krip-tip requested a review from vanwinkeljan as a code owner June 23, 2021 11:06
lib/gui/lvgl/Kconfig Outdated Show resolved Hide resolved
lib/gui/lvgl/Kconfig Outdated Show resolved Hide resolved
lib/gui/lvgl/Kconfig Outdated Show resolved Hide resolved
lib/gui/lvgl/Kconfig Outdated Show resolved Hide resolved
lib/gui/lvgl/lv_conf.h Outdated Show resolved Hide resolved
@krip-tip krip-tip requested a review from stephanosio June 23, 2021 12:25
lib/gui/lvgl/Kconfig Outdated Show resolved Hide resolved
@krip-tip krip-tip changed the title lib/gui/lvgl: Add user user config file lib/gui/lvgl: Add user config file Jun 23, 2021
@krip-tip krip-tip requested a review from stephanosio June 24, 2021 09:21
lib/gui/lvgl/Kconfig Outdated Show resolved Hide resolved
Copy link
Member

@stephanosio stephanosio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please amend commits instead of adding new ones for the changes.

@stephanosio
Copy link
Member

stephanosio commented Jun 24, 2021

Add custom preferences file, for example
to enable custom fonts and change preferences.

Signed-off-by: Krivorot Oleg [email protected]
@krip-tip krip-tip force-pushed the lib_lvgl_user_config branch from b5ac2f8 to 19c431b Compare June 24, 2021 11:38
@krip-tip
Copy link
Contributor Author

https://docs.zephyrproject.org/latest/contribute/index.html#contribution-workflow

Please see #15.

I'm sorry, I think I figured out how to change and not produce commits. This is my first pull request for a large project

Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same behavior can be achieved by setting Kconfig options in prj.conf.

@krip-tip
Copy link
Contributor Author

The same behavior can be achieved by setting Kconfig options in prj.conf.

This is if you define the standard options in Kconfig. But there are options that need to be written in lv_config.h so that the lvgl library itself can use them. For example, I have not found any other way to completely replace the standard fonts and use several of my fonts in my theme. All of this is simply solved by including an additional header file at the end.
And in the example from lvgl itself, the user's fonts are included in the configuration file.
it will be more difficult to implement the mechanism for connecting fonts via commands in Kconfig.
And in my program self-written lvgl objects are defined. which are also written to the settings file and collected together with the library.

@gmarull
Copy link
Member

gmarull commented Jun 24, 2021

The same behavior can be achieved by setting Kconfig options in prj.conf.

This is if you define the standard options in Kconfig. But there are options that need to be written in lv_config.h so that the lvgl library itself can use them. For example, I have not found any other way to completely replace the standard fonts and use several of my fonts in my theme. All of this is simply solved by including an additional header file at the end.
And in the example from lvgl itself, the user's fonts are included in the configuration file.
it will be more difficult to implement the mechanism for connecting fonts via commands in Kconfig.
And in my program self-written lvgl objects are defined. which are also written to the settings file and collected together with the library.

There is no need to add an extra header for custom fonts. The auto-generated C font files can be added to the application (target_sources(app PRIVATE my_font.c)) and then you can just use them using LV_FONT_DECLARE(my_font). You can create application level Kconfig options for custom fonts if needed.

@krip-tip
Copy link
Contributor Author

krip-tip commented Jun 25, 2021

The same behavior can be achieved by setting Kconfig options in prj.conf.

This is if you define the standard options in Kconfig. But there are options that need to be written in lv_config.h so that the lvgl library itself can use them. For example, I have not found any other way to completely replace the standard fonts and use several of my fonts in my theme. All of this is simply solved by including an additional header file at the end.
And in the example from lvgl itself, the user's fonts are included in the configuration file.
it will be more difficult to implement the mechanism for connecting fonts via commands in Kconfig.
And in my program self-written lvgl objects are defined. which are also written to the settings file and collected together with the library.

There is no need to add an extra header for custom fonts. The auto-generated C font files can be added to the application (target_sources(app PRIVATE my_font.c)) and then you can just use them using LV_FONT_DECLARE(my_font). You can create application level Kconfig options for custom fonts if needed.

I agree with the help of the specified definitions and the indication void * lv_theme_default_font_small_custom_ptr and others, I managed to connect my fonts.
But what cannot be done: connect CONFIG_LVGL_USE_THEME_CUSTOM.
Do you have an example?
defined:

CONFIG_LVGL_USE_THEME_CUSTOM = y
CONFIG_LVGL_THEME_CUSTOM_INIT_FUNCTION = "lv_theme_my_init"

but it fails to compile:

lv_conf.h: 280: 1: error: unknown type name 'lv_theme_t'
   280 | lv_theme_t * LVGL_THEME_CUSTOM_INIT_FUNCTION (

but if in lv_conf.h

#define LV_THEME_DEFAULT_FLAG 0
#define LV_THEME_DEFAULT_INCLUDE <lv_theme_my.h>
#define LV_THEME_DEFAULT_INIT lv_theme_my_init

everything compiles fine.

There is a proposal to modify the connection of a custom theme
I was unable to pass the name of the initialization function from Kconfig, since all text constants are always quoted there when they are passed to autoconf.h

@krip-tip
Copy link
Contributor Author

krip-tip commented Jun 25, 2021

and the custom theme through my proposal is connected as a hack, I do not type a custom theme and then redefined the variables :-(
this is not pretty, but it allows you to work until this case is thought out and implemented.

@gmarull
Copy link
Member

gmarull commented Jun 29, 2021

@oleg-krv you're right, the Kconfig custom options do not work (Kconfig options expand as a string). An issue should be opened to fix/remove that.

What I've done for custom themes in the past is:

  1. create a theme using something like https://github.com/lvgl/lvgl/blob/master/src/extra/themes/basic/lv_theme_basic.c
  2. Set the theme when app is started, ie
lv_theme_set_act(my_theme_init())

@krip-tip
Copy link
Contributor Author

@oleg-krv you're right, the Kconfig custom options do not work (Kconfig options expand as a string). An issue should be opened to fix/remove that.

What I've done for custom themes in the past is:

  1. create a theme using something like https://github.com/lvgl/lvgl/blob/master/src/extra/themes/basic/lv_theme_basic.c
  2. Set the theme when app is started, ie
lv_theme_set_act(my_theme_init())

This can be done, but how to remove the initialization of the standard theme so that it does not take up memory?

Alternative. Replace block:

#if CONFIG_LVGL_USE_THEME_CUSTOM

lv_theme_t *LVGL_THEME_CUSTOM_INIT_FUNCTION(
	lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags,
	const lv_font_t *font_small, const lv_font_t *font_normal,
	const lv_font_t *font_subtitle, const lv_font_t *font_title);

#define LV_THEME_DEFAULT_INIT LVGL_THEME_CUSTOM_INIT_FUNCTION

#endif

to this code:

#if CONFIG_LVGL_USE_THEME_CUSTOM

#define LV_THEME_DEFAULT_FLAG 0
#define LV_THEME_DEFAULT_INCLUDE  CONFIG_LVGL_CUSTOM_THEME_INCLUDE

#ifndef LV_THEME_DEFAULT_INIT
#error "Define LV_THEME_DEFAULT_INIT in CMake or custom theme header file. In the variable, specify the name of the custom theme initialization function."
#endif

#endif

also a hack, but more elegant :-)

@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Aug 30, 2021
@github-actions github-actions bot closed this Sep 13, 2021
@krip-tip krip-tip deleted the lib_lvgl_user_config branch October 19, 2021 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants