|
@@ -28,10 +28,21 @@
|
28
|
28
|
#define MODE_BUTTON_YELLOW 24
|
29
|
29
|
#define MODE_BUTTON_RED 25
|
30
|
30
|
|
|
31
|
+#define MIN_FRAME_LENGTH 10000
|
|
32
|
+#define MAX_FRAME_LENGTH 30000
|
|
33
|
+#define MIN_PULSE_LENGTH 100
|
|
34
|
+#define MAX_PULSE_LENGTH 1000
|
|
35
|
+#define MIN_LOW_ENDPOINT 500
|
|
36
|
+#define MAX_LOW_ENDPOINT 1500
|
|
37
|
+#define MIN_HIGH_ENDPOINT 1500
|
|
38
|
+#define MAX_HIGH_ENDPOINT 2500
|
|
39
|
+#define MIN_TRIM -100
|
|
40
|
+#define MAX_TRIM 100
|
|
41
|
+
|
31
|
42
|
void statusCallback(uint8_t a1, uint8_t a2, uint8_t q1, uint8_t q2);
|
32
|
43
|
|
33
|
|
-JoystickEventsButtons::JoystickEventsButtons(X52* x, JoystickEvents* client)
|
34
|
|
- : JoystickEvents(client), x52(x), state(NONE), index(0),
|
|
44
|
+JoystickEventsButtons::JoystickEventsButtons(JoystickEvents* client)
|
|
45
|
+ : JoystickEvents(client), state(NONE), index(0),
|
35
|
46
|
value(0), signedValue(0), currentMode(0) { }
|
36
|
47
|
|
37
|
48
|
void JoystickEventsButtons::printMenu() {
|
|
@@ -72,9 +83,9 @@ void JoystickEventsButtons::printMenu() {
|
72
|
83
|
} else if (state == EDIT_CHANNELS) {
|
73
|
84
|
printValue(4, CHANNELS_MAX, cppmMenu[0]);
|
74
|
85
|
} else if (state == EDIT_FRAME_LENGTH) {
|
75
|
|
- printValue(10000, 30000, cppmMenu[1]);
|
|
86
|
+ printValue(MIN_FRAME_LENGTH, MAX_FRAME_LENGTH, cppmMenu[1]);
|
76
|
87
|
} else if (state == EDIT_PULSE_LENGTH) {
|
77
|
|
- printValue(100, 1000, cppmMenu[2]);
|
|
88
|
+ printValue(MIN_PULSE_LENGTH, MAX_PULSE_LENGTH, cppmMenu[2]);
|
78
|
89
|
} else if (state == EDIT_INVERT) {
|
79
|
90
|
printValue(0, 1, cppmMenu[3]);
|
80
|
91
|
} else if ((state >= EDIT_INVERT_ROLL) && (state <= EDIT_INVERT_AUX2)) {
|
|
@@ -83,33 +94,33 @@ void JoystickEventsButtons::printMenu() {
|
83
|
94
|
} else if ((state >= EDIT_MIN_ROLL) && (state <= EDIT_MAX_AUX2)) {
|
84
|
95
|
uint8_t index = state - EDIT_MIN_ROLL;
|
85
|
96
|
if (index & 0x01) {
|
86
|
|
- printValue(1500, 2500, endpointMenu[index]);
|
|
97
|
+ printValue(MIN_HIGH_ENDPOINT, MAX_HIGH_ENDPOINT, endpointMenu[index]);
|
87
|
98
|
} else {
|
88
|
|
- printValue(500, 1500, endpointMenu[index]);
|
|
99
|
+ printValue(MIN_LOW_ENDPOINT, MAX_LOW_ENDPOINT, endpointMenu[index]);
|
89
|
100
|
}
|
90
|
101
|
} else if ((state >= EDIT_TRIM_ROLL) && (state <= EDIT_TRIM_AUX2)) {
|
91
|
102
|
uint8_t index = state - EDIT_TRIM_ROLL;
|
92
|
|
- printSignedValue(-100, 100, (String("Trim ") + axisMenu[index]).c_str());
|
|
103
|
+ printSignedValue(MIN_TRIM, MAX_TRIM, (String("Trim ") + axisMenu[index]).c_str());
|
93
|
104
|
}
|
94
|
105
|
}
|
95
|
106
|
|
96
|
107
|
void JoystickEventsButtons::OnButtonDown(uint8_t but_id) {
|
97
|
108
|
#ifdef DEBUG_BUTTON_MFD
|
98
|
109
|
String text = "Button " + String(but_id) + " down";
|
99
|
|
- x52->setMFDText(1, text.c_str());
|
|
110
|
+ x52.setMFDText(1, text.c_str());
|
100
|
111
|
#endif
|
101
|
112
|
|
102
|
113
|
if (but_id == MODE_BUTTON_GREEN) {
|
103
|
|
- x52->setLEDBrightness(2);
|
104
|
|
- x52->setMFDBrightness(2);
|
|
114
|
+ x52.setLEDBrightness(2);
|
|
115
|
+ x52.setMFDBrightness(2);
|
105
|
116
|
currentMode = 1;
|
106
|
117
|
} else if (but_id == MODE_BUTTON_YELLOW) {
|
107
|
|
- x52->setLEDBrightness(1);
|
108
|
|
- x52->setMFDBrightness(1);
|
|
118
|
+ x52.setLEDBrightness(1);
|
|
119
|
+ x52.setMFDBrightness(1);
|
109
|
120
|
currentMode = 2;
|
110
|
121
|
} else if (but_id == MODE_BUTTON_RED) {
|
111
|
|
- x52->setLEDBrightness(0);
|
112
|
|
- x52->setMFDBrightness(0);
|
|
122
|
+ x52.setLEDBrightness(0);
|
|
123
|
+ x52.setMFDBrightness(0);
|
113
|
124
|
currentMode = 3;
|
114
|
125
|
} else if ((but_id == MENU_BUTTON_ENTER_1) || (but_id == MENU_BUTTON_ENTER_2)) {
|
115
|
126
|
if (state == NONE) {
|
|
@@ -369,7 +380,7 @@ void JoystickEventsButtons::menuHelper(uint8_t count, const char** menu, const c
|
369
|
380
|
|
370
|
381
|
uint8_t end = start + 2;
|
371
|
382
|
if (index == 0) {
|
372
|
|
- x52->setMFDText(0, title);
|
|
383
|
+ x52.setMFDText(0, title);
|
373
|
384
|
line = 1;
|
374
|
385
|
end = start + 1;
|
375
|
386
|
}
|
|
@@ -380,11 +391,11 @@ void JoystickEventsButtons::menuHelper(uint8_t count, const char** menu, const c
|
380
|
391
|
|
381
|
392
|
for (uint8_t i = start; i <= end; i++) {
|
382
|
393
|
String tmp = (index == i) ? "-> " : " ";
|
383
|
|
- x52->setMFDText(line++, (tmp + menu[i]).c_str());
|
|
394
|
+ x52.setMFDText(line++, (tmp + menu[i]).c_str());
|
384
|
395
|
}
|
385
|
396
|
|
386
|
397
|
if (line == 2) {
|
387
|
|
- x52->setMFDText(2);
|
|
398
|
+ x52.setMFDText(2);
|
388
|
399
|
}
|
389
|
400
|
|
390
|
401
|
#ifdef DEBUG_OUTPUT
|
|
@@ -418,9 +429,9 @@ void JoystickEventsButtons::printValue(uint16_t min, uint16_t max, const char* t
|
418
|
429
|
value = max;
|
419
|
430
|
}
|
420
|
431
|
|
421
|
|
- x52->setMFDText(0, (String(title) + ":").c_str());
|
422
|
|
- x52->setMFDText(1, String(value).c_str());
|
423
|
|
- x52->setMFDText(2, "Press OK to save");
|
|
432
|
+ x52.setMFDText(0, (String(title) + ":").c_str());
|
|
433
|
+ x52.setMFDText(1, String(value).c_str());
|
|
434
|
+ x52.setMFDText(2, "Press OK to save");
|
424
|
435
|
}
|
425
|
436
|
|
426
|
437
|
void JoystickEventsButtons::printSignedValue(int16_t min, int16_t max, const char* title) {
|
|
@@ -442,8 +453,8 @@ void JoystickEventsButtons::printSignedValue(int16_t min, int16_t max, const cha
|
442
|
453
|
signedValue = max;
|
443
|
454
|
}
|
444
|
455
|
|
445
|
|
- x52->setMFDText(0, (String(title) + ":").c_str());
|
446
|
|
- x52->setMFDText(1, String(signedValue).c_str());
|
447
|
|
- x52->setMFDText(2, "Press OK to save");
|
|
456
|
+ x52.setMFDText(0, (String(title) + ":").c_str());
|
|
457
|
+ x52.setMFDText(1, String(signedValue).c_str());
|
|
458
|
+ x52.setMFDText(2, "Press OK to save");
|
448
|
459
|
}
|
449
|
460
|
|