From 0fdfa32d4a77ce5ae7b396161d9bc3cd14d972b8 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 9 Oct 2018 17:29:12 +0200 Subject: [PATCH 01/23] set version number --- lvgl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lvgl.h b/lvgl.h index 6e74d53fa..3f3084c81 100644 --- a/lvgl.h +++ b/lvgl.h @@ -61,9 +61,9 @@ extern "C" { *********************/ /*Current version of LittlevGL*/ #define LVGL_VERSION_MAJOR 5 -#define LVGL_VERSION_MINOR 2 +#define LVGL_VERSION_MINOR 3 #define LVGL_VERSION_PATCH 0 -#define LVGL_VERSION_INFO "rc" +#define LVGL_VERSION_INFO "" /********************** * TYPEDEFS From b6b77f4b456e832504cf7ac364f4c456a5eb5bb3 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 11 Oct 2018 14:23:03 +0200 Subject: [PATCH 02/23] lv_img_color_format_get_px_size fix for true color apha format --- lv_draw/lv_draw_img.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lv_draw/lv_draw_img.c b/lv_draw/lv_draw_img.c index 6fe95fe15..0f7fa5153 100644 --- a/lv_draw/lv_draw_img.c +++ b/lv_draw/lv_draw_img.c @@ -155,7 +155,7 @@ uint8_t lv_img_color_format_get_px_size(lv_img_cf_t cf) case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED: return LV_COLOR_SIZE; case LV_IMG_CF_TRUE_COLOR_ALPHA: - return LV_IMG_PX_SIZE_ALPHA_BYTE; + return LV_IMG_PX_SIZE_ALPHA_BYTE << 3; case LV_IMG_CF_INDEXED_1BIT: case LV_IMG_CF_ALPHA_1BIT: @@ -469,6 +469,7 @@ static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t decoder_header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA || decoder_header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) { uint32_t pos = ((y * decoder_header.w + x) * px_size) >> 3; + pos += 4; /*Skip the header*/ res = lv_fs_seek(&decoder_file, pos); if(res != LV_FS_RES_OK) { LV_LOG_WARN("Built-in image decoder seek failed"); From 0ee104d155b1e416dde827ef6126033487236528 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 12 Oct 2018 09:09:10 +0200 Subject: [PATCH 03/23] lv_btnm: ignore clicks on inactive buttons --- lv_objx/lv_btnm.c | 53 ++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/lv_objx/lv_btnm.c b/lv_objx/lv_btnm.c index c5f609213..38f011091 100644 --- a/lv_objx/lv_btnm.c +++ b/lv_objx/lv_btnm.c @@ -547,45 +547,42 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) } } else if(sign == LV_SIGNAL_RELEASED) { if(ext->btn_id_pr != LV_BTNM_PR_NONE) { - if(ext->action) { - uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr); - if(txt_i != LV_BTNM_PR_NONE && button_is_inactive(ext->map_p[txt_i]) == false) { - ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i])); - } - } + uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr); + if(button_is_inactive(ext->map_p[txt_i]) == false && txt_i != LV_BTNM_PR_NONE) { /*Ignore the inactive buttons anf click between the buttons*/ + if(ext->action)ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i])); - /*Invalidate to old pressed area*/; - lv_obj_get_coords(btnm, &btnm_area); - lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_pr]); - btn_area.x1 += btnm_area.x1; - btn_area.y1 += btnm_area.y1; - btn_area.x2 += btnm_area.x1; - btn_area.y2 += btnm_area.y1; - lv_inv_area(&btn_area); - - if(ext->toggle != 0) { - /*Invalidate to old toggled area*/; - lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_tgl]); + /*Invalidate to old pressed area*/; + lv_obj_get_coords(btnm, &btnm_area); + lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_pr]); btn_area.x1 += btnm_area.x1; btn_area.y1 += btnm_area.y1; btn_area.x2 += btnm_area.x1; btn_area.y2 += btnm_area.y1; lv_inv_area(&btn_area); - ext->btn_id_tgl = ext->btn_id_pr; - } + if(ext->toggle != 0) { + /*Invalidate to old toggled area*/; + lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_tgl]); + btn_area.x1 += btnm_area.x1; + btn_area.y1 += btnm_area.y1; + btn_area.x2 += btnm_area.x1; + btn_area.y2 += btnm_area.y1; + lv_inv_area(&btn_area); + ext->btn_id_tgl = ext->btn_id_pr; + } - -#if USE_LV_GROUP - /*Leave the clicked button as pressed if this the focused object in a group*/ - lv_group_t * g = lv_obj_get_group(btnm); - if(lv_group_get_focused(g) != btnm) { + #if USE_LV_GROUP + /*Leave the clicked button as pressed if this the focused object in a group*/ + lv_group_t * g = lv_obj_get_group(btnm); + if(lv_group_get_focused(g) != btnm) { + ext->btn_id_pr = LV_BTNM_PR_NONE; + } + #else ext->btn_id_pr = LV_BTNM_PR_NONE; + #endif + } -#else - ext->btn_id_pr = LV_BTNM_PR_NONE; -#endif } } else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) { ext->btn_id_pr = LV_BTNM_PR_NONE; From fe24ce53b71930e04f3c78ef6a6583b759f82bab Mon Sep 17 00:00:00 2001 From: Brian Pugh Date: Fri, 12 Oct 2018 09:35:46 -0700 Subject: [PATCH 04/23] initial bdf font converter --- utils/bdf_font_converter.py | 203 ++++++++++++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 utils/bdf_font_converter.py diff --git a/utils/bdf_font_converter.py b/utils/bdf_font_converter.py new file mode 100644 index 000000000..53574ca10 --- /dev/null +++ b/utils/bdf_font_converter.py @@ -0,0 +1,203 @@ +#!/user/bin/env python + +''' +Small utility that converts 1bpp BDF fonts to a font compatible with littlevgl +''' + +# General imports +import argparse +import math + + +class Glyph: + def __init__(self, props ): + for k, v in props.items(): + setattr(self, k, v) + + def __lt__(self, other): + return self.encoding < other.encoding + + def get_width(self): + return self.dwidth[0] + + def get_byte_width(self): + # Compute how many bytes wide the glyph will be + return math.ceil(self.dwidth[0] / 8.0) + + def get_height(self): + return len(self.bitmap) + + def get_encoding(self): + return self.encoding + + def write_bitmap(self, f): + f.write('''/*Unicode: U+%04x ( %s ) , Width: %d */\n''' % + (self.encoding, self.name, self.dwidth[0]) ) + for line in self.bitmap: + for i in range(0, len(line), 2): + f.write("0x%s," % line[i:i+2]) + if(i > 0): + f.write(" ") + f.write("\n") + f.write("\n\n") + +def parse_bdf(fn): + # Converts bdf file to a list of Glyphs + # Read in BDF File + with open(fn, "r") as f: + bdf = f.readlines() + bdf = [x.rstrip("\n") for x in bdf] + + # Iterate through BDF Glyphs + glyphs = [] + i = -1 + while i < len(bdf): + props = {} + + i += 1 + tokens = bdf[i].split(' ') + if tokens[0] == 'ENDFONT': + break; + if tokens[0] != "STARTCHAR": + continue + props['name'] = tokens[1] + + i += 1 + tokens = bdf[i].split(' ') + if tokens[0] != "ENCODING": + continue + encoding = int(tokens[-1]) + if encoding < 0: # skip glyphs with a negative encoding value + continue + props['encoding'] = encoding + + i += 1 + tokens = bdf[i].split(' ') + if tokens[0] != "SWIDTH": + continue + props['swidth'] = (int(tokens[1]), int(tokens[2])) + + i += 1 + tokens = bdf[i].split(' ') + if tokens[0] != "DWIDTH": + continue + props['dwidth'] = (int(tokens[1]), int(tokens[2])) + + i += 1 + tokens = bdf[i].split(' ') + if tokens[0] != "BBX": + continue + props['dwidth'] = (int(tokens[1]), int(tokens[2]), + int(tokens[3]), int(tokens[4])) + + i += 1 + tokens = bdf[i].split(' ') + if tokens[0] != "BITMAP": + continue + + props['bitmap'] = [] + while True: + i += 1 + tokens = bdf[i].split(' ') + if tokens[0] == 'ENDCHAR': + break + props['bitmap'].append(tokens[0]) + glyphs.append(Glyph(props)) + return glyphs + +def parse_args(): + ''' Parse CLI arguments into an object and a dictionary ''' + parser = argparse.ArgumentParser() + parser.add_argument('bdf_fn', type=str, default='imgs', + help='Directory containing all the PNGs') + parser.add_argument('font_name', type=str, default='font_name', + help='Name of the font') + parser.add_argument('--starting', type=int, default=61440, + help='Starting utf8 value') + args = parser.parse_args() + dargs = vars(args) + return (args, dargs) + +def main(): + args, dargs = parse_args() + + glyphs = parse_bdf(args.bdf_fn) + glyphs.sort() # Sorts by encoding (utf8) value + + ################ + # WRITE HEADER # + ################ + out = open(args.font_name + '.c', "w") + out.write(''' +#include "../lv_misc/lv_font.h" +''') + + ################# + # WRITE BITMAPS # + ################# + out.write( +''' +static const uint8_t %s_glyph_bitmap[] = +{ +''' % args.font_name) + + for glyph in glyphs: + glyph.write_bitmap(out) + + out.write(''' +}; +''') + + ###################### + # WRITE DESCRIPTIONS # + ###################### + out.write( +''' +/*Store the glyph descriptions*/ +static const lv_font_glyph_dsc_t %s_glyph_dsc[] = +{ +''' % args.font_name) + glyph_index = 0 + for glyph in glyphs: + out.write(''' +{.w_px = %d, .glyph_index = %d}, /*Unicode: U+%04x ( )*/ +''' % (glyph.get_width(), glyph_index, glyph.get_encoding()) ) + glyph_index += glyph.get_byte_width() * glyph.get_height() + + out.write(''' +}; +''') + + ##################### + # WRITE FONT STRUCT # + ##################### + out.write( +''' +lv_font_t %s = +{ + .unicode_first = %d, /*First Unicode letter in this font*/ + .unicode_last = %d, /*Last Unicode letter in this font*/ + .h_px = %d, /*Font height in pixels*/ + .glyph_bitmap = %s_glyph_bitmap, /*Bitmap of glyphs*/ + .glyph_dsc = %s_glyph_dsc, /*Description of glyphs*/ + .glyph_cnt = %d, /*Number of glyphs in the font*/ + .unicode_list = NULL, /*Every character in the font from 'unicode_first' to 'unicode_last'*/ + .get_bitmap = lv_font_get_bitmap_continuous, /*Function pointer to get glyph's bitmap*/ + .get_width = lv_font_get_width_continuous, /*Function pointer to get glyph's width*/ + .bpp = 1, /*Bit per pixel*/ + .monospace = 0, /*Fix width (0: if not used)*/ + .next_page = NULL, /*Pointer to a font extension*/ +}; +''' % (args.font_name, + glyphs[0].get_encoding(), + glyphs[-1].get_encoding(), + glyphs[0].get_height(), + args.font_name, + args.font_name, + len(glyphs), + ) ) + + out.close() + +if __name__=='__main__': + main() From 10dddd85c5213541f20f6aea49292388c3c8c495 Mon Sep 17 00:00:00 2001 From: Brian Pugh Date: Fri, 12 Oct 2018 09:38:31 -0700 Subject: [PATCH 05/23] Documentation update --- utils/bdf_font_converter.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/utils/bdf_font_converter.py b/utils/bdf_font_converter.py index 53574ca10..16935822e 100644 --- a/utils/bdf_font_converter.py +++ b/utils/bdf_font_converter.py @@ -109,11 +109,9 @@ def parse_args(): ''' Parse CLI arguments into an object and a dictionary ''' parser = argparse.ArgumentParser() parser.add_argument('bdf_fn', type=str, default='imgs', - help='Directory containing all the PNGs') + help='BDF Filename') parser.add_argument('font_name', type=str, default='font_name', - help='Name of the font') - parser.add_argument('--starting', type=int, default=61440, - help='Starting utf8 value') + help='Name of the font to be generated') args = parser.parse_args() dargs = vars(args) return (args, dargs) From a482132652152a920ff4767b01824ff071d24895 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 12 Oct 2018 21:11:55 +0200 Subject: [PATCH 06/23] lv_bar and lv_slider: fix indicator size at amy value --- lv_objx/lv_bar.c | 8 ++++---- lv_objx/lv_slider.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lv_objx/lv_bar.c b/lv_objx/lv_bar.c index 454aba4bb..46ca9bd1a 100644 --- a/lv_objx/lv_bar.c +++ b/lv_objx/lv_bar.c @@ -317,11 +317,11 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode lv_coord_t h = lv_area_get_height(&indic_area); if(w >= h) { - indic_area.x2 = (int32_t)((int32_t)w * (ext->cur_value - ext->min_value - 1)) / (ext->max_value - ext->min_value); - indic_area.x2 = indic_area.x1 + indic_area.x2; + indic_area.x2 = (int32_t)((int32_t)w * (ext->cur_value - ext->min_value)) / (ext->max_value - ext->min_value); + indic_area.x2 = indic_area.x1 + indic_area.x2 - 1; } else { - indic_area.y1 = (int32_t)((int32_t)h * (ext->cur_value - ext->min_value - 1)) / (ext->max_value - ext->min_value); - indic_area.y1 = indic_area.y2 - indic_area.y1; + indic_area.y1 = (int32_t)((int32_t)h * (ext->cur_value - ext->min_value)) / (ext->max_value - ext->min_value); + indic_area.y1 = indic_area.y2 - indic_area.y1 + 1; } /*Draw the indicator*/ diff --git a/lv_objx/lv_slider.c b/lv_objx/lv_slider.c index 857bb61bd..71e4b4162 100644 --- a/lv_objx/lv_slider.c +++ b/lv_objx/lv_slider.c @@ -349,12 +349,12 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig if(ext->drag_value != LV_SLIDER_NOT_PRESSED) cur_value = ext->drag_value; if(slider_w >= slider_h) { - area_indic.x2 = (int32_t)((int32_t)(lv_area_get_width(&area_indic) - 1) * (cur_value - min_value)) / (max_value - min_value); - area_indic.x2 = area_indic.x1 + area_indic.x2; + area_indic.x2 = (int32_t)((int32_t)(lv_area_get_width(&area_indic)) * (cur_value - min_value)) / (max_value - min_value); + area_indic.x2 = area_indic.x1 + area_indic.x2 - 1; } else { - area_indic.y1 = (int32_t)((int32_t)(lv_area_get_height(&area_indic) - 1) * (cur_value - min_value)) / (max_value - min_value); - area_indic.y1 = area_indic.y2 - area_indic.y1; + area_indic.y1 = (int32_t)((int32_t)(lv_area_get_height(&area_indic)) * (cur_value - min_value)) / (max_value - min_value); + area_indic.y1 = area_indic.y2 - area_indic.y1 + 1; } if(cur_value != min_value) lv_draw_rect(&area_indic, mask, style_indic, opa_scale); From c6d8f8ee28deb62e03709e499f4301ab05f48ca7 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 15 Oct 2018 12:44:17 +0200 Subject: [PATCH 07/23] move the bdf_font_converter to the lv_utils repo --- utils/bdf_font_converter.py | 201 ------------------------------------ 1 file changed, 201 deletions(-) delete mode 100644 utils/bdf_font_converter.py diff --git a/utils/bdf_font_converter.py b/utils/bdf_font_converter.py deleted file mode 100644 index 16935822e..000000000 --- a/utils/bdf_font_converter.py +++ /dev/null @@ -1,201 +0,0 @@ -#!/user/bin/env python - -''' -Small utility that converts 1bpp BDF fonts to a font compatible with littlevgl -''' - -# General imports -import argparse -import math - - -class Glyph: - def __init__(self, props ): - for k, v in props.items(): - setattr(self, k, v) - - def __lt__(self, other): - return self.encoding < other.encoding - - def get_width(self): - return self.dwidth[0] - - def get_byte_width(self): - # Compute how many bytes wide the glyph will be - return math.ceil(self.dwidth[0] / 8.0) - - def get_height(self): - return len(self.bitmap) - - def get_encoding(self): - return self.encoding - - def write_bitmap(self, f): - f.write('''/*Unicode: U+%04x ( %s ) , Width: %d */\n''' % - (self.encoding, self.name, self.dwidth[0]) ) - for line in self.bitmap: - for i in range(0, len(line), 2): - f.write("0x%s," % line[i:i+2]) - if(i > 0): - f.write(" ") - f.write("\n") - f.write("\n\n") - -def parse_bdf(fn): - # Converts bdf file to a list of Glyphs - # Read in BDF File - with open(fn, "r") as f: - bdf = f.readlines() - bdf = [x.rstrip("\n") for x in bdf] - - # Iterate through BDF Glyphs - glyphs = [] - i = -1 - while i < len(bdf): - props = {} - - i += 1 - tokens = bdf[i].split(' ') - if tokens[0] == 'ENDFONT': - break; - if tokens[0] != "STARTCHAR": - continue - props['name'] = tokens[1] - - i += 1 - tokens = bdf[i].split(' ') - if tokens[0] != "ENCODING": - continue - encoding = int(tokens[-1]) - if encoding < 0: # skip glyphs with a negative encoding value - continue - props['encoding'] = encoding - - i += 1 - tokens = bdf[i].split(' ') - if tokens[0] != "SWIDTH": - continue - props['swidth'] = (int(tokens[1]), int(tokens[2])) - - i += 1 - tokens = bdf[i].split(' ') - if tokens[0] != "DWIDTH": - continue - props['dwidth'] = (int(tokens[1]), int(tokens[2])) - - i += 1 - tokens = bdf[i].split(' ') - if tokens[0] != "BBX": - continue - props['dwidth'] = (int(tokens[1]), int(tokens[2]), - int(tokens[3]), int(tokens[4])) - - i += 1 - tokens = bdf[i].split(' ') - if tokens[0] != "BITMAP": - continue - - props['bitmap'] = [] - while True: - i += 1 - tokens = bdf[i].split(' ') - if tokens[0] == 'ENDCHAR': - break - props['bitmap'].append(tokens[0]) - glyphs.append(Glyph(props)) - return glyphs - -def parse_args(): - ''' Parse CLI arguments into an object and a dictionary ''' - parser = argparse.ArgumentParser() - parser.add_argument('bdf_fn', type=str, default='imgs', - help='BDF Filename') - parser.add_argument('font_name', type=str, default='font_name', - help='Name of the font to be generated') - args = parser.parse_args() - dargs = vars(args) - return (args, dargs) - -def main(): - args, dargs = parse_args() - - glyphs = parse_bdf(args.bdf_fn) - glyphs.sort() # Sorts by encoding (utf8) value - - ################ - # WRITE HEADER # - ################ - out = open(args.font_name + '.c', "w") - out.write(''' -#include "../lv_misc/lv_font.h" -''') - - ################# - # WRITE BITMAPS # - ################# - out.write( -''' -static const uint8_t %s_glyph_bitmap[] = -{ -''' % args.font_name) - - for glyph in glyphs: - glyph.write_bitmap(out) - - out.write(''' -}; -''') - - ###################### - # WRITE DESCRIPTIONS # - ###################### - out.write( -''' -/*Store the glyph descriptions*/ -static const lv_font_glyph_dsc_t %s_glyph_dsc[] = -{ -''' % args.font_name) - glyph_index = 0 - for glyph in glyphs: - out.write(''' -{.w_px = %d, .glyph_index = %d}, /*Unicode: U+%04x ( )*/ -''' % (glyph.get_width(), glyph_index, glyph.get_encoding()) ) - glyph_index += glyph.get_byte_width() * glyph.get_height() - - out.write(''' -}; -''') - - ##################### - # WRITE FONT STRUCT # - ##################### - out.write( -''' -lv_font_t %s = -{ - .unicode_first = %d, /*First Unicode letter in this font*/ - .unicode_last = %d, /*Last Unicode letter in this font*/ - .h_px = %d, /*Font height in pixels*/ - .glyph_bitmap = %s_glyph_bitmap, /*Bitmap of glyphs*/ - .glyph_dsc = %s_glyph_dsc, /*Description of glyphs*/ - .glyph_cnt = %d, /*Number of glyphs in the font*/ - .unicode_list = NULL, /*Every character in the font from 'unicode_first' to 'unicode_last'*/ - .get_bitmap = lv_font_get_bitmap_continuous, /*Function pointer to get glyph's bitmap*/ - .get_width = lv_font_get_width_continuous, /*Function pointer to get glyph's width*/ - .bpp = 1, /*Bit per pixel*/ - .monospace = 0, /*Fix width (0: if not used)*/ - .next_page = NULL, /*Pointer to a font extension*/ -}; -''' % (args.font_name, - glyphs[0].get_encoding(), - glyphs[-1].get_encoding(), - glyphs[0].get_height(), - args.font_name, - args.font_name, - len(glyphs), - ) ) - - out.close() - -if __name__=='__main__': - main() From d833a65d1e8a2aea6c21aa0999ea58d66ba621b4 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 13 Oct 2018 00:47:57 +0200 Subject: [PATCH 08/23] lv_ddlist and lv_roller bugfix when deleted while being in a group --- lv_objx/lv_ddlist.c | 6 ++++++ lv_objx/lv_roller.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index e7c632cfe..c7e108d21 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -708,6 +708,9 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en) anim_en = false; #endif lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist); + + if(ext->label == NULL) return; /*Probably the ddlist is being deleted if the label is NULL.*/ + lv_style_t * style = lv_obj_get_style(ddlist); lv_coord_t new_height; if(ext->opened) { /*Open the list*/ @@ -756,6 +759,9 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en) static void lv_ddlist_pos_current_option(lv_obj_t * ddlist) { lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist); + + if(ext->label == NULL) return; /*Probably the ddlist is being deleted if the label is NULL.*/ + lv_style_t * style = lv_obj_get_style(ddlist); const lv_font_t * font = style->text.font; lv_coord_t font_h = lv_font_get_height(font); diff --git a/lv_objx/lv_roller.c b/lv_objx/lv_roller.c index bac6aba8e..00aa156f0 100644 --- a/lv_objx/lv_roller.c +++ b/lv_objx/lv_roller.c @@ -503,8 +503,10 @@ static void refr_position(lv_obj_t * roller, bool anim_en) #if USE_LV_ANIMATION == 0 anim_en = false; #endif - lv_obj_t * roller_scrl = lv_page_get_scrl(roller); lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller); + if(ext->ddlist.label == NULL) return; /*Probably the roller is being deleted if the label is NULL.*/ + + lv_obj_t * roller_scrl = lv_page_get_scrl(roller); lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label); const lv_font_t * font = style_label->text.font; lv_coord_t font_h = lv_font_get_height(font); From 03e6b1bff7c9306106f8a149768c1ca388be02d2 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 15 Oct 2018 18:22:52 +0200 Subject: [PATCH 09/23] lv_group_remove_obj: stop iterating when the obj is found --- lv_core/lv_group.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lv_core/lv_group.c b/lv_core/lv_group.c index 9bda97439..d1fcabb6e 100644 --- a/lv_core/lv_group.c +++ b/lv_core/lv_group.c @@ -138,6 +138,7 @@ void lv_group_remove_obj(lv_obj_t * obj) lv_ll_rem(&g->obj_ll, i); lv_mem_free(i); obj->group_p = NULL; + break; } } } From 603e9336d40402b8ad36a9614bba94dc7b94e840 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 15 Oct 2018 19:00:03 +0200 Subject: [PATCH 10/23] fixes if the freed memory become dirty --- lv_misc/lv_anim.c | 1 + lv_misc/lv_task.c | 9 +++++++-- lv_objx/lv_ddlist.c | 6 +++--- lv_objx/lv_list.c | 8 +++++++- lv_objx/lv_page.c | 5 ++++- lv_objx/lv_roller.c | 11 ++++++----- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/lv_misc/lv_anim.c b/lv_misc/lv_anim.c index dee853b90..2bfbf788e 100644 --- a/lv_misc/lv_anim.c +++ b/lv_misc/lv_anim.c @@ -266,6 +266,7 @@ static bool anim_ready_handler(lv_anim_t * a) void * p = a->var; lv_ll_rem(&anim_ll, a); lv_mem_free(a); + anim_list_changed = true; /* Call the callback function at the end*/ /* Check if an animation is deleted in the cb function diff --git a/lv_misc/lv_task.c b/lv_misc/lv_task.c index 6745229b9..c2a9a48b6 100644 --- a/lv_misc/lv_task.c +++ b/lv_misc/lv_task.c @@ -31,6 +31,7 @@ static bool lv_task_exec(lv_task_t * lv_task_p); static lv_ll_t lv_task_ll; /*Linked list to store the lv_tasks*/ static bool lv_task_run = false; static uint8_t idle_last = 0; +static bool task_deleted; /********************** * MACROS @@ -197,6 +198,8 @@ void lv_task_del(lv_task_t * lv_task_p) lv_ll_rem(&lv_task_ll, lv_task_p); lv_mem_free(lv_task_p); + + task_deleted = true; } /** @@ -298,11 +301,13 @@ static bool lv_task_exec(lv_task_t * lv_task_p) uint32_t elp = lv_tick_elaps(lv_task_p->last_run); if(elp >= lv_task_p->period) { lv_task_p->last_run = lv_tick_get(); + task_deleted = false; lv_task_p->task(lv_task_p->param); /*Delete if it was a one shot lv_task*/ - if(lv_task_p->once != 0) lv_task_del(lv_task_p); - + if(task_deleted == false) { /*The task might be deleted by itself as well*/ + if(lv_task_p->once != 0) lv_task_del(lv_task_p); + } exec = true; } diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index c7e108d21..aae86b2e2 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -586,14 +586,14 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par } } else if(c == LV_GROUP_KEY_ENTER) { if(ext->opened) { - ext->sel_opt_id_ori = ext->sel_opt_id; - ext->opened = 0; - if(ext->action) ext->action(ddlist); #if USE_LV_GROUP lv_group_t * g = lv_obj_get_group(ddlist); bool editing = lv_group_get_editing(g); if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/ #endif + ext->sel_opt_id_ori = ext->sel_opt_id; + ext->opened = 0; + if(ext->action) res = ext->action(ddlist); } else { ext->opened = 1; } diff --git a/lv_objx/lv_list.c b/lv_objx/lv_list.c index fd73e3432..67c2dd427 100644 --- a/lv_objx/lv_list.c +++ b/lv_objx/lv_list.c @@ -767,8 +767,14 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para last_clicked_btn = btn; } -#endif + if(sign == LV_SIGNAL_CLEANUP) { + lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn)); + lv_obj_t * sel = lv_list_get_btn_selected(list); + if(sel == btn) lv_list_set_btn_selected(list, lv_list_get_next_btn(list, btn)); + } + +#endif return res; } diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index 793b9647b..39c8fa0b6 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -355,6 +355,8 @@ void lv_page_glue_obj(lv_obj_t * obj, bool glue) void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, uint16_t anim_time) { + lv_page_ext_t * ext = lv_obj_get_ext_attr(page); + #if USE_LV_ANIMATION == 0 anim_time = 0; #else @@ -362,9 +364,10 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, uint16_t anim_time) * 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); + lv_anim_del(ext->scrl, (lv_anim_fp_t)lv_obj_set_y); + lv_anim_del(ext->scrl, (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); lv_style_t * style_scrl = lv_page_get_style(page, LV_PAGE_STYLE_SCRL); diff --git a/lv_objx/lv_roller.c b/lv_objx/lv_roller.c index 00aa156f0..f0f6d9029 100644 --- a/lv_objx/lv_roller.c +++ b/lv_objx/lv_roller.c @@ -358,14 +358,15 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par lv_roller_set_selected(roller, ext->ddlist.sel_opt_id - 1, true); } } else if(c == LV_GROUP_KEY_ENTER) { - ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/ - if(ext->ddlist.action) ext->ddlist.action(roller); #if USE_LV_GROUP - lv_group_t * g = lv_obj_get_group(roller); - bool editing = lv_group_get_editing(g); + lv_group_t * g = lv_obj_get_group(roller); + bool editing = lv_group_get_editing(g); + + if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/ - if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/ #endif + ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/ + if(ext->ddlist.action) res = ext->ddlist.action(roller); } } else if(sign == LV_SIGNAL_GET_TYPE) { lv_obj_type_t * buf = param; From 7e4187e89a5e42f3d636d3f934887118c3c1f621 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 15 Oct 2018 19:33:34 +0200 Subject: [PATCH 11/23] fixes if an object is deleted in its action --- lv_core/lv_indev.c | 3 +++ lv_objx/lv_btnm.c | 62 +++++++++++++++++++++++---------------------- lv_objx/lv_ddlist.c | 10 +++++--- lv_objx/lv_kb.c | 19 ++++++++------ lv_objx/lv_page.c | 8 +++--- lv_objx/lv_roller.c | 6 ++--- lv_objx/lv_slider.c | 8 +++--- lv_objx/lv_sw.c | 13 +++++----- 8 files changed, 70 insertions(+), 59 deletions(-) diff --git a/lv_core/lv_indev.c b/lv_core/lv_indev.c index d726de3f6..94b1b6d9f 100644 --- a/lv_core/lv_indev.c +++ b/lv_core/lv_indev.c @@ -690,6 +690,9 @@ static void indev_proc_release(lv_indev_proc_t * proc) else { proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_RELEASED, indev_act); } + + if(proc->reset_query != 0) return; + /*Handle click focus*/ #if USE_LV_GROUP /*Edit mode is not used by POINTER devices. So leave edit mode if we are in it*/ diff --git a/lv_objx/lv_btnm.c b/lv_objx/lv_btnm.c index 38f011091..a49bd6cf9 100644 --- a/lv_objx/lv_btnm.c +++ b/lv_objx/lv_btnm.c @@ -541,7 +541,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) if(txt_i != LV_BTNM_PR_NONE) { if(button_is_repeat_disabled(ext->map_p[txt_i]) == false && button_is_inactive(ext->map_p[txt_i]) == false) { - ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i])); + res = ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i])); } } } @@ -549,39 +549,41 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) if(ext->btn_id_pr != LV_BTNM_PR_NONE) { uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr); if(button_is_inactive(ext->map_p[txt_i]) == false && txt_i != LV_BTNM_PR_NONE) { /*Ignore the inactive buttons anf click between the buttons*/ - if(ext->action)ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i])); + if(ext->action) res = ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i])); + if(res == LV_RES_OK) { - /*Invalidate to old pressed area*/; - lv_obj_get_coords(btnm, &btnm_area); - lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_pr]); - btn_area.x1 += btnm_area.x1; - btn_area.y1 += btnm_area.y1; - btn_area.x2 += btnm_area.x1; - btn_area.y2 += btnm_area.y1; - lv_inv_area(&btn_area); + /*Invalidate to old pressed area*/; + lv_obj_get_coords(btnm, &btnm_area); + lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_pr]); + btn_area.x1 += btnm_area.x1; + btn_area.y1 += btnm_area.y1; + btn_area.x2 += btnm_area.x1; + btn_area.y2 += btnm_area.y1; + lv_inv_area(&btn_area); - if(ext->toggle != 0) { - /*Invalidate to old toggled area*/; - lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_tgl]); - btn_area.x1 += btnm_area.x1; - btn_area.y1 += btnm_area.y1; - btn_area.x2 += btnm_area.x1; - btn_area.y2 += btnm_area.y1; - lv_inv_area(&btn_area); - ext->btn_id_tgl = ext->btn_id_pr; + if(ext->toggle != 0) { + /*Invalidate to old toggled area*/; + lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_tgl]); + btn_area.x1 += btnm_area.x1; + btn_area.y1 += btnm_area.y1; + btn_area.x2 += btnm_area.x1; + btn_area.y2 += btnm_area.y1; + lv_inv_area(&btn_area); + ext->btn_id_tgl = ext->btn_id_pr; - } + } - #if USE_LV_GROUP - /*Leave the clicked button as pressed if this the focused object in a group*/ - lv_group_t * g = lv_obj_get_group(btnm); - if(lv_group_get_focused(g) != btnm) { - ext->btn_id_pr = LV_BTNM_PR_NONE; - } - #else - ext->btn_id_pr = LV_BTNM_PR_NONE; - #endif + #if USE_LV_GROUP + /*Leave the clicked button as pressed if this the focused object in a group*/ + lv_group_t * g = lv_obj_get_group(btnm); + if(lv_group_get_focused(g) != btnm) { + ext->btn_id_pr = LV_BTNM_PR_NONE; + } + #else + ext->btn_id_pr = LV_BTNM_PR_NONE; + #endif + } } } } else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) { @@ -663,7 +665,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) if(ext->action != NULL) { uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr); if(txt_i != LV_BTNM_PR_NONE) { - ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i])); + res = ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i])); } } } diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index aae86b2e2..894294717 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -598,7 +598,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par ext->opened = 1; } - lv_ddlist_refr_size(ddlist, true); + if(res == LV_RES_OK) lv_ddlist_refr_size(ddlist, true); } else if(c == LV_GROUP_KEY_ESC) { if(ext->opened) { ext->opened = 0; @@ -658,6 +658,7 @@ static lv_res_t lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * static lv_res_t lv_ddlist_release_action(lv_obj_t * ddlist) { lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist); + lv_res_t res = LV_RES_OK; if(ext->opened == 0) { /*Open the list*/ ext->opened = 1; @@ -688,12 +689,13 @@ static lv_res_t lv_ddlist_release_action(lv_obj_t * ddlist) ext->sel_opt_id = new_opt; if(ext->action != NULL) { - ext->action(ddlist); + res = ext->action(ddlist); } } - lv_ddlist_refr_size(ddlist, true); - return LV_RES_OK; + if(res == LV_RES_OK) lv_ddlist_refr_size(ddlist, true); + + return res; } diff --git a/lv_objx/lv_kb.c b/lv_objx/lv_kb.c index f1e219d0b..f92190aa5 100644 --- a/lv_objx/lv_kb.c +++ b/lv_objx/lv_kb.c @@ -25,7 +25,7 @@ * STATIC PROTOTYPES **********************/ static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param); -static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt); +static lv_res_t lv_kb_def_action(lv_obj_t * kb, const char * txt); /********************** * STATIC VARIABLES @@ -104,7 +104,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy) if(copy == NULL) { lv_obj_set_size(new_kb, LV_HOR_RES, LV_VER_RES / 2); lv_obj_align(new_kb, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0); - lv_btnm_set_action(new_kb, lv_app_kb_action); + lv_btnm_set_action(new_kb, lv_kb_def_action); lv_btnm_set_map(new_kb, kb_map_lc); /*Set the default styles*/ @@ -390,9 +390,10 @@ static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param) * @param i the index of the released button from the current btnm map * @return LV_ACTION_RES_INV if the btnm is deleted else LV_ACTION_RES_OK */ -static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt) +static lv_res_t lv_kb_def_action(lv_obj_t * kb, const char * txt) { lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb); + lv_res_t res = LV_RES_OK; /*Do the corresponding action according to the text of the button*/ if(strcmp(txt, "abc") == 0) { @@ -405,22 +406,24 @@ static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt) lv_btnm_set_map(kb, kb_map_spec); return LV_RES_OK; } else if(strcmp(txt, SYMBOL_CLOSE) == 0) { - if(ext->hide_action) ext->hide_action(kb); + if(ext->hide_action) res = ext->hide_action(kb); else { lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/ lv_obj_del(kb); } return LV_RES_INV; } else if(strcmp(txt, SYMBOL_OK) == 0) { - if(ext->ok_action) ext->ok_action(kb); + if(ext->ok_action) res = ext->ok_action(kb); else { lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/ - lv_obj_del(kb); + res = lv_obj_del(kb); } - return LV_RES_INV; } - if(ext->ta == NULL) return LV_RES_OK; + if(res != LV_RES_OK) return res; /*The keyboard might be deleted in the actions*/ + + /*Add the characters to the text area if set*/ + if(ext->ta == NULL) return res; if(strcmp(txt, "Enter") == 0)lv_ta_add_char(ext->ta, '\n'); else if(strcmp(txt, SYMBOL_LEFT) == 0) lv_ta_cursor_left(ext->ta); diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index 39c8fa0b6..ce27cae5c 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -650,12 +650,12 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) } } else if(sign == LV_SIGNAL_PRESSED) { if(ext->pr_action != NULL) { - ext->pr_action(page); + res = ext->pr_action(page); } } else if(sign == LV_SIGNAL_RELEASED) { if(lv_indev_is_dragging(lv_indev_get_act()) == false) { if(ext->rel_action != NULL) { - ext->rel_action(page); + res = ext->rel_action(page); } } } else if(sign == LV_SIGNAL_REFR_EXT_SIZE) { @@ -794,12 +794,12 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi } } else if(sign == LV_SIGNAL_PRESSED) { if(page_ext->pr_action != NULL) { - page_ext->pr_action(page); + res = page_ext->pr_action(page); } } else if(sign == LV_SIGNAL_RELEASED) { if(lv_indev_is_dragging(lv_indev_get_act()) == false) { if(page_ext->rel_action != NULL) { - page_ext->rel_action(page); + res = page_ext->rel_action(page); } } } diff --git a/lv_objx/lv_roller.c b/lv_objx/lv_roller.c index f0f6d9029..a67a35c0a 100644 --- a/lv_objx/lv_roller.c +++ b/lv_objx/lv_roller.c @@ -415,7 +415,7 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, if(id < 0) id = 0; if(id >= ext->ddlist.option_cnt) id = ext->ddlist.option_cnt - 1; ext->ddlist.sel_opt_id = id; - if(ext->ddlist.action) ext->ddlist.action(roller); + if(ext->ddlist.action) res = ext->ddlist.action(roller); } else if(sign == LV_SIGNAL_RELEASED) { /*If picked an option by clicking then set it*/ if(!lv_indev_is_dragging(indev)) { @@ -426,12 +426,12 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, if(id < 0) id = 0; if(id >= ext->ddlist.option_cnt) id = ext->ddlist.option_cnt - 1; ext->ddlist.sel_opt_id = id; - if(ext->ddlist.action) ext->ddlist.action(roller); + if(ext->ddlist.action) res = ext->ddlist.action(roller); } } /*Position the scrollable according to the new selected option*/ - if(id != -1) { + if(id != -1 && res == LV_RES_OK) { refr_position(roller, true); } diff --git a/lv_objx/lv_slider.c b/lv_objx/lv_slider.c index 71e4b4162..2a0763789 100644 --- a/lv_objx/lv_slider.c +++ b/lv_objx/lv_slider.c @@ -455,13 +455,13 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par if(tmp != ext->drag_value) { ext->drag_value = tmp; - if(ext->action != NULL) ext->action(slider); lv_obj_invalidate(slider); + if(ext->action != NULL) res = ext->action(slider); } } else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) { lv_slider_set_value(slider, ext->drag_value); ext->drag_value = LV_SLIDER_NOT_PRESSED; - if(ext->action != NULL) ext->action(slider); + if(ext->action != NULL) res = ext->action(slider); } else if(sign == LV_SIGNAL_CORD_CHG) { /* The knob size depends on slider size. * During the drawing method the ext. size is used by the knob so refresh the ext. size.*/ @@ -498,10 +498,10 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par #endif if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) { lv_slider_set_value(slider, lv_slider_get_value(slider) + 1); - if(ext->action != NULL) ext->action(slider); + if(ext->action != NULL) res = ext->action(slider); } else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) { lv_slider_set_value(slider, lv_slider_get_value(slider) - 1); - if(ext->action != NULL) ext->action(slider); + if(ext->action != NULL) res = ext->action(slider); } } else if(sign == LV_SIGNAL_GET_EDITABLE) { bool * editable = (bool *)param; diff --git a/lv_objx/lv_sw.c b/lv_objx/lv_sw.c index 7c299a6ea..75970730b 100644 --- a/lv_objx/lv_sw.c +++ b/lv_objx/lv_sw.c @@ -243,9 +243,10 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param) if(lv_sw_get_state(sw)) lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_on); else lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_off); - if(slider_action != NULL) slider_action(sw); - ext->changed = 0; + + if(slider_action != NULL) res = slider_action(sw); + } else if(sign == LV_SIGNAL_CONTROLL) { char c = *((char *)param); @@ -253,13 +254,13 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param) if(old_val) lv_sw_off(sw); else lv_sw_on(sw); - if(slider_action) slider_action(sw); + if(slider_action) res = slider_action(sw); } else if(c == LV_GROUP_KEY_UP || c == LV_GROUP_KEY_RIGHT) { lv_sw_on(sw); - if(slider_action) slider_action(sw); + if(slider_action) res = slider_action(sw); } else if(c == LV_GROUP_KEY_DOWN || c == LV_GROUP_KEY_LEFT) { lv_sw_off(sw); - if(slider_action) slider_action(sw); + if(slider_action) res = slider_action(sw); } } else if(sign == LV_SIGNAL_GET_EDITABLE) { bool * editable = (bool *)param; @@ -274,7 +275,7 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param) } /*Restore the callback*/ - ext->slider.action = slider_action; + if(res == LV_RES_OK) ext->slider.action = slider_action; return res; } From 7427e01b60cc6afd823113a5e8734976c8021340 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 15 Oct 2018 20:12:12 +0200 Subject: [PATCH 12/23] lv_group related updates mainly with ENCODER indev --- lv_core/lv_group.c | 12 +++++++++++- lv_core/lv_indev.c | 17 +++-------------- lv_objx/lv_ddlist.c | 12 +++++++----- lv_objx/lv_roller.c | 15 ++++++++------- lv_objx/lv_tabview.c | 18 ++++++++++++++++++ 5 files changed, 47 insertions(+), 27 deletions(-) diff --git a/lv_core/lv_group.c b/lv_core/lv_group.c index d1fcabb6e..7b399a978 100644 --- a/lv_core/lv_group.c +++ b/lv_core/lv_group.c @@ -154,6 +154,9 @@ void lv_group_focus_obj(lv_obj_t * obj) if(g->frozen != 0) return; + /*On defocus edit mode must be leaved*/ + lv_group_set_editing(g, false); + lv_obj_t ** i; LL_READ(g->obj_ll, i) { if(*i == obj) { @@ -295,8 +298,15 @@ void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb) */ void lv_group_set_editing(lv_group_t * group, bool edit) { - group->editing = edit ? 1 : 0; + uint8_t en_val = edit ? 1 : 0; + + if(en_val == group->editing) return; /*Do not set the same mode again*/ + + group->editing = en_val; lv_obj_t * focused = lv_group_get_focused(group); + + if(focused) focused->signal_func(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave edit mode*/ + lv_obj_invalidate(focused); } diff --git a/lv_core/lv_indev.c b/lv_core/lv_indev.c index 94b1b6d9f..8b4170d7b 100644 --- a/lv_core/lv_indev.c +++ b/lv_core/lv_indev.c @@ -384,11 +384,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) /* Edit mode is not used by KEYPAD devices. * So leave edit mode if we are in it before focusing on the next/prev object*/ if(data->key == LV_GROUP_KEY_NEXT || data->key == LV_GROUP_KEY_PREV) { - if(lv_group_get_editing(i->group)) { - lv_group_set_editing(i->group, false); - lv_obj_t * focused = lv_group_get_focused(i->group); - if(focused) focused->signal_func(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave edit mode*/ - } + lv_group_set_editing(i->group, false); } if(data->key == LV_GROUP_KEY_NEXT) { @@ -465,10 +461,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) if(focused) focused->signal_func(focused, LV_SIGNAL_GET_EDITABLE, &editable); if(editable) { - i->group->editing = i->group->editing ? 0 : 1; - if(focused) focused->signal_func(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again. Some object do something on navigate->edit change*/ - LV_LOG_INFO("Edit mode changed"); - if(focused) lv_obj_invalidate(focused); + lv_group_set_editing(i->group, lv_group_get_editing(i->group) ? false : true); /*Toggle edit mode on long press*/ } /*If not editable then just send a long press signal*/ else { @@ -493,10 +486,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) } /*If the focused object is editable and now in navigate mode then enter edit mode*/ else if(editable && !i->group->editing && !i->proc.long_pr_sent) { - i->group->editing = i->group->editing ? 0 : 1; - if(focused) focused->signal_func(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again. Some object do something on navigate->edit change*/ - LV_LOG_INFO("Edit mode changed (edit)"); - if(focused) lv_obj_invalidate(focused); + lv_group_set_editing(i->group, lv_group_get_editing(i->group) ? false : true); /*Toggle edit mode on long press*/ } if(i->proc.reset_query) return; /*The object might be deleted in `focus_cb` or due to any other user event*/ @@ -699,7 +689,6 @@ static void indev_proc_release(lv_indev_proc_t * proc) lv_group_t * act_g = lv_obj_get_group(proc->act_obj); if(lv_group_get_editing(act_g)) { lv_group_set_editing(act_g, false); - proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave edit mode*/ } /*Check, if the parent is in a group focus on it.*/ diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index 894294717..981d1e4ae 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -586,14 +586,16 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par } } else if(c == LV_GROUP_KEY_ENTER) { if(ext->opened) { -#if USE_LV_GROUP - lv_group_t * g = lv_obj_get_group(ddlist); - bool editing = lv_group_get_editing(g); - if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/ -#endif ext->sel_opt_id_ori = ext->sel_opt_id; ext->opened = 0; if(ext->action) res = ext->action(ddlist); +#if USE_LV_GROUP + if(res == LV_RES_OK) { + lv_group_t * g = lv_obj_get_group(ddlist); + bool editing = lv_group_get_editing(g); + if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/ + } +#endif } else { ext->opened = 1; } diff --git a/lv_objx/lv_roller.c b/lv_objx/lv_roller.c index a67a35c0a..ea5ea7663 100644 --- a/lv_objx/lv_roller.c +++ b/lv_objx/lv_roller.c @@ -358,15 +358,16 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par lv_roller_set_selected(roller, ext->ddlist.sel_opt_id - 1, true); } } else if(c == LV_GROUP_KEY_ENTER) { -#if USE_LV_GROUP - lv_group_t * g = lv_obj_get_group(roller); - bool editing = lv_group_get_editing(g); - - if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/ - -#endif ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/ if(ext->ddlist.action) res = ext->ddlist.action(roller); +#if USE_LV_GROUP + if(res == LV_RES_OK) { + lv_group_t * g = lv_obj_get_group(roller); + bool editing = lv_group_get_editing(g); + + if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/ + } +#endif } } else if(sign == LV_SIGNAL_GET_TYPE) { lv_obj_type_t * buf = param; diff --git a/lv_objx/lv_tabview.c b/lv_objx/lv_tabview.c index ddfc15fa5..28aa76714 100644 --- a/lv_objx/lv_tabview.c +++ b/lv_objx/lv_tabview.c @@ -577,9 +577,27 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p tabview_realign(tabview); } } else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROLL) { + /* The button matrix is not in a group (the tab view is in it) but it should handle the group signals. + * So propagate the related signals to the button matrix manually*/ if(ext->btns) { ext->btns->signal_func(ext->btns, sign, param); } + if(sign == LV_SIGNAL_FOCUS) { + lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); + /*With ENCODER select the first button only in edit mode*/ + if(indev_type == LV_INDEV_TYPE_ENCODER) { + lv_group_t * g = lv_obj_get_group(tabview); + if(lv_group_get_editing(g)) { + lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns); + btnm_ext->btn_id_pr = 0; + lv_obj_invalidate(ext->btns); + } + } else { + lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns); + btnm_ext->btn_id_pr = 0; + lv_obj_invalidate(ext->btns); + } + } } else if(sign == LV_SIGNAL_GET_EDITABLE) { bool * editable = (bool *)param; *editable = true; From 39395465a2a0137d829024ef6715aece78ec859e Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 16 Oct 2018 16:08:13 +0200 Subject: [PATCH 13/23] fix version number --- lvgl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lvgl.h b/lvgl.h index 3f3084c81..dbedb4f68 100644 --- a/lvgl.h +++ b/lvgl.h @@ -61,7 +61,7 @@ extern "C" { *********************/ /*Current version of LittlevGL*/ #define LVGL_VERSION_MAJOR 5 -#define LVGL_VERSION_MINOR 3 +#define LVGL_VERSION_MINOR 2 #define LVGL_VERSION_PATCH 0 #define LVGL_VERSION_INFO "" From c9111563b10619131a410c811831c909453a85f5 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 17 Oct 2018 05:42:27 +0200 Subject: [PATCH 14/23] add lv_cont/page_get_width/height --- lv_objx/lv_cont.c | 24 ++++++++++++++++++++++++ lv_objx/lv_cont.h | 15 +++++++++++++++ lv_objx/lv_page.c | 26 ++++++++++++++++++++++++++ lv_objx/lv_page.h | 15 +++++++++++++++ 4 files changed, 80 insertions(+) diff --git a/lv_objx/lv_cont.c b/lv_objx/lv_cont.c index 89da6ad22..304852a22 100644 --- a/lv_objx/lv_cont.c +++ b/lv_objx/lv_cont.c @@ -189,6 +189,30 @@ bool lv_cont_get_ver_fit(const lv_obj_t * cont) return ext->ver_fit == 0 ? false : true; } +/** + * Get that width reduced by the horizontal padding. Useful if a layout is used. + * @param cont pointer to a container object + * @return the width which still fits into the container + */ +lv_coord_t lv_cont_get_fit_width(lv_obj_t * cont) +{ + lv_style_t * style = lv_cont_get_style(cont); + + return lv_obj_get_width(cont) - 2 * style->body.padding.hor; +} + +/** + * Get that height reduced by the vertical padding. Useful if a layout is used. + * @param cont pointer to a container object + * @return the height which still fits into the container + */ +lv_coord_t lv_cont_get_fit_height(lv_obj_t * cont) +{ + lv_style_t * style = lv_cont_get_style(cont); + + return lv_obj_get_width(cont) - 2 * style->body.padding.hor; +} + /********************** * STATIC FUNCTIONS **********************/ diff --git a/lv_objx/lv_cont.h b/lv_objx/lv_cont.h index f1c37fac7..3259c772f 100644 --- a/lv_objx/lv_cont.h +++ b/lv_objx/lv_cont.h @@ -125,6 +125,21 @@ bool lv_cont_get_hor_fit(const lv_obj_t * cont); */ bool lv_cont_get_ver_fit(const lv_obj_t * cont); + +/** + * Get that width reduced by the horizontal padding. Useful if a layout is used. + * @param cont pointer to a container object + * @return the width which still fits into the container + */ +lv_coord_t lv_cont_get_fit_width(lv_obj_t * cont); + +/** + * Get that height reduced by the vertical padding. Useful if a layout is used. + * @param cont pointer to a container object + * @return the height which still fits into the container + */ +lv_coord_t lv_cont_get_fit_height(lv_obj_t * cont); + /** * Get the style of a container * @param cont pointer to a container object diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index ce27cae5c..9e19261d8 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -306,6 +306,32 @@ bool lv_page_get_arrow_scroll(const lv_obj_t * page) return ext->arrow_scroll ? true : false; } +/** + * Get that width which can be set to the children to still not cause overflow (show scrollbars) + * @param page pointer to a page object + * @return the width which still fits into the page + */ +lv_coord_t lv_page_get_fit_width(lv_obj_t * page) +{ + lv_style_t * bg_style = lv_page_get_style(page, LV_PAGE_STYLE_BG); + lv_style_t * scrl_style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL); + + return lv_obj_get_width(page) - 2 * (bg_style->body.padding.hor + scrl_style->body.padding.hor); +} + +/** + * Get that height which can be set to the children to still not cause overflow (show scrollbars) + * @param page pointer to a page object + * @return the height which still fits into the page + */ +lv_coord_t lv_page_get_fit_height(lv_obj_t * page) +{ + lv_style_t * bg_style = lv_page_get_style(page, LV_PAGE_STYLE_BG); + lv_style_t * scrl_style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL); + + return lv_obj_get_height(page) - 2 * (bg_style->body.padding.ver + scrl_style->body.padding.ver); +} + /** * Get a style of a page * @param page pointer to page object diff --git a/lv_objx/lv_page.h b/lv_objx/lv_page.h index 80f4fcb36..975452d09 100644 --- a/lv_objx/lv_page.h +++ b/lv_objx/lv_page.h @@ -217,6 +217,21 @@ lv_sb_mode_t lv_page_get_sb_mode(const lv_obj_t * page); */ bool lv_page_get_arrow_scroll(const lv_obj_t * page); + +/** + * Get that width which can be set to the children to still not cause overflow (show scrollbars) + * @param page pointer to a page object + * @return the width which still fits into the page + */ +lv_coord_t lv_page_get_fit_width(lv_obj_t * page); + +/** + * Get that height which can be set to the children to still not cause overflow (show scrollbars) + * @param page pointer to a page object + * @return the height which still fits into the page + */ +lv_coord_t lv_page_get_fit_height(lv_obj_t * page); + /** * Get width of the scrollable part of a page * @param page pointer to a page object From 4751cb16c91a9769b4eaf6e11e0008b036aa3c14 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 17 Oct 2018 11:27:08 +0200 Subject: [PATCH 15/23] minor fixes --- lv_core/lv_obj.c | 4 ++++ lv_objx/lv_list.c | 4 ++-- lv_objx/lv_mbox.c | 2 ++ lv_themes/lv_theme_alien.c | 8 ++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index d8cba60c0..abeed35f9 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -778,6 +778,10 @@ void lv_obj_report_style_mod(lv_style_t * style) { lv_obj_t * i; LL_READ(scr_ll, i) { + if(i->style_p == style || style == NULL) { + lv_obj_refresh_style(i); + } + report_style_mod_core(style, i); } } diff --git a/lv_objx/lv_list.c b/lv_objx/lv_list.c index 67c2dd427..c0c994b65 100644 --- a/lv_objx/lv_list.c +++ b/lv_objx/lv_list.c @@ -408,7 +408,7 @@ lv_obj_t * lv_list_get_prev_btn(const lv_obj_t * list, lv_obj_t * prev_btn) if(btn == NULL) return NULL; while(btn->signal_func != lv_list_btn_signal) { - btn = lv_obj_get_child(scrl, prev_btn); + btn = lv_obj_get_child(scrl, btn); if(btn == NULL) break; } @@ -434,7 +434,7 @@ lv_obj_t * lv_list_get_next_btn(const lv_obj_t * list, lv_obj_t * prev_btn) if(btn == NULL) return NULL; while(btn->signal_func != lv_list_btn_signal) { - btn = lv_obj_get_child_back(scrl, prev_btn); + btn = lv_obj_get_child_back(scrl, btn); if(btn == NULL) break; } diff --git a/lv_objx/lv_mbox.c b/lv_objx/lv_mbox.c index 66fbfa3d6..388bfb6e7 100644 --- a/lv_objx/lv_mbox.c +++ b/lv_objx/lv_mbox.c @@ -276,6 +276,8 @@ void lv_mbox_set_style(lv_obj_t * mbox, lv_mbox_style_t type, lv_style_t * style break; } + mbox_realign(mbox); + } diff --git a/lv_themes/lv_theme_alien.c b/lv_themes/lv_theme_alien.c index 13fe40949..386efb61e 100644 --- a/lv_themes/lv_theme_alien.c +++ b/lv_themes/lv_theme_alien.c @@ -136,6 +136,13 @@ static void basic_init(void) } +static void cont_init(void) +{ +#if USE_LV_CONT != 0 + theme.cont = &panel; +#endif +} + static void btn_init(void) { #if USE_LV_BTN != 0 @@ -785,6 +792,7 @@ lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font) } basic_init(); + cont_init(); btn_init(); label_init(); bar_init(); From bf00102f83696e6bc032efed0bc6b73a820a13b0 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 17 Oct 2018 12:41:18 +0200 Subject: [PATCH 16/23] lv_ta: cursor type bit size fix --- lv_objx/lv_ta.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lv_objx/lv_ta.h b/lv_objx/lv_ta.h index b97c67c49..284dcacec 100644 --- a/lv_objx/lv_ta.h +++ b/lv_objx/lv_ta.h @@ -49,7 +49,7 @@ enum { LV_CURSOR_BLOCK, LV_CURSOR_OUTLINE, LV_CURSOR_UNDERLINE, - LV_CURSOR_HIDDEN = 0x10, /*Or it to any value to hide the cursor temporally*/ + LV_CURSOR_HIDDEN = 0x08, /*Or it to any value to hide the cursor temporally*/ }; typedef uint8_t lv_cursor_type_t; @@ -68,7 +68,7 @@ typedef struct lv_style_t *style; /*Style of the cursor (NULL to use label's style)*/ lv_coord_t valid_x; /*Used when stepping up/down in text area when stepping to a shorter line. (Handled by the library)*/ uint16_t pos; /*The current cursor position (0: before 1. letter; 1: before 2. letter etc.)*/ - lv_cursor_type_t type:3; /*Shape of the cursor*/ + lv_cursor_type_t type:4; /*Shape of the cursor*/ uint8_t state :1; /*Indicates that the cursor is visible now or not (Handled by the library)*/ } cursor; } lv_ta_ext_t; From 88b8e982b485368cc873860ba602a4cd315d674f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 17 Oct 2018 14:31:16 +0200 Subject: [PATCH 17/23] lv_task and lv_ll: stability improvents --- lv_misc/lv_ll.c | 5 ++++- lv_misc/lv_task.c | 47 ++++++++++++++++++++++++++++++----------------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/lv_misc/lv_ll.c b/lv_misc/lv_ll.c index d12de91f1..fd5561fb3 100644 --- a/lv_misc/lv_ll.c +++ b/lv_misc/lv_ll.c @@ -321,7 +321,10 @@ void lv_ll_move_before(lv_ll_t * ll_p, void * n_act, void * n_after) if(n_act == n_after) return; /*Can't move before itself*/ - void * n_before = lv_ll_get_prev(ll_p, n_after); + void * n_before; + if(n_after != NULL) n_before = lv_ll_get_prev(ll_p, n_after); + else n_before = lv_ll_get_tail(ll_p); /*if `n_after` is NULL `n_act` should be the new tail*/ + if(n_act == n_before) return; /*Already before `n_after`*/ /*It's much easier to remove from the list and add again*/ diff --git a/lv_misc/lv_task.c b/lv_misc/lv_task.c index c2a9a48b6..160e066bc 100644 --- a/lv_misc/lv_task.c +++ b/lv_misc/lv_task.c @@ -32,6 +32,8 @@ static lv_ll_t lv_task_ll; /*Linked list to store the lv_tasks*/ static bool lv_task_run = false; static uint8_t idle_last = 0; static bool task_deleted; +static bool task_created; +static lv_task_t * task_act; /********************** * MACROS @@ -80,33 +82,35 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void) bool end_flag; do { end_flag = true; - lv_task_t * act = lv_ll_get_head(&lv_task_ll); - while(act) { + task_deleted = false; + task_created = false; + task_act = lv_ll_get_head(&lv_task_ll); + while(task_act) { /* The task might be deleted if it runs only once ('once = 1') * So get next element until the current is surely valid*/ - next = lv_ll_get_next(&lv_task_ll, act); + next = lv_ll_get_next(&lv_task_ll, task_act); /*We reach priority of the turned off task. There is nothing more to do.*/ - if(act->prio == LV_TASK_PRIO_OFF) { + if(task_act->prio == LV_TASK_PRIO_OFF) { break; } /*Here is the interrupter task. Don't execute it again.*/ - if(act == task_interrupter) { + if(task_act == task_interrupter) { task_interrupter = NULL; /*From this point only task after the interrupter comes, so the interrupter is not interesting anymore*/ - act = next; + task_act = next; continue; /*Load the next task*/ } /*Just try to run the tasks with highest priority.*/ - if(act->prio == LV_TASK_PRIO_HIGHEST) { - lv_task_exec(act); + if(task_act->prio == LV_TASK_PRIO_HIGHEST) { + lv_task_exec(task_act); } /*Tasks with higher priority then the interrupted shall be run in every case*/ else if(task_interrupter) { - if(act->prio > task_interrupter->prio) { - if(lv_task_exec(act)) { - task_interrupter = act; /*Check all tasks again from the highest priority */ + if(task_act->prio > task_interrupter->prio) { + if(lv_task_exec(task_act)) { + task_interrupter = task_act; /*Check all tasks again from the highest priority */ end_flag = false; break; } @@ -115,13 +119,17 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void) /* It is no interrupter task or we already reached it earlier. * Just run the remaining tasks*/ else { - if(lv_task_exec(act)) { - task_interrupter = act; /*Check all tasks again from the highest priority */ + if(lv_task_exec(task_act)) { + task_interrupter = task_act; /*Check all tasks again from the highest priority */ end_flag = false; break; } } - act = next; /*Load the next task*/ + + if(task_deleted) break; /*If a task was deleted then this or the next item might be corrupted*/ + if(task_created) break; /*If a task was deleted then this or the next item might be corrupted*/ + + task_act = next; /*Load the next task*/ } } while(!end_flag); @@ -186,6 +194,8 @@ lv_task_t * lv_task_create(void (*task)(void *), uint32_t period, lv_task_prio_t new_lv_task->once = 0; new_lv_task->last_run = lv_tick_get(); + task_created = true; + return new_lv_task; } @@ -199,7 +209,7 @@ void lv_task_del(lv_task_t * lv_task_p) lv_mem_free(lv_task_p); - task_deleted = true; + if(task_act == lv_task_p) task_deleted = true; /*The active task was deleted*/ } /** @@ -301,12 +311,15 @@ static bool lv_task_exec(lv_task_t * lv_task_p) uint32_t elp = lv_tick_elaps(lv_task_p->last_run); if(elp >= lv_task_p->period) { lv_task_p->last_run = lv_tick_get(); - task_deleted = false; + task_deleted = false; + task_created = false; lv_task_p->task(lv_task_p->param); /*Delete if it was a one shot lv_task*/ if(task_deleted == false) { /*The task might be deleted by itself as well*/ - if(lv_task_p->once != 0) lv_task_del(lv_task_p); + if(lv_task_p->once != 0) { + lv_task_del(lv_task_p); + } } exec = true; } From 78428b523f355e79497bb1fd1e2b293d49812618 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 18 Oct 2018 06:59:41 +0200 Subject: [PATCH 18/23] lv_draw_img: fix to draw images with LV_COLOR_DEPTH 1 --- lv_draw/lv_draw_vbasic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lv_draw/lv_draw_vbasic.c b/lv_draw/lv_draw_vbasic.c index a756ddb2a..e23f15eaa 100644 --- a/lv_draw/lv_draw_vbasic.c +++ b/lv_draw/lv_draw_vbasic.c @@ -483,7 +483,7 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p, /*Calculate with the pixel level alpha*/ if(alpha_byte) { -#if LV_COLOR_DEPTH == 8 +#if LV_COLOR_DEPTH == 8 || LV_COLOR_DEPTH == 1 px_color.full = px_color_p[0]; #elif LV_COLOR_DEPTH == 16 /*Because of Alpha byte 16 bit color can start on odd address which can cause crash*/ From cd3f6340da721736a20772e62756e00bae9ad265 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 20 Oct 2018 00:38:56 +0200 Subject: [PATCH 19/23] add rc tag --- lvgl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lvgl.h b/lvgl.h index dbedb4f68..6e74d53fa 100644 --- a/lvgl.h +++ b/lvgl.h @@ -63,7 +63,7 @@ extern "C" { #define LVGL_VERSION_MAJOR 5 #define LVGL_VERSION_MINOR 2 #define LVGL_VERSION_PATCH 0 -#define LVGL_VERSION_INFO "" +#define LVGL_VERSION_INFO "rc" /********************** * TYPEDEFS From 436c09aa51c736c3a86d2c10b1258715ed86ed2c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 27 Oct 2018 11:11:08 +0200 Subject: [PATCH 20/23] lv_ll: fix comment typo --- lv_misc/lv_ll.c | 2 +- lv_misc/lv_ll.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lv_misc/lv_ll.c b/lv_misc/lv_ll.c index fd5561fb3..580beb1da 100644 --- a/lv_misc/lv_ll.c +++ b/lv_misc/lv_ll.c @@ -157,7 +157,7 @@ void * lv_ll_ins_tail(lv_ll_t * ll_p) /** * Remove the node 'node_p' from 'll_p' linked list. - * It Dose not free the the memory of node. + * It dose not free the the memory of node. * @param ll_p pointer to the linked list of 'node_p' * @param node_p pointer to node in 'll_p' linked list */ diff --git a/lv_misc/lv_ll.h b/lv_misc/lv_ll.h index 43f865182..5960132db 100644 --- a/lv_misc/lv_ll.h +++ b/lv_misc/lv_ll.h @@ -72,7 +72,7 @@ void * lv_ll_ins_tail(lv_ll_t * ll_p); /** * Remove the node 'node_p' from 'll_p' linked list. - * It Dose not free the the memory of node. + * It dose not free the the memory of node. * @param ll_p pointer to the linked list of 'node_p' * @param node_p pointer to node in 'll_p' linked list */ From 4f11ad7adb8f6abbf9f3a4cb2c6835fb54063405 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 28 Oct 2018 09:07:00 +0100 Subject: [PATCH 21/23] lv_draw_img: fix buffer size --- lv_draw/lv_draw_img.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lv_draw/lv_draw_img.c b/lv_draw/lv_draw_img.c index 0f7fa5153..2d81dbbe3 100644 --- a/lv_draw/lv_draw_img.c +++ b/lv_draw/lv_draw_img.c @@ -305,7 +305,7 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas lv_coord_t width = lv_area_get_width(&mask_com); #if LV_COMPILER_VLA_SUPPORTED - uint8_t buf[(lv_area_get_width(&mask_com) * (LV_COLOR_SIZE + 1))]; + uint8_t buf[(lv_area_get_width(&mask_com) * ((LV_COLOR_DEPTH >> 3) + 1))]; #else uint8_t buf[LV_HOR_RES * ((LV_COLOR_DEPTH >> 3) + 1)]; /*+1 because of the possible alpha byte*/ #endif From fc319a45024f7fa7ce1a86385e731142590ad2d3 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 28 Oct 2018 10:29:06 +0100 Subject: [PATCH 22/23] lv_tabview: add lv_res_t return value to prevent tab laoding on LV_RES_INV --- lv_objx/lv_tabview.c | 4 +++- lv_objx/lv_tabview.h | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lv_objx/lv_tabview.c b/lv_objx/lv_tabview.c index 28aa76714..1988d3600 100644 --- a/lv_objx/lv_tabview.c +++ b/lv_objx/lv_tabview.c @@ -275,8 +275,10 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, bool anim_en) lv_style_t * style = lv_obj_get_style(ext->content); + lv_res_t res = LV_RES_OK; if(id >= ext->tab_cnt) id = ext->tab_cnt - 1; - if(ext->tab_load_action && id != ext->tab_cur) ext->tab_load_action(tabview, id); + if(ext->tab_load_action && id != ext->tab_cur) res = ext->tab_load_action(tabview, id); + if(res != LV_RES_OK) return; /*Prevent the tab loading*/ ext->tab_cur = id; diff --git a/lv_objx/lv_tabview.h b/lv_objx/lv_tabview.h index 0356f39c4..3c80ff346 100644 --- a/lv_objx/lv_tabview.h +++ b/lv_objx/lv_tabview.h @@ -42,8 +42,9 @@ extern "C" { * TYPEDEFS **********************/ -/* parametes: pointer to a tabview object, tab_id*/ -typedef void (*lv_tabview_action_t)(lv_obj_t *, uint16_t); +/* parametes: pointer to a tabview object, tab_id + * return: LV_RES_INV: to prevent the loading of the tab; LV_RES_OK: if everything is fine*/ +typedef lv_res_t (*lv_tabview_action_t)(lv_obj_t *, uint16_t); enum { From b7792f0aa289145ce0852a742497d80f216f6f6d Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 28 Oct 2018 23:18:22 +0100 Subject: [PATCH 23/23] updates from dev-5.3 --- lv_fonts/lv_font_symbol_10.c | 5 ----- lv_fonts/lv_font_symbol_20.c | 5 ----- lv_fonts/lv_font_symbol_30.c | 5 ----- lv_fonts/lv_font_symbol_40.c | 5 ----- lv_objx/lv_page.c | 7 +------ lv_objx/lv_win.c | 2 +- 6 files changed, 2 insertions(+), 27 deletions(-) diff --git a/lv_fonts/lv_font_symbol_10.c b/lv_fonts/lv_font_symbol_10.c index f1f1ae200..586b3d817 100644 --- a/lv_fonts/lv_font_symbol_10.c +++ b/lv_fonts/lv_font_symbol_10.c @@ -2836,13 +2836,8 @@ static const lv_font_glyph_dsc_t lv_font_symbol_10_glyph_dsc[] = { }; lv_font_t lv_font_symbol_10 = { -#if LV_TXT_UTF8 .unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/ .unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/ -#else - .unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/ - .unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/ -#endif .h_px = 10, /*Font height in pixels*/ .glyph_bitmap = lv_font_symbol_10_glyph_bitmap, /*Bitmap of glyphs*/ .glyph_dsc = lv_font_symbol_10_glyph_dsc, /*Description of glyphs*/ diff --git a/lv_fonts/lv_font_symbol_20.c b/lv_fonts/lv_font_symbol_20.c index 9bce90e0d..3a691f599 100644 --- a/lv_fonts/lv_font_symbol_20.c +++ b/lv_fonts/lv_font_symbol_20.c @@ -4836,13 +4836,8 @@ static const lv_font_glyph_dsc_t lv_font_symbol_20_glyph_dsc[] = { }; lv_font_t lv_font_symbol_20 = { -#if LV_TXT_UTF8 .unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/ .unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/ -#else - .unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/ - .unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/ -#endif .h_px = 20, /*Font height in pixels*/ .glyph_bitmap = lv_font_symbol_20_glyph_bitmap, /*Bitmap of glyphs*/ .glyph_dsc = lv_font_symbol_20_glyph_dsc, /*Description of glyphs*/ diff --git a/lv_fonts/lv_font_symbol_30.c b/lv_fonts/lv_font_symbol_30.c index 7426c6d7a..0a0f38684 100644 --- a/lv_fonts/lv_font_symbol_30.c +++ b/lv_fonts/lv_font_symbol_30.c @@ -6835,13 +6835,8 @@ static const lv_font_glyph_dsc_t lv_font_symbol_30_glyph_dsc[] = { #endif }; lv_font_t lv_font_symbol_30 = { -#if LV_TXT_UTF8 .unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/ .unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/ -#else - .unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/ - .unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/ -#endif .h_px = 30, /*Font height in pixels*/ .glyph_bitmap = lv_font_symbol_30_glyph_bitmap, /*Bitmap of glyphs*/ .glyph_dsc = lv_font_symbol_30_glyph_dsc, /*Description of glyphs*/ diff --git a/lv_fonts/lv_font_symbol_40.c b/lv_fonts/lv_font_symbol_40.c index 07c346f1e..eacbde0c9 100644 --- a/lv_fonts/lv_font_symbol_40.c +++ b/lv_fonts/lv_font_symbol_40.c @@ -8836,13 +8836,8 @@ static const lv_font_glyph_dsc_t lv_font_symbol_40_glyph_dsc[] = { }; lv_font_t lv_font_symbol_40 = { -#if LV_TXT_UTF8 .unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/ .unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/ -#else - .unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/ - .unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/ -#endif .h_px = 40, /*Font height in pixels*/ .glyph_bitmap = lv_font_symbol_40_glyph_bitmap, /*Bitmap of glyphs*/ .glyph_dsc = lv_font_symbol_40_glyph_dsc, /*Description of glyphs*/ diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index 9e19261d8..3f47b2741 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -593,15 +593,10 @@ static bool lv_scrl_design(lv_obj_t * scrl, const lv_area_t * mask, lv_design_mo lv_obj_t * page = lv_obj_get_parent(scrl); lv_style_t * style_page = lv_obj_get_style(page); lv_group_t * g = lv_obj_get_group(page); - if(style_page->body.empty || style_page->body.opa == LV_OPA_TRANSP) { /*Is the background visible?*/ + if((style_page->body.empty || style_page->body.opa == LV_OPA_TRANSP) && style_page->body.border.width == 0) { /*Is the background visible?*/ if(lv_group_get_focused(g) == page) { lv_style_t * style_mod; style_mod = lv_group_mod_style(g, style_scrl_ori); - /*Be sure the scrollable is not transparent or empty (at least it should have a border)*/ - if((style_mod->body.empty || style_mod->body.opa == LV_OPA_TRANSP) && style_mod->body.border.width == 0) { - style_mod->body.border.width = LV_DPI / 20; - style_mod->body.empty = 0; - } scrl->style_p = style_mod; /*Temporally change the style to the activated */ } } diff --git a/lv_objx/lv_win.c b/lv_objx/lv_win.c index a106c98d0..8b40c2b7c 100644 --- a/lv_objx/lv_win.c +++ b/lv_objx/lv_win.c @@ -101,7 +101,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy) lv_win_set_style(new_win, LV_WIN_STYLE_BTN_PR, th->win.btn.pr); } else { lv_win_set_style(new_win, LV_WIN_STYLE_BG, &lv_style_plain); - lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_BG, &lv_style_transp); + lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_BG, &lv_style_plain); lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_SCRL, &lv_style_transp); lv_win_set_style(new_win, LV_WIN_STYLE_HEADER, &lv_style_plain_color); }