-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoardContainer.cpp
49 lines (42 loc) · 912 Bytes
/
BoardContainer.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
#include "BoardContainer.h"
BoardContainer::BoardContainer() {
setupCorrectPinOrder();
dartsBoard = new Keypad(makeKeymap(dKeys), setupDRP, setupDCP, DROWS, DCOLS);
dartsBoard->setDebounceTime(200);
dartsBoard->setHoldTime(500);
}
void BoardContainer::setupCorrectPinOrder() {
for(int i = 0; i < 8; i++) {
if(boardSetup[0]) {
setupDRP[7 - i] = dRowPins[i];
}
else {
setupDRP[i] = dRowPins[i];
}
if(boardSetup[1]) {
setupDCP[7 - i] = dColPins[i];
}
else {
setupDCP[i] = dColPins[i];
}
}
if(boardSetup[2]) {
for(int i = 0; i < 8; i++) {
int temp = setupDRP[i];
setupDRP[i] = setupDCP[i];
setupDCP[i] = temp;
}
}
}
Sector BoardContainer::sectorMapping(char x) {
Sector dart;
if (x < 61) {
dart.base = (x - 1) % 20 + 1;
dart.multiplier = (x - 1) / 20 + 1;
}
else {
dart.base = 25;
dart.multiplier = x % 60 == 1 ? 1 : 2;
}
return dart;
}