From 13f75de6ee9630b4c50252a168ff509a4d98aef6 Mon Sep 17 00:00:00 2001 From: Kiss-Vamosi Gabor Date: Fri, 3 Feb 2017 21:48:13 +0100 Subject: [PATCH] lv_app_notice: max notice num added --- lv_app/lv_app_util/lv_app_notice.c | 20 ++++++++++++++++++++ lv_conf_temp.h | 1 + 2 files changed, 21 insertions(+) diff --git a/lv_app/lv_app_util/lv_app_notice.c b/lv_app/lv_app_util/lv_app_notice.c index bb9d1d57a..b0e03e3d5 100644 --- a/lv_app/lv_app_util/lv_app_notice.c +++ b/lv_app/lv_app_util/lv_app_notice.c @@ -18,6 +18,18 @@ /********************* * DEFINES *********************/ +/*Add the required configurations*/ +#ifndef LV_APP_NOTICE_SHOW_TIME +#define LV_APP_NOTICE_SHOW_TIME 4000 +#endif + +#ifndef LV_APP_NOTICE_MAX_NUM +#define LV_APP_NOTICE_MAX_NUM 6 +#endif + +#ifndef LV_APP_NOTICE_MAX_LEN +#define LV_APP_NOTICE_MAX_LEN 256 +#endif /********************** * TYPEDEFS @@ -81,6 +93,14 @@ lv_obj_t * lv_app_notice_add(const char * format, ...) lv_mbox_start_auto_close(mbox, LV_APP_NOTICE_SHOW_TIME); #endif + /*Delete the last children if there are too many*/ + uint32_t child_num = lv_obj_get_child_num(notice_h); + if(child_num > LV_APP_NOTICE_MAX_NUM) { + lv_obj_t * last_child = ll_get_tail(¬ice_h->child_ll); + lv_obj_del(last_child); + } + + /*make sure the notices are on the top*/ lv_obj_set_parent(notice_h, lv_scr_act()); return mbox; diff --git a/lv_conf_temp.h b/lv_conf_temp.h index 7568c4bca..d034ec0d8 100644 --- a/lv_conf_temp.h +++ b/lv_conf_temp.h @@ -194,6 +194,7 @@ /* App. utility settings */ #define LV_APP_NOTICE_SHOW_TIME 4000 /*Notices will be shown for this time [ms]*/ +#define LV_APP_NOTICE_MAX_NUM 6 /*Max. number of notices*/ #define LV_APP_NOTICE_MAX_LEN 256 /*Max. number of characters on a notice*/ /*================== * LV APP X USAGE