Arduino-Scheduler
Portable Collaborative Multi-Tasking Scheduler for Arduino
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
SchedulerEventQueue.ino
Go to the documentation of this file.
1
23
#include <
Scheduler.h
>
24
#include <
Scheduler/Queue.h
>
25
26
// Check for SparkFun SAMD21 Breakout
27
#if defined(ARDUINO_ARCH_SAMD) && (USB_PID == 0x8D21)
28
#define Serial SerialUSB
29
#endif
30
31
Queue<unsigned int, 8>
eventq
;
32
33
void
setup
()
34
{
35
Serial.begin(57600);
36
while
(!Serial);
37
Serial.println(F(
"SchedulerEventQueue: started"
));
38
Serial.flush();
39
40
// Start two event handlers
41
Scheduler
.
startLoop
(
eventHandler
);
42
Scheduler
.
startLoop
(
eventHandler
);
43
}
44
45
void
loop
()
46
{
47
// Push events
48
static
unsigned
int
event
= 0;
49
Serial.print(millis());
50
Serial.print(F(
":loop::push event="
));
51
Serial.println(
event
);
52
eventq.
push
(&
event
);
53
event
+= 1;
54
55
// Random processing time
56
delay(random(500));
57
}
58
59
void
eventHandler
()
60
{
61
// Pull events
62
unsigned
int
event
;
63
eventq.
pull
(&event);
64
Serial.print(millis());
65
Serial.print(F(
":eventHandler#"
));
66
Serial.print((
int
) &event);
67
Serial.print(F(
"::pull event="
));
68
Serial.println(event);
69
70
// Random service time
71
delay(random(1000));
72
}
eventq
Queue< unsigned int, 8 > eventq
Definition:
SchedulerEventQueue.ino:31
Queue::pull
void pull(T *data)
Definition:
Queue.h:90
Queue::push
void push(const T *data)
Definition:
Queue.h:64
SchedulerClass::startLoop
static bool startLoop(func_t taskLoop, size_t stackSize=DEFAULT_STACK_SIZE)
Definition:
Scheduler.h:65
Queue
Definition:
Queue.h:28
Queue.h
event
Event event
Definition:
SchedulerEvent.ino:72
setup
void setup()
Definition:
SchedulerEventQueue.ino:33
eventHandler
void eventHandler()
Definition:
SchedulerEventQueue.ino:59
Scheduler
SchedulerClass Scheduler
Definition:
Scheduler.cpp:53
Scheduler.h
loop
void loop()
Definition:
SchedulerEventQueue.ino:45
examples
SchedulerEventQueue
SchedulerEventQueue.ino
Generated on Thu Aug 31 2017 12:52:30 for Arduino-Scheduler by
1.8.11