Arduino-Scheduler
Portable Collaborative Multi-Tasking Scheduler for Arduino
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
SchedulerTaskMax.ino
Go to the documentation of this file.
1
23
#include <
Scheduler.h
>
24
25
// Check for SparkFun SAMD21 Breakout
26
#if defined(ARDUINO_ARCH_SAMD) && (USB_PID == 0x8D21)
27
#define Serial SerialUSB
28
#endif
29
30
#if defined(ARDUINO_ARCH_AVR)
31
const
size_t
STACK_SIZE
= 64;
32
#else
33
const
size_t
STACK_SIZE
= 128;
34
#endif
35
36
unsigned
long
count
= 0L;
37
38
void
setup
()
39
{
40
Serial.begin(57600);
41
while
(!Serial);
42
Serial.println(F(
"SchedulerTaskMax: started"
));
43
Serial.flush();
44
45
int
tasks = 0;
46
while
(
Scheduler
.
startLoop
(
counter
,
STACK_SIZE
)) tasks++;
47
Serial.print(millis());
48
Serial.print(F(
":setup::task="
));
49
Serial.println(tasks);
50
yield
();
51
Serial.print(millis());
52
Serial.print(F(
":setup::count="
));
53
Serial.println(
count
);
54
}
55
56
void
loop
()
57
{
58
count
= 0;
59
unsigned
long
start = millis();
60
await
((millis() - start) >= 1000);
61
Serial.print(millis() - start);
62
Serial.print(F(
":loop::count="
));
63
Serial.println(
count
);
64
}
65
66
void
counter
()
67
{
68
count
+= 1;
69
yield
();
70
}
STACK_SIZE
const size_t STACK_SIZE
Definition:
SchedulerTaskMax.ino:33
SchedulerClass::startLoop
static bool startLoop(func_t taskLoop, size_t stackSize=DEFAULT_STACK_SIZE)
Definition:
Scheduler.h:65
await
#define await(cond)
Definition:
Scheduler.h:162
count
unsigned long count
Definition:
SchedulerTaskMax.ino:36
counter
void counter()
Definition:
SchedulerTaskMax.ino:66
setup
void setup()
Definition:
SchedulerTaskMax.ino:38
Scheduler
SchedulerClass Scheduler
Definition:
Scheduler.cpp:53
yield
void yield(void)
Definition:
Scheduler.cpp:153
loop
void loop()
Definition:
SchedulerTaskMax.ino:56
Scheduler.h
examples
SchedulerTaskMax
SchedulerTaskMax.ino
Generated on Thu Aug 31 2017 12:52:30 for Arduino-Scheduler by
1.8.11