|
@@ -29,49 +29,8 @@
|
29
|
29
|
#define MODE_BUTTON_RED 25
|
30
|
30
|
|
31
|
31
|
JoystickEventsButtons::JoystickEventsButtons(X52* x, JoystickEvents* client)
|
32
|
|
- : JoystickEvents(client), x52(x), state(NONE), index(0), value(0), menuTime(0) { }
|
33
|
|
-
|
34
|
|
-void JoystickEventsButtons::menuHelper(uint8_t count, const char** menu, const char* title) {
|
35
|
|
- if (index >= count) {
|
36
|
|
- index = count - 1;
|
37
|
|
- }
|
38
|
|
-
|
39
|
|
- uint8_t start = 0, line = 0;
|
40
|
|
- if (index > 1) {
|
41
|
|
- start = index - 1;
|
42
|
|
- }
|
43
|
|
-
|
44
|
|
- uint8_t end = start + 2;
|
45
|
|
- if (index == 0) {
|
46
|
|
- x52->setMFDText(0, title);
|
47
|
|
- line = 1;
|
48
|
|
- end = start + 1;
|
49
|
|
- }
|
50
|
|
-
|
51
|
|
- if (end >= count) {
|
52
|
|
- end = count - 1;
|
53
|
|
- }
|
54
|
|
-
|
55
|
|
- for (uint8_t i = start; i <= end; i++) {
|
56
|
|
- String tmp = (index == i) ? "-> " : " ";
|
57
|
|
- x52->setMFDText(line++, (tmp + menu[i]).c_str());
|
58
|
|
- }
|
59
|
|
-
|
60
|
|
- if (line == 2) {
|
61
|
|
- x52->setMFDText(2);
|
62
|
|
- }
|
63
|
|
-
|
64
|
|
-#ifdef DEBUG_OUTPUT
|
65
|
|
- Serial.print("menuHelper() state=");
|
66
|
|
- Serial.print(state);
|
67
|
|
- Serial.print(" index=");
|
68
|
|
- Serial.print(index);
|
69
|
|
- Serial.print(" start=");
|
70
|
|
- Serial.print(start);
|
71
|
|
- Serial.print(" end=");
|
72
|
|
- Serial.println(end);
|
73
|
|
-#endif
|
74
|
|
-}
|
|
32
|
+ : JoystickEvents(client), x52(x), state(NONE), index(0),
|
|
33
|
+ value(0), signedValue(0), menuTime(0) { }
|
75
|
34
|
|
76
|
35
|
void JoystickEventsButtons::printMenu() {
|
77
|
36
|
static const char* mainMenu[] = {
|
|
@@ -96,7 +55,11 @@ void JoystickEventsButtons::printMenu() {
|
96
|
55
|
};
|
97
|
56
|
static const uint8_t endpointMenuCount = sizeof(endpointMenu) / sizeof(endpointMenu[0]);
|
98
|
57
|
|
99
|
|
- if (state == MAINMENU) {
|
|
58
|
+ if (state == NONE) {
|
|
59
|
+ x52->setMFDText(0, "Telemetry Status");
|
|
60
|
+ x52->setMFDText(1, "???% ???%");
|
|
61
|
+ x52->setMFDText(2, "??.?V ??.?V");
|
|
62
|
+ } else if (state == MAINMENU) {
|
100
|
63
|
menuHelper(mainMenuCount, mainMenu, "Main Menu");
|
101
|
64
|
} else if (state == CPPMMENU) {
|
102
|
65
|
menuHelper(cppmMenuCount, cppmMenu, "CPPM Config Menu");
|
|
@@ -107,42 +70,31 @@ void JoystickEventsButtons::printMenu() {
|
107
|
70
|
} else if (state == INVERTAXISMENU) {
|
108
|
71
|
menuHelper(axisMenuCount, axisMenu, "Invert Axis Menu");
|
109
|
72
|
} else if (state == EDIT_CHANNELS) {
|
110
|
|
- printValue(4, CHANNELS_MAX, mainMenu[0]);
|
|
73
|
+ printValue(4, CHANNELS_MAX, cppmMenu[0]);
|
111
|
74
|
} else if (state == EDIT_FRAME_LENGTH) {
|
112
|
|
- printValue(10000, 30000, mainMenu[1]);
|
|
75
|
+ printValue(10000, 30000, cppmMenu[1]);
|
113
|
76
|
} else if (state == EDIT_PULSE_LENGTH) {
|
114
|
|
- printValue(100, 1000, mainMenu[2]);
|
|
77
|
+ printValue(100, 1000, cppmMenu[2]);
|
115
|
78
|
} else if (state == EDIT_INVERT) {
|
116
|
|
- printValue(0, 1, mainMenu[3]);
|
|
79
|
+ printValue(0, 1, cppmMenu[3]);
|
|
80
|
+ } else if ((state >= EDIT_INVERT_ROLL) && (state <= EDIT_INVERT_AUX2)) {
|
|
81
|
+ uint8_t index = state - EDIT_INVERT_ROLL;
|
|
82
|
+ printValue(0, 1, (String("Invert ") + axisMenu[index]).c_str());
|
|
83
|
+ } else if ((state >= EDIT_MIN_ROLL) && (state <= EDIT_MAX_AUX2)) {
|
|
84
|
+ uint8_t index = state - EDIT_MIN_ROLL;
|
|
85
|
+ if (index & 0x01) {
|
|
86
|
+ printValue(1500, 2500, endpointMenu[index]);
|
|
87
|
+ } else {
|
|
88
|
+ printValue(500, 1500, endpointMenu[index]);
|
|
89
|
+ }
|
|
90
|
+ } else if ((state >= EDIT_TRIM_ROLL) && (state <= EDIT_TRIM_AUX2)) {
|
|
91
|
+ uint8_t index = state - EDIT_TRIM_ROLL;
|
|
92
|
+ printSignedValue(-100, 100, (String("Trim ") + axisMenu[index]).c_str());
|
117
|
93
|
}
|
118
|
94
|
|
119
|
95
|
menuTime = millis();
|
120
|
96
|
}
|
121
|
97
|
|
122
|
|
-void JoystickEventsButtons::printValue(uint16_t min, uint16_t max, const char* title) {
|
123
|
|
-#ifdef DEBUG_OUTPUT
|
124
|
|
- Serial.print("printValue() state=");
|
125
|
|
- Serial.print(state);
|
126
|
|
- Serial.print(" index=");
|
127
|
|
- Serial.print(index);
|
128
|
|
- Serial.print(" min=");
|
129
|
|
- Serial.print(min);
|
130
|
|
- Serial.print(" max=");
|
131
|
|
- Serial.println(max);
|
132
|
|
-#endif
|
133
|
|
-
|
134
|
|
- if (value < min) {
|
135
|
|
- value = min;
|
136
|
|
- }
|
137
|
|
- if (value > max) {
|
138
|
|
- value = max;
|
139
|
|
- }
|
140
|
|
-
|
141
|
|
- x52->setMFDText(0, (String(title) + ":").c_str());
|
142
|
|
- x52->setMFDText(1, String(value).c_str());
|
143
|
|
- x52->setMFDText(2, "Press OK to save");
|
144
|
|
-}
|
145
|
|
-
|
146
|
98
|
void JoystickEventsButtons::OnButtonDown(uint8_t but_id) {
|
147
|
99
|
#ifdef DEBUG_BUTTON_MFD
|
148
|
100
|
String text = "Button " + String(but_id) + " down";
|
|
@@ -166,53 +118,102 @@ void JoystickEventsButtons::OnButtonDown(uint8_t but_id) {
|
166
|
118
|
if (index == 0) {
|
167
|
119
|
state = NONE;
|
168
|
120
|
} else if (index == 1) {
|
169
|
|
- //state = TRIMAXISMENU;
|
170
|
|
- //index = 0;
|
|
121
|
+ state = TRIMAXISMENU;
|
|
122
|
+ index = 0;
|
171
|
123
|
} else if (index == 2) {
|
172
|
|
- //state = TRIMENDPOINTMENU;
|
173
|
|
- //index = 0;
|
|
124
|
+ state = TRIMENDPOINTMENU;
|
|
125
|
+ index = 0;
|
174
|
126
|
} else if (index == 3) {
|
175
|
|
- //state = INVERTAXISMENU;
|
176
|
|
- //index = 0;
|
|
127
|
+ state = INVERTAXISMENU;
|
|
128
|
+ index = 0;
|
177
|
129
|
} else if (index == 4) {
|
178
|
130
|
state = CPPMMENU;
|
179
|
131
|
index = 0;
|
180
|
132
|
}
|
181
|
133
|
} else if (state == TRIMAXISMENU) {
|
182
|
134
|
if (index == 0) {
|
|
135
|
+ state = EDIT_TRIM_ROLL;
|
|
136
|
+ signedValue = joyCPPM.getTrim(CHANNEL_ROLL);
|
183
|
137
|
} else if (index == 1) {
|
|
138
|
+ state = EDIT_TRIM_PITCH;
|
|
139
|
+ signedValue = joyCPPM.getTrim(CHANNEL_PITCH);
|
184
|
140
|
} else if (index == 2) {
|
|
141
|
+ state = EDIT_TRIM_YAW;
|
|
142
|
+ signedValue = joyCPPM.getTrim(CHANNEL_YAW);
|
185
|
143
|
} else if (index == 3) {
|
|
144
|
+ state = EDIT_TRIM_THROTTLE;
|
|
145
|
+ signedValue = joyCPPM.getTrim(CHANNEL_THROTTLE);
|
186
|
146
|
} else if (index == 4) {
|
|
147
|
+ state = EDIT_TRIM_AUX1;
|
|
148
|
+ signedValue = joyCPPM.getTrim(CHANNEL_AUX1);
|
187
|
149
|
} else if (index == 5) {
|
|
150
|
+ state = EDIT_TRIM_AUX2;
|
|
151
|
+ signedValue = joyCPPM.getTrim(CHANNEL_AUX2);
|
188
|
152
|
} else if (index == 6) {
|
189
|
153
|
state = MAINMENU;
|
190
|
154
|
index = 0;
|
191
|
155
|
}
|
192
|
156
|
} else if (state == TRIMENDPOINTMENU) {
|
193
|
157
|
if (index == 0) {
|
|
158
|
+ state = EDIT_MIN_ROLL;
|
|
159
|
+ value = joyCPPM.getMinimum(CHANNEL_ROLL);
|
194
|
160
|
} else if (index == 1) {
|
|
161
|
+ state = EDIT_MAX_ROLL;
|
|
162
|
+ value = joyCPPM.getMaximum(CHANNEL_ROLL);
|
195
|
163
|
} else if (index == 2) {
|
|
164
|
+ state = EDIT_MIN_PITCH;
|
|
165
|
+ value = joyCPPM.getMinimum(CHANNEL_PITCH);
|
196
|
166
|
} else if (index == 3) {
|
|
167
|
+ state = EDIT_MAX_PITCH;
|
|
168
|
+ value = joyCPPM.getMaximum(CHANNEL_PITCH);
|
197
|
169
|
} else if (index == 4) {
|
|
170
|
+ state = EDIT_MIN_YAW;
|
|
171
|
+ value = joyCPPM.getMinimum(CHANNEL_YAW);
|
198
|
172
|
} else if (index == 5) {
|
|
173
|
+ state = EDIT_MAX_YAW;
|
|
174
|
+ value = joyCPPM.getMaximum(CHANNEL_YAW);
|
199
|
175
|
} else if (index == 6) {
|
|
176
|
+ state = EDIT_MIN_THROTTLE;
|
|
177
|
+ value = joyCPPM.getMinimum(CHANNEL_THROTTLE);
|
200
|
178
|
} else if (index == 7) {
|
|
179
|
+ state = EDIT_MAX_THROTTLE;
|
|
180
|
+ value = joyCPPM.getMaximum(CHANNEL_THROTTLE);
|
201
|
181
|
} else if (index == 8) {
|
|
182
|
+ state = EDIT_MIN_AUX1;
|
|
183
|
+ value = joyCPPM.getMinimum(CHANNEL_AUX1);
|
202
|
184
|
} else if (index == 9) {
|
|
185
|
+ state = EDIT_MAX_AUX1;
|
|
186
|
+ value = joyCPPM.getMaximum(CHANNEL_AUX1);
|
203
|
187
|
} else if (index == 10) {
|
|
188
|
+ state = EDIT_MIN_AUX2;
|
|
189
|
+ value = joyCPPM.getMinimum(CHANNEL_AUX2);
|
204
|
190
|
} else if (index == 11) {
|
|
191
|
+ state = EDIT_MAX_AUX2;
|
|
192
|
+ value = joyCPPM.getMaximum(CHANNEL_AUX2);
|
205
|
193
|
} else if (index == 12) {
|
|
194
|
+ state = EDIT_MIN_ROLL;
|
206
|
195
|
state = MAINMENU;
|
207
|
196
|
index = 0;
|
208
|
197
|
}
|
209
|
198
|
} else if (state == INVERTAXISMENU) {
|
210
|
199
|
if (index == 0) {
|
|
200
|
+ state = EDIT_INVERT_ROLL;
|
|
201
|
+ value = joyCPPM.getInvert(CHANNEL_ROLL);
|
211
|
202
|
} else if (index == 1) {
|
|
203
|
+ state = EDIT_INVERT_PITCH;
|
|
204
|
+ value = joyCPPM.getInvert(CHANNEL_PITCH);
|
212
|
205
|
} else if (index == 2) {
|
|
206
|
+ state = EDIT_INVERT_YAW;
|
|
207
|
+ value = joyCPPM.getInvert(CHANNEL_YAW);
|
213
|
208
|
} else if (index == 3) {
|
|
209
|
+ state = EDIT_INVERT_THROTTLE;
|
|
210
|
+ value = joyCPPM.getInvert(CHANNEL_THROTTLE);
|
214
|
211
|
} else if (index == 4) {
|
|
212
|
+ state = EDIT_INVERT_AUX1;
|
|
213
|
+ value = joyCPPM.getInvert(CHANNEL_AUX1);
|
215
|
214
|
} else if (index == 5) {
|
|
215
|
+ state = EDIT_INVERT_AUX2;
|
|
216
|
+ value = joyCPPM.getInvert(CHANNEL_AUX2);
|
216
|
217
|
} else if (index == 6) {
|
217
|
218
|
state = MAINMENU;
|
218
|
219
|
index = 0;
|
|
@@ -236,32 +237,112 @@ void JoystickEventsButtons::OnButtonDown(uint8_t but_id) {
|
236
|
237
|
}
|
237
|
238
|
} else if (state == EDIT_CHANNELS) {
|
238
|
239
|
CPPM::instance().setChannels(value);
|
239
|
|
- state = MAINMENU;
|
|
240
|
+ state = CPPMMENU;
|
240
|
241
|
} else if (state == EDIT_FRAME_LENGTH) {
|
241
|
242
|
CPPM::instance().setFrameLength(value);
|
242
|
|
- state = MAINMENU;
|
|
243
|
+ state = CPPMMENU;
|
243
|
244
|
} else if (state == EDIT_PULSE_LENGTH) {
|
244
|
245
|
CPPM::instance().setPulseLength(value);
|
245
|
|
- state = MAINMENU;
|
|
246
|
+ state = CPPMMENU;
|
246
|
247
|
} else if (state == EDIT_INVERT) {
|
247
|
248
|
CPPM::instance().setInvert(value);
|
248
|
|
- state = MAINMENU;
|
|
249
|
+ state = CPPMMENU;
|
|
250
|
+ } else if (state == EDIT_INVERT_ROLL) {
|
|
251
|
+ joyCPPM.setInvert(CHANNEL_ROLL, value);
|
|
252
|
+ state = INVERTAXISMENU;
|
|
253
|
+ } else if (state == EDIT_INVERT_PITCH) {
|
|
254
|
+ joyCPPM.setInvert(CHANNEL_PITCH, value);
|
|
255
|
+ state = INVERTAXISMENU;
|
|
256
|
+ } else if (state == EDIT_INVERT_YAW) {
|
|
257
|
+ joyCPPM.setInvert(CHANNEL_YAW, value);
|
|
258
|
+ state = INVERTAXISMENU;
|
|
259
|
+ } else if (state == EDIT_INVERT_THROTTLE) {
|
|
260
|
+ joyCPPM.setInvert(CHANNEL_THROTTLE, value);
|
|
261
|
+ state = INVERTAXISMENU;
|
|
262
|
+ } else if (state == EDIT_INVERT_AUX1) {
|
|
263
|
+ joyCPPM.setInvert(CHANNEL_AUX1, value);
|
|
264
|
+ state = INVERTAXISMENU;
|
|
265
|
+ } else if (state == EDIT_INVERT_AUX2) {
|
|
266
|
+ joyCPPM.setInvert(CHANNEL_AUX2, value);
|
|
267
|
+ state = INVERTAXISMENU;
|
|
268
|
+ } else if (state == EDIT_MIN_ROLL) {
|
|
269
|
+ joyCPPM.setMinimum(CHANNEL_ROLL, value);
|
|
270
|
+ state = TRIMENDPOINTMENU;
|
|
271
|
+ } else if (state == EDIT_MAX_ROLL) {
|
|
272
|
+ joyCPPM.setMaximum(CHANNEL_ROLL, value);
|
|
273
|
+ state = TRIMENDPOINTMENU;
|
|
274
|
+ } else if (state == EDIT_MIN_PITCH) {
|
|
275
|
+ joyCPPM.setMinimum(CHANNEL_PITCH, value);
|
|
276
|
+ state = TRIMENDPOINTMENU;
|
|
277
|
+ } else if (state == EDIT_MAX_PITCH) {
|
|
278
|
+ joyCPPM.setMaximum(CHANNEL_PITCH, value);
|
|
279
|
+ state = TRIMENDPOINTMENU;
|
|
280
|
+ } else if (state == EDIT_MIN_YAW) {
|
|
281
|
+ joyCPPM.setMinimum(CHANNEL_YAW, value);
|
|
282
|
+ state = TRIMENDPOINTMENU;
|
|
283
|
+ } else if (state == EDIT_MAX_YAW) {
|
|
284
|
+ joyCPPM.setMaximum(CHANNEL_YAW, value);
|
|
285
|
+ state = TRIMENDPOINTMENU;
|
|
286
|
+ } else if (state == EDIT_MIN_THROTTLE) {
|
|
287
|
+ joyCPPM.setMinimum(CHANNEL_THROTTLE, value);
|
|
288
|
+ state = TRIMENDPOINTMENU;
|
|
289
|
+ } else if (state == EDIT_MAX_THROTTLE) {
|
|
290
|
+ joyCPPM.setMaximum(CHANNEL_THROTTLE, value);
|
|
291
|
+ state = TRIMENDPOINTMENU;
|
|
292
|
+ } else if (state == EDIT_MIN_AUX1) {
|
|
293
|
+ joyCPPM.setMinimum(CHANNEL_AUX1, value);
|
|
294
|
+ state = TRIMENDPOINTMENU;
|
|
295
|
+ } else if (state == EDIT_MAX_AUX1) {
|
|
296
|
+ joyCPPM.setMaximum(CHANNEL_AUX1, value);
|
|
297
|
+ state = TRIMENDPOINTMENU;
|
|
298
|
+ } else if (state == EDIT_MIN_AUX2) {
|
|
299
|
+ joyCPPM.setMinimum(CHANNEL_AUX2, value);
|
|
300
|
+ state = TRIMENDPOINTMENU;
|
|
301
|
+ } else if (state == EDIT_MAX_AUX2) {
|
|
302
|
+ joyCPPM.setMaximum(CHANNEL_AUX2, value);
|
|
303
|
+ state = TRIMENDPOINTMENU;
|
|
304
|
+ } else if (state == EDIT_TRIM_ROLL) {
|
|
305
|
+ joyCPPM.setTrim(CHANNEL_ROLL, signedValue);
|
|
306
|
+ state = TRIMAXISMENU;
|
|
307
|
+ } else if (state == EDIT_TRIM_PITCH) {
|
|
308
|
+ joyCPPM.setTrim(CHANNEL_PITCH, signedValue);
|
|
309
|
+ state = TRIMAXISMENU;
|
|
310
|
+ } else if (state == EDIT_TRIM_YAW) {
|
|
311
|
+ joyCPPM.setTrim(CHANNEL_YAW, signedValue);
|
|
312
|
+ state = TRIMAXISMENU;
|
|
313
|
+ } else if (state == EDIT_TRIM_THROTTLE) {
|
|
314
|
+ joyCPPM.setTrim(CHANNEL_THROTTLE, signedValue);
|
|
315
|
+ state = TRIMAXISMENU;
|
|
316
|
+ } else if (state == EDIT_TRIM_AUX1) {
|
|
317
|
+ joyCPPM.setTrim(CHANNEL_AUX1, signedValue);
|
|
318
|
+ state = TRIMAXISMENU;
|
|
319
|
+ } else if (state == EDIT_TRIM_AUX2) {
|
|
320
|
+ joyCPPM.setTrim(CHANNEL_AUX2, signedValue);
|
|
321
|
+ state = TRIMAXISMENU;
|
249
|
322
|
}
|
250
|
323
|
printMenu();
|
251
|
324
|
} else if (but_id == MENU_BUTTON_DOWN) {
|
252
|
|
- if (state > STATES_EDIT) {
|
|
325
|
+ if ((state > STATES_EDIT) && (state < STATES_EDIT_SIGNED)) {
|
253
|
326
|
if (value > 0) {
|
254
|
327
|
value--;
|
255
|
328
|
}
|
|
329
|
+ } else if (state > STATES_EDIT_SIGNED) {
|
|
330
|
+ if (signedValue > -32767) {
|
|
331
|
+ signedValue--;
|
|
332
|
+ }
|
256
|
333
|
} else if (state != NONE) {
|
257
|
334
|
index++;
|
258
|
335
|
}
|
259
|
336
|
printMenu();
|
260
|
337
|
} else if (but_id == MENU_BUTTON_UP) {
|
261
|
|
- if (state > STATES_EDIT) {
|
|
338
|
+ if ((state > STATES_EDIT) && (state < STATES_EDIT_SIGNED)) {
|
262
|
339
|
if (value < 0xFFFF) {
|
263
|
340
|
value++;
|
264
|
341
|
}
|
|
342
|
+ } else if (state > STATES_EDIT_SIGNED) {
|
|
343
|
+ if (signedValue < 32767) {
|
|
344
|
+ signedValue++;
|
|
345
|
+ }
|
265
|
346
|
} else if (state != NONE) {
|
266
|
347
|
if (index > 0) {
|
267
|
348
|
index--;
|
|
@@ -275,3 +356,93 @@ void JoystickEventsButtons::OnButtonDown(uint8_t but_id) {
|
275
|
356
|
}
|
276
|
357
|
}
|
277
|
358
|
|
|
359
|
+void JoystickEventsButtons::menuHelper(uint8_t count, const char** menu, const char* title) {
|
|
360
|
+ if (index >= count) {
|
|
361
|
+ index = count - 1;
|
|
362
|
+ }
|
|
363
|
+
|
|
364
|
+ uint8_t start = 0, line = 0;
|
|
365
|
+ if (index > 1) {
|
|
366
|
+ start = index - 1;
|
|
367
|
+ }
|
|
368
|
+
|
|
369
|
+ uint8_t end = start + 2;
|
|
370
|
+ if (index == 0) {
|
|
371
|
+ x52->setMFDText(0, title);
|
|
372
|
+ line = 1;
|
|
373
|
+ end = start + 1;
|
|
374
|
+ }
|
|
375
|
+
|
|
376
|
+ if (end >= count) {
|
|
377
|
+ end = count - 1;
|
|
378
|
+ }
|
|
379
|
+
|
|
380
|
+ for (uint8_t i = start; i <= end; i++) {
|
|
381
|
+ String tmp = (index == i) ? "-> " : " ";
|
|
382
|
+ x52->setMFDText(line++, (tmp + menu[i]).c_str());
|
|
383
|
+ }
|
|
384
|
+
|
|
385
|
+ if (line == 2) {
|
|
386
|
+ x52->setMFDText(2);
|
|
387
|
+ }
|
|
388
|
+
|
|
389
|
+#ifdef DEBUG_OUTPUT
|
|
390
|
+ Serial.print("menuHelper() state=");
|
|
391
|
+ Serial.print(state);
|
|
392
|
+ Serial.print(" index=");
|
|
393
|
+ Serial.print(index);
|
|
394
|
+ Serial.print(" start=");
|
|
395
|
+ Serial.print(start);
|
|
396
|
+ Serial.print(" end=");
|
|
397
|
+ Serial.println(end);
|
|
398
|
+#endif
|
|
399
|
+}
|
|
400
|
+
|
|
401
|
+void JoystickEventsButtons::printValue(uint16_t min, uint16_t max, const char* title) {
|
|
402
|
+#ifdef DEBUG_OUTPUT
|
|
403
|
+ Serial.print("printValue() state=");
|
|
404
|
+ Serial.print(state);
|
|
405
|
+ Serial.print(" index=");
|
|
406
|
+ Serial.print(index);
|
|
407
|
+ Serial.print(" min=");
|
|
408
|
+ Serial.print(min);
|
|
409
|
+ Serial.print(" max=");
|
|
410
|
+ Serial.println(max);
|
|
411
|
+#endif
|
|
412
|
+
|
|
413
|
+ if (value < min) {
|
|
414
|
+ value = min;
|
|
415
|
+ }
|
|
416
|
+ if (value > max) {
|
|
417
|
+ value = max;
|
|
418
|
+ }
|
|
419
|
+
|
|
420
|
+ x52->setMFDText(0, (String(title) + ":").c_str());
|
|
421
|
+ x52->setMFDText(1, String(value).c_str());
|
|
422
|
+ x52->setMFDText(2, "Press OK to save");
|
|
423
|
+}
|
|
424
|
+
|
|
425
|
+void JoystickEventsButtons::printSignedValue(int16_t min, int16_t max, const char* title) {
|
|
426
|
+#ifdef DEBUG_OUTPUT
|
|
427
|
+ Serial.print("printSignedValue() state=");
|
|
428
|
+ Serial.print(state);
|
|
429
|
+ Serial.print(" index=");
|
|
430
|
+ Serial.print(index);
|
|
431
|
+ Serial.print(" min=");
|
|
432
|
+ Serial.print(min);
|
|
433
|
+ Serial.print(" max=");
|
|
434
|
+ Serial.println(max);
|
|
435
|
+#endif
|
|
436
|
+
|
|
437
|
+ if (signedValue < min) {
|
|
438
|
+ signedValue = min;
|
|
439
|
+ }
|
|
440
|
+ if (signedValue > max) {
|
|
441
|
+ signedValue = max;
|
|
442
|
+ }
|
|
443
|
+
|
|
444
|
+ x52->setMFDText(0, (String(title) + ":").c_str());
|
|
445
|
+ x52->setMFDText(1, String(signedValue).c_str());
|
|
446
|
+ x52->setMFDText(2, "Press OK to save");
|
|
447
|
+}
|
|
448
|
+
|