From 4db0071f05b6e046a8adae51700102fec451c9ad Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Sat, 24 Jul 2021 17:27:16 +0300 Subject: [PATCH] feat(obj) add lv_is_initialized (#2402) While it's possible to try initialize LVGL after it is already initialized, it warns 'lv_init: already inited' in such case. Therefore it is useful to be able to check on runtime whether LVGL was initialized or not before calling lv_init(). --- src/core/lv_obj.c | 5 +++++ src/core/lv_obj.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/core/lv_obj.c b/src/core/lv_obj.c index 4268be651..63d1f0989 100644 --- a/src/core/lv_obj.c +++ b/src/core/lv_obj.c @@ -84,6 +84,11 @@ const lv_obj_class_t lv_obj_class = { * GLOBAL FUNCTIONS **********************/ +bool lv_is_initialized(void) +{ + return lv_initialized; +} + void lv_init(void) { /*Do nothing if already initialized*/ diff --git a/src/core/lv_obj.h b/src/core/lv_obj.h index 79d542236..9c8846610 100644 --- a/src/core/lv_obj.h +++ b/src/core/lv_obj.h @@ -204,6 +204,11 @@ void lv_deinit(void); #endif +/** + * Returns whether the 'lv' library is currently initialized + */ +bool lv_is_initialized(void); + /** * Create a base object (a rectangle) * @param parent pointer to a parent object. If NULL then a screen will be created.