-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
73 lines (60 loc) · 1.7 KB
/
main.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <algorithm>
#include <atomic>
#include <chrono>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <memory>
#include <mutex>
#include <sstream>
#include <string>
#include <thread>
#include <vector>
#include "gpio_input.h"
#include "gpio_output.h"
#include "gpio_blinking_output.h"
using namespace std;
void gpioControllerTask();
// Inputs (Optocoupler): 17, 27, 23, 22, 24, 25, 8, 7
// Outputs (Open Collector): 6, 5, 1, 0
// Outputs (Relay): 26, 20, 16
GPIO_Input in1(17);
GPIO_Input in2(27);
GPIO_Input in3(23);
GPIO_Input in4(22);
GPIO_Input in5(24);
GPIO_Input in6(25);
GPIO_Input in7(8);
GPIO_Input in8(7);
GPIO_Output out1(6);
GPIO_Output out2(5);
GPIO_Output out3(1);
GPIO_Output out4(0);
GPIO_BlinkingOutput relay1(26);
GPIO_BlinkingOutput relay2(20);
GPIO_BlinkingOutput relay3(16);
void gpioControllerTask();
int main(int argc, char* argv[]) {
std::thread gpioControllerThread(gpioControllerTask);
gpioControllerThread.join();
return EXIT_SUCCESS;
}
void gpioControllerTask() {
relay1.blink();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
relay2.blink();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
relay3.blink();
uint32_t i = 0;
while (true) {
out1.write(i & 1 << 0);
out2.write(i & 1 << 1);
out3.write(i & 1 << 2);
out4.write(i & 1 << 3);
++i;
std::cout << in1.read() << " " << in2.read() << " " << in3.read() << " " << in4.read() << " " << in5.read() << " " << in6.read() << " " << in7.read() << " " << in8.read() << " " << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(200));
}
}