-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controller_Commands.h
125 lines (95 loc) · 2.83 KB
/
Controller_Commands.h
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef CONTROLLER_COMMANDS_H
#define CONTROLLER_COMMANDS_H
class ControllerCommands{
unsigned long pushTime = 0;
bool secondLoop = false;
public:
void updateButtons()
{
if (ps5.Right())
{
}
if (ps5.Down())
{
}
if (ps5.Up())
{
}
if (ps5.Left())
{
}
if (ps5.UpRight())
{
// leftAnalog.updateValue(128, 128);
}
if (ps5.DownRight())
{
// leftAnalog.updateValue(128, -128);
}
if (ps5.UpLeft())
{
// leftAnalog.updateValue(-128, 128);
}
if (ps5.DownLeft())
{
// leftAnalog.updateValue(-128, -128);
}
if (ps5.Square())
{
}
if (ps5.Cross())
{
digitalWrite(19, HIGH);
Serial.println("HONK");
} else{
digitalWrite(19, LOW);
}
if (ps5.Circle())
{
}
if (ps5.Triangle())
{
}
if (ps5.L1())
{
}
if (ps5.R1())
{
}
if (ps5.Share())
{
}
if (ps5.Options())
{
}
if (ps5.L3())
{
}
if (ps5.R3())
{
}
if (ps5.PSButton())
{
}
if (ps5.Touchpad())
{
// Killswitch the robot. To turn off, restart the robot.
// diffDrive.killswitch();
// while(true);
}
if (ps5.L2() >= 128) {
// Serial.printf("L2 button at %d\n", ps5.L2Value());
}
if (ps5.R2() >= 128) {
// Serial.printf("R2 button at %d\n", ps5.R2Value());
}
// if no buttons are pressed
if(!ps5.Right() && !ps5.Right() && !ps5.Down() && !ps5.Left() && !ps5.UpLeft() && !ps5.UpRight() && !ps5.DownLeft() && !ps5.DownRight() && !ps5.Square() && !ps5.Cross() && !ps5.Circle() && !ps5.Triangle() && !ps5.L1() && !ps5.R1() && !ps5.Share() && !ps5.Options() && !ps5.L3() && !ps5.R3() && !ps5.PSButton() && !ps5.Touchpad() && !ps5.L2() && !ps5.R2())
{
secondLoop = false;
pushTime = millis();
}
}
};
ControllerCommands controllerCommands;
#endif