这样是能用的, 先提交一波

This commit is contained in:
zogodo
2019-12-26 21:49:57 +08:00
parent 764cfcfd94
commit 08b4dc8c35
5 changed files with 10 additions and 3 deletions

View File

@@ -79,7 +79,9 @@
<fieldset class="task"> <fieldset class="task">
<legend>Timed Task</legend> <legend>Timed Task</legend>
<button onclick="GetTimedTask()">Test</button> <input type="number" id="task_time"/>
<button onclick="AddTimedTask()">Add</button>
<button onclick="GetTimedTask()">Get</button>
</fieldset> </fieldset>
<fieldset class="chart"> <fieldset class="chart">

File diff suppressed because one or more lines are too long

View File

@@ -179,7 +179,7 @@ int application_start(void)
} }
else else
{ {
os_log("task_top[%u]"); os_log("timed task count[%u]", task_count);
} }
mico_thread_msleep(1000); mico_thread_msleep(1000);
} }

View File

@@ -2,6 +2,7 @@
#include<stdlib.h> #include<stdlib.h>
#include<string.h> #include<string.h>
#include<stdbool.h> #include<stdbool.h>
#include<time.h>
#include"timed_task/timed_task.h" #include"timed_task/timed_task.h"
pTimedTask task_top = NULL; pTimedTask task_top = NULL;
@@ -65,6 +66,7 @@ bool DelTask(int time)
pTimedTask tmp = task_top; pTimedTask tmp = task_top;
task_top = task_top->next; task_top = task_top->next;
free(tmp); free(tmp);
task_count--;
return true; return true;
} }
else if (task_top->next == NULL) else if (task_top->next == NULL)
@@ -80,6 +82,8 @@ bool DelTask(int time)
{ {
pre_tsk->next = tmp_tsk->next; pre_tsk->next = tmp_tsk->next;
free(tmp_tsk); free(tmp_tsk);
task_count--;
return true;
} }
tmp_tsk = tmp_tsk->next; tmp_tsk = tmp_tsk->next;
} }

View File

@@ -11,6 +11,7 @@ struct TimedTask
}; };
extern pTimedTask task_top; extern pTimedTask task_top;
extern int task_count;
bool AddTask(pTimedTask task); bool AddTask(pTimedTask task);
bool DelTask(int time); bool DelTask(int time);