|
6 | 6 | #include "Bezier.hpp"
|
7 | 7 |
|
8 | 8 | #define CALIBRATION_BUTTON 7
|
9 | | -#define AXIS_ARRAY_SIZE 3 |
10 | 9 | #define LED 13
|
| 10 | + |
11 | 11 | #define CENTER 512
|
12 | 12 |
|
| 13 | +#define AXIS_ARRAY_SIZE 3 |
| 14 | + |
13 | 15 | #define LINEAR 2
|
14 | 16 | #define CURVE 1
|
15 | 17 |
|
16 | | -#define ANALOG_FILTER_M_COUNT 3 |
17 | | -#define ANALOG_FILTER_M_DISCARD 1 |
18 | | - |
19 | 18 | // some pins can function as either digital or analog inputs, so we predefine
|
20 | 19 | // which will operate in which mode
|
21 | | -// X Y RX RY Th |
22 | | -/* static const int analog_pins[] = { A0, A1, A8, A9, A6 }; */ |
| 20 | +// X Y Th |
23 | 21 | static const int analog_pins[] = { A0, A1, A6 };
|
24 | | -static const int digital_pins[] = { 3, 5, 6, 7, 8, 9 }; |
| 22 | +static const int digital_pins[] = { 3, 5, 6, 7, 8, 9, 14 }; |
25 | 23 |
|
26 | 24 | struct {
|
27 | 25 | bool is_calibrated = false;
|
@@ -230,6 +228,10 @@ int axisRead(int index, int option = CURVE)
|
230 | 228 | 1023),
|
231 | 229 | 0,
|
232 | 230 | 1023);
|
| 231 | + |
| 232 | +int buttonRead(int index) |
| 233 | +{ |
| 234 | + return !digitalRead(digital_pins[index]); |
233 | 235 | }
|
234 | 236 |
|
235 | 237 | // ===========================================================================
|
@@ -258,8 +260,8 @@ void setup()
|
258 | 260 | void loop()
|
259 | 261 | {
|
260 | 262 | // read the buttons
|
261 | | - for (int i = 0; i < sizeof(digital_pins) / sizeof(int); i++) |
262 | | - joystick.setButton(i, !digitalRead(digital_pins[i])); |
| 263 | + for (int btn = 0; btn < (sizeof(digital_pins) / sizeof(int)); btn++) |
| 264 | + joystick.setButton(btn, buttonRead(btn)); |
263 | 265 |
|
264 | 266 | // read the analog inputs
|
265 | 267 | joystick.setYAxis(axisRead(0, CURVE));
|
|
0 commit comments