|
@@ -29,7 +29,7 @@
|
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) { }
|
|
32
|
+ : JoystickEvents(client), x52(x), state(NONE), index(0), value(0), menuTime(0) { }
|
33
|
33
|
|
34
|
34
|
void JoystickEventsButtons::menuHelper(uint8_t count, const char** menu, const char* title) {
|
35
|
35
|
if (index >= count) {
|
|
@@ -40,19 +40,23 @@ void JoystickEventsButtons::menuHelper(uint8_t count, const char** menu, const c
|
40
|
40
|
if (index > 1) {
|
41
|
41
|
start = index - 1;
|
42
|
42
|
}
|
|
43
|
+
|
43
|
44
|
uint8_t end = start + 2;
|
44
|
45
|
if (index == 0) {
|
45
|
46
|
x52->setMFDText(0, title);
|
46
|
47
|
line = 1;
|
47
|
48
|
end = start + 1;
|
48
|
49
|
}
|
|
50
|
+
|
49
|
51
|
if (end >= count) {
|
50
|
52
|
end = count - 1;
|
51
|
53
|
}
|
|
54
|
+
|
52
|
55
|
for (uint8_t i = start; i <= end; i++) {
|
53
|
56
|
String tmp = (index == i) ? "-> " : " ";
|
54
|
57
|
x52->setMFDText(line++, (tmp + menu[i]).c_str());
|
55
|
58
|
}
|
|
59
|
+
|
56
|
60
|
if (line == 2) {
|
57
|
61
|
x52->setMFDText(2);
|
58
|
62
|
}
|
|
@@ -71,13 +75,37 @@ void JoystickEventsButtons::menuHelper(uint8_t count, const char** menu, const c
|
71
|
75
|
|
72
|
76
|
void JoystickEventsButtons::printMenu() {
|
73
|
77
|
static const char* mainMenu[] = {
|
74
|
|
- "Channels", "Frame Length",
|
75
|
|
- "Pulse Length", "Invert"
|
|
78
|
+ "Status", "Trim Axis", "Trim Endpoint", "Invert Axis", "CPPM Config"
|
76
|
79
|
};
|
77
|
80
|
static const uint8_t mainMenuCount = sizeof(mainMenu) / sizeof(mainMenu[0]);
|
78
|
81
|
|
|
82
|
+ static const char* cppmMenu[] = {
|
|
83
|
+ "Channels", "Frame Length", "Pulse Length", "Invert", "Main Menu"
|
|
84
|
+ };
|
|
85
|
+ static const uint8_t cppmMenuCount = sizeof(cppmMenu) / sizeof(cppmMenu[0]);
|
|
86
|
+
|
|
87
|
+ static const char* axisMenu[] = {
|
|
88
|
+ "Roll", "Pitch", "Yaw", "Throttle", "Aux1", "Aux2", "Main Menu"
|
|
89
|
+ };
|
|
90
|
+ static const uint8_t axisMenuCount = sizeof(axisMenu) / sizeof(axisMenu[0]);
|
|
91
|
+
|
|
92
|
+ static const char* endpointMenu[] = {
|
|
93
|
+ "Roll Min", "Roll Max", "Pitch Min", "Pitch Max", "Yaw Min", "Yaw Max",
|
|
94
|
+ "Throttle Min", "Throttle Max", "Aux1 Min", "Aux1 Max", "Aux2 Min",
|
|
95
|
+ "Aux2 Max", "Main Menu"
|
|
96
|
+ };
|
|
97
|
+ static const uint8_t endpointMenuCount = sizeof(endpointMenu) / sizeof(endpointMenu[0]);
|
|
98
|
+
|
79
|
99
|
if (state == MAINMENU) {
|
80
|
100
|
menuHelper(mainMenuCount, mainMenu, "Main Menu");
|
|
101
|
+ } else if (state == CPPMMENU) {
|
|
102
|
+ menuHelper(cppmMenuCount, cppmMenu, "CPPM Config Menu");
|
|
103
|
+ } else if (state == TRIMAXISMENU) {
|
|
104
|
+ menuHelper(axisMenuCount, axisMenu, "Trim Axis Menu");
|
|
105
|
+ } else if (state == TRIMENDPOINTMENU) {
|
|
106
|
+ menuHelper(endpointMenuCount, endpointMenu, "Trim Endpoints");
|
|
107
|
+ } else if (state == INVERTAXISMENU) {
|
|
108
|
+ menuHelper(axisMenuCount, axisMenu, "Invert Axis Menu");
|
81
|
109
|
} else if (state == EDIT_CHANNELS) {
|
82
|
110
|
printValue(4, CHANNELS_MAX, mainMenu[0]);
|
83
|
111
|
} else if (state == EDIT_FRAME_LENGTH) {
|
|
@@ -87,6 +115,8 @@ void JoystickEventsButtons::printMenu() {
|
87
|
115
|
} else if (state == EDIT_INVERT) {
|
88
|
116
|
printValue(0, 1, mainMenu[3]);
|
89
|
117
|
}
|
|
118
|
+
|
|
119
|
+ menuTime = millis();
|
90
|
120
|
}
|
91
|
121
|
|
92
|
122
|
void JoystickEventsButtons::printValue(uint16_t min, uint16_t max, const char* title) {
|
|
@@ -131,8 +161,64 @@ void JoystickEventsButtons::OnButtonDown(uint8_t but_id) {
|
131
|
161
|
} else if ((but_id == MENU_BUTTON_ENTER_1) || (but_id == MENU_BUTTON_ENTER_2)) {
|
132
|
162
|
if (state == NONE) {
|
133
|
163
|
state = MAINMENU;
|
|
164
|
+ index = 0;
|
134
|
165
|
} else if (state == MAINMENU) {
|
135
|
166
|
if (index == 0) {
|
|
167
|
+ state = NONE;
|
|
168
|
+ } else if (index == 1) {
|
|
169
|
+ //state = TRIMAXISMENU;
|
|
170
|
+ //index = 0;
|
|
171
|
+ } else if (index == 2) {
|
|
172
|
+ //state = TRIMENDPOINTMENU;
|
|
173
|
+ //index = 0;
|
|
174
|
+ } else if (index == 3) {
|
|
175
|
+ //state = INVERTAXISMENU;
|
|
176
|
+ //index = 0;
|
|
177
|
+ } else if (index == 4) {
|
|
178
|
+ state = CPPMMENU;
|
|
179
|
+ index = 0;
|
|
180
|
+ }
|
|
181
|
+ } else if (state == TRIMAXISMENU) {
|
|
182
|
+ if (index == 0) {
|
|
183
|
+ } else if (index == 1) {
|
|
184
|
+ } else if (index == 2) {
|
|
185
|
+ } else if (index == 3) {
|
|
186
|
+ } else if (index == 4) {
|
|
187
|
+ } else if (index == 5) {
|
|
188
|
+ } else if (index == 6) {
|
|
189
|
+ state = MAINMENU;
|
|
190
|
+ index = 0;
|
|
191
|
+ }
|
|
192
|
+ } else if (state == TRIMENDPOINTMENU) {
|
|
193
|
+ if (index == 0) {
|
|
194
|
+ } else if (index == 1) {
|
|
195
|
+ } else if (index == 2) {
|
|
196
|
+ } else if (index == 3) {
|
|
197
|
+ } else if (index == 4) {
|
|
198
|
+ } else if (index == 5) {
|
|
199
|
+ } else if (index == 6) {
|
|
200
|
+ } else if (index == 7) {
|
|
201
|
+ } else if (index == 8) {
|
|
202
|
+ } else if (index == 9) {
|
|
203
|
+ } else if (index == 10) {
|
|
204
|
+ } else if (index == 11) {
|
|
205
|
+ } else if (index == 12) {
|
|
206
|
+ state = MAINMENU;
|
|
207
|
+ index = 0;
|
|
208
|
+ }
|
|
209
|
+ } else if (state == INVERTAXISMENU) {
|
|
210
|
+ if (index == 0) {
|
|
211
|
+ } else if (index == 1) {
|
|
212
|
+ } else if (index == 2) {
|
|
213
|
+ } else if (index == 3) {
|
|
214
|
+ } else if (index == 4) {
|
|
215
|
+ } else if (index == 5) {
|
|
216
|
+ } else if (index == 6) {
|
|
217
|
+ state = MAINMENU;
|
|
218
|
+ index = 0;
|
|
219
|
+ }
|
|
220
|
+ } else if (state == CPPMMENU) {
|
|
221
|
+ if (index == 0) {
|
136
|
222
|
state = EDIT_CHANNELS;
|
137
|
223
|
value = CPPM::instance().getChannels();
|
138
|
224
|
} else if (index == 1) {
|
|
@@ -144,6 +230,9 @@ void JoystickEventsButtons::OnButtonDown(uint8_t but_id) {
|
144
|
230
|
} else if (index == 3) {
|
145
|
231
|
state = EDIT_INVERT;
|
146
|
232
|
value = CPPM::instance().getInvert();
|
|
233
|
+ } else if (index == 4) {
|
|
234
|
+ state = MAINMENU;
|
|
235
|
+ index = 0;
|
147
|
236
|
}
|
148
|
237
|
} else if (state == EDIT_CHANNELS) {
|
149
|
238
|
CPPM::instance().setChannels(value);
|