-
Notifications
You must be signed in to change notification settings - Fork 0
/
object_threads.cpp
54 lines (45 loc) · 963 Bytes
/
object_threads.cpp
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
#include "oosmos.hpp"
#include "os.hpp"
#include <iostream>
#include <cstdint>
using namespace std;
struct cMyObject : public OOSMOS::cObject
{
OOSMOS::cStack BlinkingThread_Stack;
void BlinkingThread(OOSMOS::cStack& rStack)
{
ThreadBegin();
for (;;) {
cout << "BlinkingThread: LED On" << endl;
ThreadDelayMS(250);
cout << "BlinkingThread: LED Off" << endl;
ThreadDelayMS(750);
}
ThreadEnd();
}
OOSMOS::cStack BeepingThread_Stack;
uint32_t m_BeepCount = 0;
void BeepingThread(OOSMOS::cStack& rStack)
{
ThreadBegin();
for (;;) {
m_BeepCount += 1;
cout << "BeepingThread: Beep " << m_BeepCount << endl;
ThreadDelaySeconds(2);
}
ThreadEnd();
}
void Run()
{
BlinkingThread(BlinkingThread_Stack);
BeepingThread(BeepingThread_Stack);
}
};
int main()
{
cMyObject MyObject;
for (;;) {
OOSMOS::Run();
OS::DelayMS(1);
}
}