Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f56ea8a

Browse files
committed
rename buttons and axes arrays
1 parent e513bf0 commit f56ea8a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

‎FlightStick.ino

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
// some pins can function as either digital or analog inputs, so we predefine
1919
// which will operate in which mode
2020
// X Y Th
21-
static const int analog_pins[] = { A0, A1, A6 };
22-
static const int digital_pins[] = { 3, 5, 6, 7, 8, 9, 14 };
21+
static const int axes_pins[] = { A0, A1, A6 };
22+
static const int button_pins[] = { 3, 5, 6, 7, 8, 9, 14 };
2323

2424
struct {
2525
bool is_calibrated = false;
@@ -85,7 +85,7 @@ void calibration()
8585
Serial.println("========= Calibrating =========");
8686
for (int i = 0; i < AXIS_ARRAY_SIZE; i++) {
8787

88-
uint16_t curr = analogRead(analog_pins[i]);
88+
uint16_t curr = analogRead(axes_pins[i]);
8989
Serial.print("Axis: ");
9090
Serial.print(i);
9191
Serial.print(" - Raw Value: ");
@@ -118,11 +118,11 @@ void setupPins(void)
118118
// Set all the digital pins as inputs
119119
// with the pull-up enabled, except for the
120120
// two serial line pins
121-
for (int pin : digital_pins) {
121+
for (int pin : button_pins) {
122122
pinMode(pin, INPUT_PULLUP);
123123
}
124124

125-
for (int Ai : analog_pins) {
125+
for (int Ai : axes_pins) {
126126
pinMode(Ai, INPUT);
127127
digitalWrite(Ai, LOW);
128128
}
@@ -196,7 +196,7 @@ int axisRead(int index, int filter_total, int option = CURVE)
196196
return readToCurve(
197197
map(
198198
analogReadFilter(
199-
analog_pins[index],
199+
axes_pins[index],
200200
filter_total
201201
),
202202
calibration_data.min[index],
@@ -209,7 +209,7 @@ int axisRead(int index, int filter_total, int option = CURVE)
209209
}
210210
return map(
211211
analogReadFilter(
212-
analog_pins[index],
212+
axes_pins[index],
213213
filter_total
214214
),
215215
calibration_data.min[index],
@@ -221,7 +221,7 @@ int axisRead(int index, int filter_total, int option = CURVE)
221221

222222
int buttonRead(int index)
223223
{
224-
return !digitalRead(digital_pins[index]);
224+
return !digitalRead(button_pins[index]);
225225
}
226226

227227
// ===========================================================================
@@ -250,7 +250,7 @@ void setup()
250250
void loop()
251251
{
252252
// read the buttons
253-
for (int btn = 0; btn < (sizeof(digital_pins) / sizeof(int)); btn++)
253+
for (int btn = 0; btn < (sizeof(button_pins) / sizeof(int)); btn++)
254254
joystick.setButton(btn, buttonRead(btn));
255255

256256
// read the axes

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /