gc: add undescore to roots, arranged lv_mem.c regarding gc defines. Added support to Symbols using the numstr technique of encoding the characters as a number in an enum. Globals: register them directly witout the need for constructor to access them. Updated example code. Updated lv_mpy.c
This commit is contained in:
@@ -51,7 +51,7 @@ static bool task_created;
|
||||
*/
|
||||
void lv_task_init(void)
|
||||
{
|
||||
lv_ll_init(&LV_GC_ROOT(lv_task_ll), sizeof(lv_task_t));
|
||||
lv_ll_init(&LV_GC_ROOT(_lv_task_ll), sizeof(lv_task_t));
|
||||
|
||||
/*Initially enable the lv_task handling*/
|
||||
lv_task_enable(true);
|
||||
@@ -87,33 +87,33 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void)
|
||||
end_flag = true;
|
||||
task_deleted = false;
|
||||
task_created = false;
|
||||
LV_GC_ROOT(task_act) = lv_ll_get_head(&LV_GC_ROOT(lv_task_ll));
|
||||
while(LV_GC_ROOT(task_act)) {
|
||||
LV_GC_ROOT(_task_act) = lv_ll_get_head(&LV_GC_ROOT(_lv_task_ll));
|
||||
while(LV_GC_ROOT(_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_GC_ROOT(lv_task_ll), LV_GC_ROOT(task_act));
|
||||
next = lv_ll_get_next(&LV_GC_ROOT(_lv_task_ll), LV_GC_ROOT(_task_act));
|
||||
|
||||
/*We reach priority of the turned off task. There is nothing more to do.*/
|
||||
if(((lv_task_t *)LV_GC_ROOT(task_act))->prio == LV_TASK_PRIO_OFF) {
|
||||
if(((lv_task_t *)LV_GC_ROOT(_task_act))->prio == LV_TASK_PRIO_OFF) {
|
||||
break;
|
||||
}
|
||||
|
||||
/*Here is the interrupter task. Don't execute it again.*/
|
||||
if(LV_GC_ROOT(task_act) == task_interrupter) {
|
||||
if(LV_GC_ROOT(_task_act) == task_interrupter) {
|
||||
task_interrupter = NULL; /*From this point only task after the interrupter comes, so the interrupter is not interesting anymore*/
|
||||
LV_GC_ROOT(task_act) = next;
|
||||
LV_GC_ROOT(_task_act) = next;
|
||||
continue; /*Load the next task*/
|
||||
}
|
||||
|
||||
/*Just try to run the tasks with highest priority.*/
|
||||
if(((lv_task_t *)LV_GC_ROOT(task_act))->prio == LV_TASK_PRIO_HIGHEST) {
|
||||
lv_task_exec(LV_GC_ROOT(task_act));
|
||||
if(((lv_task_t *)LV_GC_ROOT(_task_act))->prio == LV_TASK_PRIO_HIGHEST) {
|
||||
lv_task_exec(LV_GC_ROOT(_task_act));
|
||||
}
|
||||
/*Tasks with higher priority then the interrupted shall be run in every case*/
|
||||
else if(task_interrupter) {
|
||||
if(((lv_task_t *)LV_GC_ROOT(task_act))->prio > task_interrupter->prio) {
|
||||
if(lv_task_exec(LV_GC_ROOT(task_act))) {
|
||||
task_interrupter = LV_GC_ROOT(task_act); /*Check all tasks again from the highest priority */
|
||||
if(((lv_task_t *)LV_GC_ROOT(_task_act))->prio > task_interrupter->prio) {
|
||||
if(lv_task_exec(LV_GC_ROOT(_task_act))) {
|
||||
task_interrupter = LV_GC_ROOT(_task_act); /*Check all tasks again from the highest priority */
|
||||
end_flag = false;
|
||||
break;
|
||||
}
|
||||
@@ -122,8 +122,8 @@ 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(LV_GC_ROOT(task_act))) {
|
||||
task_interrupter = LV_GC_ROOT(task_act); /*Check all tasks again from the highest priority */
|
||||
if(lv_task_exec(LV_GC_ROOT(_task_act))) {
|
||||
task_interrupter = LV_GC_ROOT(_task_act); /*Check all tasks again from the highest priority */
|
||||
end_flag = false;
|
||||
break;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void)
|
||||
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*/
|
||||
|
||||
LV_GC_ROOT(task_act) = next; /*Load the next task*/
|
||||
LV_GC_ROOT(_task_act) = next; /*Load the next task*/
|
||||
}
|
||||
} while(!end_flag);
|
||||
|
||||
@@ -167,24 +167,24 @@ lv_task_t * lv_task_create(void (*task)(void *), uint32_t period, lv_task_prio_t
|
||||
lv_task_t * tmp;
|
||||
|
||||
/*Create task lists in order of priority from high to low*/
|
||||
tmp = lv_ll_get_head(&LV_GC_ROOT(lv_task_ll));
|
||||
tmp = lv_ll_get_head(&LV_GC_ROOT(_lv_task_ll));
|
||||
if(NULL == tmp) { /*First task*/
|
||||
new_lv_task = lv_ll_ins_head(&LV_GC_ROOT(lv_task_ll));
|
||||
new_lv_task = lv_ll_ins_head(&LV_GC_ROOT(_lv_task_ll));
|
||||
lv_mem_assert(new_lv_task);
|
||||
if(new_lv_task == NULL) return NULL;
|
||||
} else {
|
||||
do {
|
||||
if(tmp->prio <= prio) {
|
||||
new_lv_task = lv_ll_ins_prev(&LV_GC_ROOT(lv_task_ll), tmp);
|
||||
new_lv_task = lv_ll_ins_prev(&LV_GC_ROOT(_lv_task_ll), tmp);
|
||||
lv_mem_assert(new_lv_task);
|
||||
if(new_lv_task == NULL) return NULL;
|
||||
break;
|
||||
}
|
||||
tmp = lv_ll_get_next(&LV_GC_ROOT(lv_task_ll), tmp);
|
||||
tmp = lv_ll_get_next(&LV_GC_ROOT(_lv_task_ll), tmp);
|
||||
} while(tmp != NULL);
|
||||
|
||||
if(tmp == NULL) { /*Only too high priority tasks were found*/
|
||||
new_lv_task = lv_ll_ins_tail(&LV_GC_ROOT(lv_task_ll));
|
||||
new_lv_task = lv_ll_ins_tail(&LV_GC_ROOT(_lv_task_ll));
|
||||
lv_mem_assert(new_lv_task);
|
||||
if(new_lv_task == NULL) return NULL;
|
||||
}
|
||||
@@ -208,11 +208,11 @@ lv_task_t * lv_task_create(void (*task)(void *), uint32_t period, lv_task_prio_t
|
||||
*/
|
||||
void lv_task_del(lv_task_t * lv_task_p)
|
||||
{
|
||||
lv_ll_rem(&LV_GC_ROOT(lv_task_ll), lv_task_p);
|
||||
lv_ll_rem(&LV_GC_ROOT(_lv_task_ll), lv_task_p);
|
||||
|
||||
lv_mem_free(lv_task_p);
|
||||
|
||||
if(LV_GC_ROOT(task_act) == lv_task_p) task_deleted = true; /*The active task was deleted*/
|
||||
if(LV_GC_ROOT(_task_act) == lv_task_p) task_deleted = true; /*The active task was deleted*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,16 +224,16 @@ void lv_task_set_prio(lv_task_t * lv_task_p, lv_task_prio_t prio)
|
||||
{
|
||||
/*Find the tasks with new priority*/
|
||||
lv_task_t * i;
|
||||
LL_READ(LV_GC_ROOT(lv_task_ll), i) {
|
||||
LL_READ(LV_GC_ROOT(_lv_task_ll), i) {
|
||||
if(i->prio <= prio) {
|
||||
if(i != lv_task_p) lv_ll_move_before(&LV_GC_ROOT(lv_task_ll), lv_task_p, i);
|
||||
if(i != lv_task_p) lv_ll_move_before(&LV_GC_ROOT(_lv_task_ll), lv_task_p, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*There was no such a low priority so far then add the node to the tail*/
|
||||
if(i == NULL) {
|
||||
lv_ll_move_before(&LV_GC_ROOT(lv_task_ll), lv_task_p, NULL);
|
||||
lv_ll_move_before(&LV_GC_ROOT(_lv_task_ll), lv_task_p, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user