@@ -69,27 +69,36 @@ void testMultiButtonPush(unsigned int currentStep)
69
69
70
70
void testXYAxis (unsigned int currentStep)
71
71
{
72
+ int xAxis;
73
+ int yAxis;
74
+
72
75
if (currentStep < 256 )
73
76
{
74
- Joystick.setXAxis (currentStep - 127 );
75
- Joystick.setYAxis (-127 );
77
+ xAxis = currentStep - 127 ;
78
+ yAxis = -127 ;
79
+ Joystick.setXAxis (xAxis);
80
+ Joystick.setYAxis (yAxis);
76
81
}
77
82
else if (currentStep < 512 )
78
83
{
79
- Joystick.setYAxis (currentStep - 256 - 127 );
84
+ yAxis = currentStep - 256 - 127 ;
85
+ Joystick.setYAxis (yAxis);
80
86
}
81
87
else if (currentStep < 768 )
82
88
{
83
- Joystick.setXAxis (128 - (currentStep - 512 ));
89
+ xAxis = 128 - (currentStep - 512 );
90
+ Joystick.setXAxis (xAxis);
84
91
}
85
92
else if (currentStep < 1024 )
86
93
{
87
- Joystick.setYAxis (128 - (currentStep - 768 ));
94
+ yAxis = 128 - (currentStep - 768 );
95
+ Joystick.setYAxis (yAxis);
88
96
}
89
97
else if (currentStep < 1024 + 128 )
90
98
{
91
- Joystick.setXAxis (currentStep - 1024 - 127 );
92
- Joystick.setYAxis (currentStep - 1024 - 127 );
99
+ xAxis = currentStep - 1024 - 127 ;
100
+ Joystick.setXAxis (xAxis);
101
+ Joystick.setYAxis (xAxis);
93
102
}
94
103
}
95
104
@@ -150,13 +159,30 @@ void testThrottleRudder(unsigned int value)
150
159
Joystick.setRudder (255 - value);
151
160
}
152
161
153
- void testXYAxisRotation (unsigned int degree)
162
+ void testXYZAxisRotation (unsigned int degree)
154
163
{
155
- Joystick.setXAxisRotation (degree);
156
- Joystick.setYAxisRotation (360 - degree);
164
+ Joystick.setRxAxis (degree);
165
+ Joystick.setRyAxis (360 - degree);
166
+ Joystick.setRzAxis (degree * 2 );
157
167
}
158
168
159
169
void setup () {
170
+
171
+ /*
172
+ * Uncomment this out for debugging...
173
+ Serial.begin(9600);
174
+ while (!Serial) {
175
+ ; // wait for serial port to connect. Needed for native USB
176
+ }
177
+ */
178
+
179
+ Joystick.setXAxisRange (-127 , 127 );
180
+ Joystick.setYAxisRange (-127 , 127 );
181
+ Joystick.setZAxisRange (-127 , 127 );
182
+ Joystick.setRxAxisRange (0 , 360 );
183
+ Joystick.setRyAxisRange (0 , 360 );
184
+ Joystick.setRzAxisRange (0 , 720 );
185
+
160
186
if (testAutoSendMode)
161
187
{
162
188
Joystick.begin ();
@@ -175,6 +201,7 @@ void loop() {
175
201
// System Disabled
176
202
if (digitalRead (A0) != 0 )
177
203
{
204
+ // Turn indicator light off.
178
205
digitalWrite (13 , 0 );
179
206
return ;
180
207
}
@@ -218,7 +245,7 @@ void loop() {
218
245
else if (gCurrentStep < (37 + 256 + 1024 + 128 + 510 + 28 + 360 ))
219
246
{
220
247
gNextTime = millis () + gcAnalogDelta;
221
- testXYAxisRotation (gCurrentStep - (37 + 256 + 1024 + 128 + 510 + 28 ));
248
+ testXYZAxisRotation (gCurrentStep - (37 + 256 + 1024 + 128 + 510 + 28 ));
222
249
}
223
250
224
251
if (testAutoSendMode == false )
0 commit comments