From 80834329257486c586756d6401006a09a8f2f8c2 Mon Sep 17 00:00:00 2001 From: Alexander Enchevich Date: Fri, 6 Jul 2018 16:29:45 +0300 Subject: [PATCH 1/2] fix compile errors related to USE_LV_ANIMATION --- lv_objx/lv_ddlist.c | 2 +- lv_objx/lv_page.c | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index a60ca725d..1d2687275 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -680,9 +680,9 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en) if(anim_en == 0) { lv_obj_set_height(ddlist, new_height); lv_ddlist_pos_current_option(ddlist); +#if USE_LV_ANIMATION lv_anim_del(ddlist, (lv_anim_fp_t)lv_obj_set_height); /*If an animation is in progress then it will overwrite this changes*/ } else { -#if USE_LV_ANIMATION lv_anim_t a; a.var = ddlist; a.start = lv_obj_get_height(ddlist); diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index 541435abe..d8352ab8a 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -285,13 +285,13 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time) { #if USE_LV_ANIMATION == 0 - anim_tiem = 0; -#endif - + anim_time = 0; +#else /* Be sure there is no position changing animation in progress * because it can overide the current changes*/ lv_anim_del(page, (lv_anim_fp_t)lv_obj_set_y); lv_anim_del(page, (lv_anim_fp_t)lv_obj_set_pos); +#endif lv_page_ext_t * ext = lv_obj_get_ext_attr(page); lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_BG); @@ -328,8 +328,8 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time) if(anim_time == 0) { lv_obj_set_y(ext->scrl, scrlable_y); - } else { #if USE_LV_ANIMATION + } else { lv_anim_t a; a.act_time = 0; a.start = lv_obj_get_y(ext->scrl); @@ -571,8 +571,6 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) #endif } } - - else if(sign == LV_SIGNAL_GET_TYPE) { lv_obj_type_t * buf = param; uint8_t i; From 70d5e5a012ad76698381638bfea365e06b599957 Mon Sep 17 00:00:00 2001 From: Alexander Enchevich Date: Fri, 6 Jul 2018 17:12:06 +0300 Subject: [PATCH 2/2] Code formatting --- lv_objx/lv_page.c | 86 ++++++++++++++++++++++----------------------- lv_objx/lv_roller.c | 4 +-- 2 files changed, 44 insertions(+), 46 deletions(-) diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index d8352ab8a..daeebed33 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -21,7 +21,7 @@ * DEFINES *********************/ #define LV_PAGE_SB_MIN_SIZE (LV_DPI / 8) -#define LV_PAGE_GROUP_SCROLL_ANIM_TIME 200 +#define LV_PAGE_GROUP_SCROLL_ANIM_TIME 200 /********************** * TYPEDEFS @@ -285,12 +285,12 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time) { #if USE_LV_ANIMATION == 0 - anim_time = 0; + anim_time = 0; #else - /* Be sure there is no position changing animation in progress - * because it can overide the current changes*/ - lv_anim_del(page, (lv_anim_fp_t)lv_obj_set_y); - lv_anim_del(page, (lv_anim_fp_t)lv_obj_set_pos); + /* Be sure there is no position changing animation in progress + * because it can overide the current changes*/ + lv_anim_del(page, (lv_anim_fp_t)lv_obj_set_y); + lv_anim_del(page, (lv_anim_fp_t)lv_obj_set_pos); #endif lv_page_ext_t * ext = lv_obj_get_ext_attr(page); @@ -527,51 +527,49 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) if(page->ext_size < (-ext->sb.style->body.padding.hor)) page->ext_size = -ext->sb.style->body.padding.hor; if(page->ext_size < (-ext->sb.style->body.padding.ver)) page->ext_size = -ext->sb.style->body.padding.ver; } else if(sign == LV_SIGNAL_CONTROLL) { - uint32_t c = *((uint32_t *) param); - lv_obj_t * scrl = lv_page_get_scrl(page); - if(c == LV_GROUP_KEY_DOWN || c == LV_GROUP_KEY_RIGHT) { + uint32_t c = *((uint32_t *) param); + lv_obj_t * scrl = lv_page_get_scrl(page); + if(c == LV_GROUP_KEY_DOWN || c == LV_GROUP_KEY_RIGHT) { #if USE_LV_ANIMATION - lv_anim_t a; - a.var = scrl; - a.start = lv_obj_get_y(scrl); - a.end = a.start - LV_DPI / 2; - a.fp = (lv_anim_fp_t)lv_obj_set_y; - a.path = lv_anim_path_linear; - a.end_cb = NULL; - a.act_time = 0; - a.time = LV_PAGE_GROUP_SCROLL_ANIM_TIME; - a.playback = 0; - a.playback_pause = 0; - a.repeat = 0; - a.repeat_pause = 0; - lv_anim_create(&a); + lv_anim_t a; + a.var = scrl; + a.start = lv_obj_get_y(scrl); + a.end = a.start - LV_DPI / 2; + a.fp = (lv_anim_fp_t)lv_obj_set_y; + a.path = lv_anim_path_linear; + a.end_cb = NULL; + a.act_time = 0; + a.time = LV_PAGE_GROUP_SCROLL_ANIM_TIME; + a.playback = 0; + a.playback_pause = 0; + a.repeat = 0; + a.repeat_pause = 0; + lv_anim_create(&a); #else - lv_obj_set_y(scrl, lv_obj_get_y(scrl) - LV_DPI / 2); + lv_obj_set_y(scrl, lv_obj_get_y(scrl) - LV_DPI / 2); #endif - } - else if(c == LV_GROUP_KEY_UP || c == LV_GROUP_KEY_LEFT) { + } else if(c == LV_GROUP_KEY_UP || c == LV_GROUP_KEY_LEFT) { #if USE_LV_ANIMATION - lv_anim_t a; - a.var = scrl; - a.start = lv_obj_get_y(scrl); - a.end = a.start + LV_DPI / 2; - a.fp = (lv_anim_fp_t)lv_obj_set_y; - a.path = lv_anim_path_linear; - a.end_cb = NULL; - a.act_time = 0; - a.time = LV_PAGE_GROUP_SCROLL_ANIM_TIME; - a.playback = 0; - a.playback_pause = 0; - a.repeat = 0; - a.repeat_pause = 0; - lv_anim_create(&a); + lv_anim_t a; + a.var = scrl; + a.start = lv_obj_get_y(scrl); + a.end = a.start + LV_DPI / 2; + a.fp = (lv_anim_fp_t)lv_obj_set_y; + a.path = lv_anim_path_linear; + a.end_cb = NULL; + a.act_time = 0; + a.time = LV_PAGE_GROUP_SCROLL_ANIM_TIME; + a.playback = 0; + a.playback_pause = 0; + a.repeat = 0; + a.repeat_pause = 0; + lv_anim_create(&a); #else - lv_obj_set_y(scrl, lv_obj_get_y(scrl) - LV_DPI / 2); + lv_obj_set_y(scrl, lv_obj_get_y(scrl) - LV_DPI / 2); #endif - } - } - else if(sign == LV_SIGNAL_GET_TYPE) { + } + } else if(sign == LV_SIGNAL_GET_TYPE) { lv_obj_type_t * buf = param; uint8_t i; for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/ diff --git a/lv_objx/lv_roller.c b/lv_objx/lv_roller.c index c23db3576..3c3a909f0 100644 --- a/lv_objx/lv_roller.c +++ b/lv_objx/lv_roller.c @@ -228,7 +228,7 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig lv_coord_t font_h = lv_font_get_height(font); lv_area_t rect_area; rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.line_space / 2; - if((font_h & 0x1) && (style->text.line_space & 0x1)) rect_area.y1 --; /*Compensate the two rounding error*/ + if((font_h & 0x1) && (style->text.line_space & 0x1)) rect_area.y1 --; /*Compensate the two rounding error*/ rect_area.y2 = rect_area.y1 + font_h + style->text.line_space - 1; rect_area.x1 = roller->coords.x1; rect_area.x2 = roller->coords.x2; @@ -245,7 +245,7 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig /*Redraw the text on the selected area with a different color*/ lv_area_t rect_area; rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.line_space / 2; - if((font_h & 0x1) && (style->text.line_space & 0x1)) rect_area.y1 --; /*Compensate the two rounding error*/ + if((font_h & 0x1) && (style->text.line_space & 0x1)) rect_area.y1 --; /*Compensate the two rounding error*/ rect_area.y2 = rect_area.y1 + font_h + style->text.line_space - 1; rect_area.x1 = roller->coords.x1; rect_area.x2 = roller->coords.x2;