diff --git a/lv_app/lv_app.h b/lv_app/lv_app.h index c2f94300a..5d44ea6f6 100644 --- a/lv_app/lv_app.h +++ b/lv_app/lv_app.h @@ -21,6 +21,14 @@ /********************* * DEFINES *********************/ +/*Check dependencies*/ +#if LV_OBJ_FREE_P == 0 +#error "lv_app: Free pointer is required for application. Enable it lv_conf.h: LV_OBJ_FREE_P 1" +#endif + +#if DM_CUSTOM == 0 && DM_MEM_SIZE < (2 * 1024) +#error "lv_app: not enough dynamic memory. Increase it in misc_conf.h: DM_MEM_SIZE" +#endif /********************** * TYPEDEFS diff --git a/lv_app/lv_app_util/lv_app_fsel.c b/lv_app/lv_app_util/lv_app_fsel.c index 0594613d0..1a41bbea9 100644 --- a/lv_app/lv_app_util/lv_app_fsel.c +++ b/lv_app/lv_app_util/lv_app_fsel.c @@ -7,7 +7,7 @@ * INCLUDES *********************/ #include "lv_app_fsel.h" -#if LV_APP_ENABLE != 0 +#if USE_LV_APP_FSEL != 0 #include #include "lv_app_notice.h" @@ -15,9 +15,6 @@ /********************* * DEFINES *********************/ -#define LV_APP_FSEL_FN_MAX_LEN 128 -#define LV_APP_FSEL_PATH_MAX_LEN 256 -#define LV_APP_FSEL_PAGE_SIZE 8 /********************** * TYPEDEFS diff --git a/lv_app/lv_app_util/lv_app_fsel.h b/lv_app/lv_app_util/lv_app_fsel.h index 4c9be142a..efba70b88 100644 --- a/lv_app/lv_app_util/lv_app_fsel.h +++ b/lv_app/lv_app_util/lv_app_fsel.h @@ -10,11 +10,24 @@ * INCLUDES *********************/ #include "../lv_app.h" -#if LV_APP_ENABLE != 0 +#if USE_LV_APP_FSEL != 0 /********************* * DEFINES *********************/ +/*Add the required configurations*/ +#ifndef LV_APP_FSEL_FN_MAX_LEN +#define LV_APP_FSEL_FN_MAX_LEN 128 +#endif + +#ifndef LV_APP_FSEL_PATH_MAX_LEN +#define LV_APP_FSEL_PATH_MAX_LEN 256 +#endif + +#ifndef LV_APP_FSEL_PAGE_SIZE +#define LV_APP_FSEL_PAGE_SIZE 8 +#endif + /********************** * TYPEDEFS diff --git a/lv_app/lv_app_util/lv_app_kb.c b/lv_app/lv_app_util/lv_app_kb.c index 5558b959c..256897778 100644 --- a/lv_app/lv_app_util/lv_app_kb.c +++ b/lv_app/lv_app_util/lv_app_kb.c @@ -7,7 +7,7 @@ * INCLUDES *********************/ #include "lv_app_kb.h" -#if LV_APP_ENABLE != 0 +#if USE_LV_APP_KB != 0 #include "lvgl/lv_objx/lv_btnm.h" #include "lvgl/lv_objx/lv_ta.h" diff --git a/lv_app/lv_app_util/lv_app_kb.h b/lv_app/lv_app_util/lv_app_kb.h index 1eb4631da..bf0d48031 100644 --- a/lv_app/lv_app_util/lv_app_kb.h +++ b/lv_app/lv_app_util/lv_app_kb.h @@ -10,7 +10,7 @@ * INCLUDES *********************/ #include "../lv_app.h" -#if LV_APP_ENABLE != 0 +#if USE_LV_APP_KB != 0 /********************* * DEFINES diff --git a/lv_app/lv_app_util/lv_app_notice.c b/lv_app/lv_app_util/lv_app_notice.c index 3d649a199..12326e670 100644 --- a/lv_app/lv_app_util/lv_app_notice.c +++ b/lv_app/lv_app_util/lv_app_notice.c @@ -7,7 +7,7 @@ * INCLUDES *********************/ #include "lv_app_notice.h" -#if LV_APP_ENABLE != 0 +#if USE_LV_APP_NOTICE != 0 #include #include "lvgl/lv_objx/lv_label.h" @@ -18,23 +18,6 @@ /********************* * DEFINES *********************/ -/*Add the required configurations*/ -#ifndef LV_APP_NOTICE_SHOW_TIME -#define LV_APP_NOTICE_SHOW_TIME 4000 -#endif - -#ifndef LV_APP_NOTICE_CLOSE_ANIM_TIME -#define LV_APP_NOTICE_CLOSE_ANIM_TIME 300 -#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 diff --git a/lv_app/lv_app_util/lv_app_notice.h b/lv_app/lv_app_util/lv_app_notice.h index 2dc25b815..7c2eaca5a 100644 --- a/lv_app/lv_app_util/lv_app_notice.h +++ b/lv_app/lv_app_util/lv_app_notice.h @@ -11,11 +11,28 @@ *********************/ #include "../lv_app.h" #include -#if LV_APP_ENABLE != 0 +#if USE_LV_APP_NOTICE != 0 /********************* * DEFINES *********************/ +/*Add the required configurations*/ +#ifndef LV_APP_NOTICE_SHOW_TIME +#define LV_APP_NOTICE_SHOW_TIME 4000 +#endif + +#ifndef LV_APP_NOTICE_CLOSE_ANIM_TIME +#define LV_APP_NOTICE_CLOSE_ANIM_TIME 300 +#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 diff --git a/lv_draw/lv_draw.c b/lv_draw/lv_draw.c index b3e9ce856..8b5c8a1e9 100644 --- a/lv_draw/lv_draw.c +++ b/lv_draw/lv_draw.c @@ -283,7 +283,7 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_style_ if(txt[i] == ' ') { /*Get the parameter*/ if(i - par_start == LABEL_RECOLOR_PAR_LENGTH) { - char buf[LABEL_RECOLOR_PAR_LENGTH]; + char buf[LABEL_RECOLOR_PAR_LENGTH + 1]; memcpy(buf, &txt[par_start], LABEL_RECOLOR_PAR_LENGTH); buf[LABEL_RECOLOR_PAR_LENGTH] = '\0'; int r,g,b; diff --git a/lv_obj/lv_obj.c b/lv_obj/lv_obj.c index 7da18e76e..78236ccc0 100644 --- a/lv_obj/lv_obj.c +++ b/lv_obj/lv_obj.c @@ -7,13 +7,14 @@ * INCLUDES *********************/ -#include -#include -#include -#include -#include -#include +#include "lv_conf.h" +#include "lvgl/lv_draw/lv_draw.h" +#include "lvgl/lv_obj/lv_dispi.h" +#include "lvgl/lv_obj/lv_obj.h" +#include "lvgl/lv_obj/lv_refr.h" +#include "lvgl/lv_app/lv_app.h" #include "lvgl/lv_draw/lv_draw_rbasic.h" +#include "misc/gfx/anim.h" #include #include #include @@ -138,7 +139,9 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy) lv_obj_set_design_f(new_obj, lv_obj_design); /*Set free data*/ +#if LV_OBJ_FREE_NUM != 0 new_obj->free_num = 0; +#endif #if LV_OBJ_FREE_P != 0 new_obj->free_p = NULL; #endif @@ -179,7 +182,9 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy) lv_obj_set_design_f(new_obj, lv_obj_design); /*Set free data*/ +#if LV_OBJ_FREE_NUM != 0 new_obj->free_num = 0; +#endif #if LV_OBJ_FREE_P != 0 new_obj->free_p = NULL; #endif @@ -202,7 +207,9 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy) new_obj->ext_size = copy->ext_size; /*Set free data*/ +#if LV_OBJ_FREE_NUM != 0 new_obj->free_num = copy->free_num; +#endif #if LV_OBJ_FREE_P != 0 new_obj->free_p = copy->free_p; #endif diff --git a/lv_objx/lv_label.c b/lv_objx/lv_label.c index bcb732ac8..0e61d5d58 100644 --- a/lv_objx/lv_label.c +++ b/lv_objx/lv_label.c @@ -602,7 +602,7 @@ static void lv_label_refr_text(lv_obj_t * label) ext->dot_tmp[i] = ext->txt[index - LV_LABEL_DOT_NUM + i]; ext->txt[index - LV_LABEL_DOT_NUM + i] = '.'; } - /*The last character is '\0'*/ + /*The last character is '\0'. Save this character from the text too.*/ ext->dot_tmp[i] = ext->txt[index]; ext->txt[index] = '\0'; } diff --git a/lv_objx/lv_label.h b/lv_objx/lv_label.h index 94fd1315c..f027787a0 100644 --- a/lv_objx/lv_label.h +++ b/lv_objx/lv_label.h @@ -41,7 +41,7 @@ typedef struct /*New data for this type */ char * txt; /*Text of the label*/ lv_label_long_mode_t long_mode; /*Determinate what to do with the long texts*/ - char dot_tmp[LV_LABEL_DOT_NUM]; /*Store the character which are replaced by dots (Handled by the library)*/ + char dot_tmp[LV_LABEL_DOT_NUM + 1]; /*Store the character which are replaced by dots (Handled by the library)*/ uint16_t dot_end; /*The text end position in dot mode (Handled by the library)*/ uint8_t static_txt :1; /*Flag to indicate the text is static*/ uint8_t recolor :1; /*Enable in-line letter re-coloring*/ diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index 41cc6a442..6e8ffe4f6 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -428,8 +428,6 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time) cord_t scrlable_y = lv_obj_get_y(ext->scrl); cord_t page_h = lv_obj_get_height(page); - bool refr = false; - cord_t top_err = -(scrlable_y + obj_y); cord_t bot_err = scrlable_y + obj_y + obj_h - page_h; @@ -440,7 +438,6 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time) /*Calculate a new position and to let scrable_rects.vpad space above*/ scrlable_y = -(obj_y - style_scrl->vpad - style->vpad); scrlable_y += style_scrl->vpad; - refr = true; } /*Out of the page on the bottom*/ else if((obj_h <= page_h && bot_err > 0) || @@ -449,7 +446,9 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time) scrlable_y = -obj_y; scrlable_y += page_h - obj_h; scrlable_y -= style_scrl->vpad; - refr = true; + } else { + /*Alraedy in focus*/ + return; } if(anim_time == 0) {