-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecode.cpp
More file actions
38 lines (33 loc) · 820 Bytes
/
decode.cpp
File metadata and controls
38 lines (33 loc) · 820 Bytes
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
#include <iostream>
#include <chrono>
#include <exception>
#include "GPIOPin.hpp"
#include "PT22x2.hpp"
#include "Command.hpp"
using std::chrono::microseconds;
using std::cout;
using std::cin;
using std::endl;
using std::runtime_error;
void codewordHandler(PT22x2::Codeword codeword) {
try {
Command cmd(codeword);
cout << cmd << endl;
cout << codeword << endl;
}
catch (runtime_error const &e) {
// malformed codeword, just ignore it
}
}
int main() {
PT22x2::Decoder decoder(&codewordHandler);
GPIOPin pin(25);
pin.setPullDown();
pin.setEdgeHandler([&decoder] (microseconds time) {
decoder.edgeOccured(time);
});
cout << "Receiving signals ..." << endl
<< "(press return to stop)" << endl;
cin.get();
return 0;
}