From ec1a78d4c7a25d79e38197cdfc513efe4724c0ec Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Tue, 22 Feb 2022 09:44:30 +0100 Subject: [PATCH 1/1] widgets: make dependencies internal handling consistent when using Kconfig --- src/lv_conf_internal.h | 72 ++++++++++++++++++++++++++++++----------- src/widgets/lv_img.h | 5 +++ src/widgets/lv_roller.h | 5 +++ 3 files changed, 64 insertions(+), 18 deletions(-) diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 456c7284..a07b51bb 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -597,15 +597,23 @@ /*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 CONFIG_LV_USE_ASSERT_NULL - #define LV_USE_ASSERT_NULL CONFIG_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 CONFIG_LV_USE_ASSERT_MALLOC - #define LV_USE_ASSERT_MALLOC CONFIG_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 @@ -1341,16 +1349,24 @@ #endif #ifndef LV_USE_DROPDOWN - #ifdef CONFIG_LV_USE_DROPDOWN - #define LV_USE_DROPDOWN CONFIG_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 CONFIG_LV_USE_IMG - #define LV_USE_IMG CONFIG_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 @@ -1369,15 +1385,23 @@ #endif #if LV_USE_LABEL #ifndef LV_LABEL_TEXT_SELECTION - #ifdef CONFIG_LV_LABEL_TEXT_SELECTION - #define LV_LABEL_TEXT_SELECTION CONFIG_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 CONFIG_LV_LABEL_LONG_TXT_HINT - #define LV_LABEL_LONG_TXT_HINT CONFIG_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 @@ -1397,8 +1421,12 @@ #endif #ifndef LV_USE_ROLLER - #ifdef CONFIG_LV_USE_ROLLER - #define LV_USE_ROLLER CONFIG_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 @@ -1414,8 +1442,12 @@ #endif #ifndef LV_USE_SLIDER - #ifdef CONFIG_LV_USE_SLIDER - #define LV_USE_SLIDER CONFIG_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 @@ -1434,8 +1466,12 @@ #endif #ifndef LV_USE_TEXTAREA - #ifdef CONFIG_LV_USE_TEXTAREA - #define LV_USE_TEXTAREA CONFIG_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 diff --git a/src/widgets/lv_img.h b/src/widgets/lv_img.h index 2a005643..9068c50e 100644 --- a/src/widgets/lv_img.h +++ b/src/widgets/lv_img.h @@ -17,6 +17,11 @@ extern "C" { #if LV_USE_IMG != 0 +/*Testing of dependencies*/ +#if LV_USE_LABEL == 0 +#error "lv_img: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1)" +#endif + #include "../core/lv_obj.h" #include "../misc/lv_fs.h" #include "../draw/lv_draw.h" diff --git a/src/widgets/lv_roller.h b/src/widgets/lv_roller.h index d90001d9..14411dea 100644 --- a/src/widgets/lv_roller.h +++ b/src/widgets/lv_roller.h @@ -17,6 +17,11 @@ extern "C" { #if LV_USE_ROLLER != 0 +/*Testing of dependencies*/ +#if LV_USE_LABEL == 0 +#error "lv_roller: lv_label is required. Enable it in lv_conf.h (LV_USE_ROLLER 1)" +#endif + #include "../core/lv_obj.h" #include "lv_label.h" -- 2.32.0