-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTask32.h
More file actions
71 lines (55 loc) · 2.04 KB
/
Task32.h
File metadata and controls
71 lines (55 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// written by : Doug Reuter
// TaskManager32 - Manage task functions on 32bt arduino bords such as ( due or zero)
// may work on other arduino boards as well
// http://cheapogadget.com https://github.com/cheapogadget/Taskmanager32
// Copyright (C) 2016 Doug Reuter dougreuter@gmail.com
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Task.h
#ifndef _TASK_h
#define _TASK_h
#include "arduino.h"
#define TASK_PRIORITY_DEFAULT TASK_PRIORITY_MEDIUM
enum taskPriority
{
TASK_PRIORITY_IDLE,
TASK_PRIORITY_LOW,
TASK_PRIORITY_MEDIUM,
TASK_PRIORTY_HIGH,
TASK_PRIORITY_CRITICAL,
TASK_PRIORITY_COUNT
};
#define TASK_HISTORY_LENGTH 8
#define TASK_HISTORY_DIV >>3
class Task
{
protected:
uint32_t currentTimeStamp;
public:
const char * taskName; // Name of task
void(*taskFunc)(void); // Task function pointer
bool isEnabled; // IsEnabled = Run
uint32_t period; // Period in microseconds
/* Scheduling */
uint32_t executedLastAt; // last time of invocation
uint32_t executeNextAt; // time of invocation event for event-driven tasks
uint32_t executeLastPeriod;
uint32_t executeNextAtEstimatedFinish;
taskPriority priority; // priority
uint16_t avgerageRuntime;
uint16_t averageRuntimeHistory[TASK_HISTORY_LENGTH];
uint8_t aveargeRuntimeIndex;
bool IsNotEmpty;
Task(const char * _taskName, void(*_taskFunc)(void), uint32_t _period, taskPriority _priority = TASK_PRIORITY_DEFAULT, bool _isEnabled = true);
Task();
bool run();
};
#endif