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

lv_examples: Add Kconfig to lv_examples and choose an example to run on the menuconfig interface #196

Merged
merged 5 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions components/lv_examples/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Kconfig for lv_examples v7.4.0

menu "lv_examples configuration"

config LV_EX_PRINTF
bool "Enable printf-ing data in demos and examples."

choice LV_EX_CHOICE
prompt "Select the demo you want to run."
default LV_USE_DEMO_WIDGETS

config LV_USE_DEMO_WIDGETS
bool "Show demo widgets."

config LV_DEMO_WIDGETS_SLIDESHOW
bool "Slide demo widgets automatically."
depends on LV_USE_DEMO_WIDGETS
default y

config LV_USE_DEMO_KEYPAD_AND_ENCODER
bool "Demonstrate the usage of encoder and keyboard."

config LV_USE_DEMO_BENCHMARK
bool "Benchmark your system."

config LV_USE_DEMO_STRESS
bool "Stress test for LVGL."
endchoice
endmenu
12 changes: 6 additions & 6 deletions components/lv_examples/lv_ex_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/*******************
* GENERAL SETTING
*******************/
#define LV_EX_PRINTF 1 /*Enable printf-ing data in demoes and examples*/
#define LV_EX_PRINTF CONFIG_LV_EX_PRINTF /*Enable printf-ing data in demoes and examples*/
Copy link
Member

Choose a reason for hiding this comment

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

(This applies to all the changes in lv_ex_conf.h.)

As far as I know, Kconfig does not define unselected options to 0; it just doesn't define them at all. I'm not sure how the statement #if LV_EX_PRINTF will be affected by this. It might be better to use a code pattern like this:

Suggested change
#define LV_EX_PRINTF CONFIG_LV_EX_PRINTF /*Enable printf-ing data in demoes and examples*/
/*Enable printf-ing data in demoes and examples*/
#ifdef CONFIG_LV_EX_PRINTF
#define LV_EX_PRINTF 1
#else
#define LV_EX_PRINTF 0
#endif

Copy link
Collaborator Author

@C47D C47D Sep 9, 2020

Choose a reason for hiding this comment

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

You're totally right @embeddedt, I forgot about that, will commit your suggestion. I think the same applies for the other choice symbols (demo to run), isn't?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure but I think we would need to include the ESP-IDFs sdkconfig.h file to be able to use the CONFIG_x symbols. I will try removing that include on the current lv_config file and see what happens.

Copy link
Member

Choose a reason for hiding this comment

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

If it's needed we can use LV_CONF_PATH to include any file instead of lv_conf.h.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice, I will test it too, yesterday I forgot to push the fixes for @embeddedt comment, will do it later.

#define LV_EX_KEYBOARD 0 /*Add PC keyboard support to some examples (`lv_drivers` repository is required)*/
#define LV_EX_MOUSEWHEEL 0 /*Add 'encoder' (mouse wheel) support to some examples (`lv_drivers` repository is required)*/

Expand All @@ -25,22 +25,22 @@
*********************/

/*Show some widget*/
#define LV_USE_DEMO_WIDGETS 1
#define LV_USE_DEMO_WIDGETS CONFIG_LV_USE_DEMO_WIDGETS
#if LV_USE_DEMO_WIDGETS
#define LV_DEMO_WIDGETS_SLIDESHOW 1
#define LV_DEMO_WIDGETS_SLIDESHOW CONFIG_LV_DEMO_WIDGETS_SLIDESHOW
#endif

/*Printer demo, optimized for 800x480*/
#define LV_USE_DEMO_PRINTER 0

/*Demonstrate the usage of encoder and keyboard*/
#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0
#define LV_USE_DEMO_KEYPAD_AND_ENCODER CONFIG_LV_USE_DEMO_KEYPAD_AND_ENCODER

/*Benchmark your system*/
#define LV_USE_DEMO_BENCHMARK 0
#define LV_USE_DEMO_BENCHMARK CONFIG_LV_USE_DEMO_BECHMARK

/*Stress test for LVGL*/
#define LV_USE_DEMO_STRESS 0
#define LV_USE_DEMO_STRESS CONFIG_LV_USE_DEMO_STRESS

#endif /*LV_EX_CONF_H*/

Expand Down
27 changes: 24 additions & 3 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,17 @@
#include "lvgl_helpers.h"

#ifndef CONFIG_LVGL_TFT_DISPLAY_MONOCHROME
#include "lv_examples/src/lv_demo_widgets/lv_demo_widgets.h"
#if defined CONFIG_LV_USE_DEMO_WIDGETS
#include "lv_examples/src/lv_demo_widgets/lv_demo_widgets.h"
#elif defined CONFIG_LV_DEMO_KEYPAD_AND_ENCODER
#include "lv_examples/src/lv_demo_keypad_and_encoder/lv_demo_keyoad_and_encoder.h"
#elif defined CONFIG_LV_DEMO_BENCHMARK
#include "lv_examples/src/lv_demo_benchmark/lv_demo_benchmark.h"
#elif defined CONFIG_LV_DEMO_STRESS
#include "lv_examples/src/lv_demo_stress/lv_demo_stress.h"
#else
#error "No demo application selected."
#endif
#endif

/*********************
Expand Down Expand Up @@ -164,8 +174,19 @@ static void create_demo_application(void)
* 0, 0 at the end means an x, y offset after alignment*/
lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, 0);
#else
/* TODO: Otherwise we show the selected demo */
lv_demo_widgets();
/* Otherwise we show the selected demo */

#if defined CONFIG_LV_USE_DEMO_WIDGETS
lv_demo_widgets();
#elif defined CONFIG_LV_DEMO_KEYPAD_AND_ENCODER
lv_demo_keypad_encoder();
#elif defined CONFIG_LV_DEMO_BENCHMARK
lv_demo_benchmark();
#elif defined CONFIG_LV_DEMO_STRESS
lv_demo_stress();
#else
#error "No demo application selected."
#endif
#endif
}

Expand Down