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 diff --git a/lv_misc/lv_ll.c b/lv_misc/lv_ll.c index d12de91f1..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 */ @@ -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_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 */ 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; } 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; 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 {