-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
53 lines (37 loc) · 1.02 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
#include <Windows.h>
#include "SerialPort.h"
#include "KeyboardLegend.h"
using namespace std;
/*void RunLEDTest() {
while (true) {
for (int i = 0; i < 128; i++) {
bytesToWrite[i] = 255;
sp.WriteBytes(bytesToWrite, sizeof(bytesToWrite));
Sleep(WRITE_SLEEP_TIME);
}
for (int i = 127; i >= 0; i--) {
bytesToWrite[i] = 0;
sp.WriteBytes(bytesToWrite, sizeof(bytesToWrite));
Sleep(WRITE_SLEEP_TIME);
}
}
}*/
int main() {
KeyboardLegend keyboard;
SerialPort sp("COM4", true, true);
unsigned char bytesToWrite[1] = {0};
unsigned int buffer[256] = {0};
unsigned int singleBuffer = 0;
while (true) {
sp.ReadTheLonelyByte(singleBuffer);
cout << singleBuffer << endl;
sp.WriteBytes(bytesToWrite, 1);
}
if(sp.Close()) {
cout << "Successfully closed SerialPort" << endl;
}
else {
cout << "Could not close SerialPort" << endl;
}
return 0;
}