forked from cgwood/ArdustationMega
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpages.h
445 lines (342 loc) · 9.51 KB
/
pages.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
// Page class for ASM
// Created 2012 By Colin G http://www.diydrones.com/profile/ColinG
#ifndef PAGES_H_
#define PAGES_H_
// Parameter settings
#define PARAMNAMEFIELDWIDTH 12
#define MAXPARAMVALCOUNT 10
//const uint8_t ParamIDs[] = {0,1,2,3,4,5,6,7,8,9};
//{
// WP_LOITER_RAD,
// WP_RADIUS,
// XTRK_GAIN_SC,
// XTRK_ANGLE_CD,
// TRIM_ARSPD_CM,
// ARSPD_FBW_MIN,
// ARSPD_FBW_MAX,
// KFF_PTCH2THR,
// KFF_THR2PTCH,
// LOG_BITMASK,
//};
/* Look-up sine table for integer math */
byte byteSine[16] = {
0, 27, 54, 79, 104, 128, 150, 171, 190, 201, 221, 233, 243, 250, 254, 255}
;
class Pages {
public:
// ----- Declare pages here ----- //
enum PAGEIDS {
P_MAIN = 0,
P_STATUS,
P_SETTINGS,
P_COMMANDS,
P_PARAMETERS,
P_PARAMETERS_CTUN,
P_PARAMETERS_NTUN,
P_PARAMETERS_TECS,
P_ROVER_PARAMETERS,
P_COPTER_PARAMETERS,
P_HARDWARE,
P_UAVTEST,
P_GLCD,
P_SD,
P_PID,
P_COUNT
};
public:
/// Constructor
Pages();
/// Move page
static uint8_t move(int8_t dir);
/// Force update the page
static void forceUpdate(uint8_t reason);
/// Interact with the page
static void interact(uint8_t buttonid);
/// Force the page enter function (used for startup)
static uint8_t enter();
/// refresh page - medium items (10Hz)
static uint8_t refresh_med();
/// refresh page - slow items (0.5 Hz)
static uint8_t refresh_slow();
/// Define the pages -- call this whenever the uav type changes
static uint8_t definePages();
/// Directions
enum DIRECTIONS {
D_UP = 1,
D_DOWN,
D_LEFT,
D_RIGHT
};
/// Update reasons
enum REASONS {
R_PARAM = 0,
R_COUNT
};
protected:
/// One off function, executes on page enter
virtual uint8_t _enter();
/// Force update the page
virtual uint8_t _forceUpdate(uint8_t reason);
/// One off function, executes on uav type change
virtual uint8_t _redefine(){};
/// refresh page - medium items (10Hz)
virtual uint8_t _refresh_med();
/// refresh page - slow items (0.5 Hz)
virtual uint8_t _refresh_slow();
/// Interact with the page
virtual uint8_t _interact(uint8_t buttonid);
/// One off function, executes on leaving a page
//virtual uint8_t _leave();
private:
/// Access to the pages
static Pages *_currPage(uint8_t pageid);
};
// Main page
class PageMain :
public Pages {
public:
PageMain() {
_alt_icon=icon_altitude_small;
_sat_icon=sat;
_batt_icon=icn_batt;
_conn_icon=icn_conn;
_speed_icon=icn_speed;
};
private:
byte x0,y0,x1,y1;
void calcangle(byte *x, byte *y);
protected:
/// One off function, executes on page enter
virtual uint8_t _enter();
/// Force update the page
virtual uint8_t _forceUpdate(uint8_t reason) {lcd.ClearArea();GLCD.ClearScreen();_enter();};
/// One off function, executes on uav type change
virtual uint8_t _redefine(){};
/// refresh page - medium items (10Hz)
virtual uint8_t _refresh_med();
/// refresh page - slow items (0.5 Hz)
virtual uint8_t _refresh_slow();
/// Interact with the page
virtual uint8_t _interact(uint8_t buttonid);
private:
gText _textArea;
Image_t _alt_icon;
Image_t _sat_icon;
Image_t _batt_icon;
Image_t _conn_icon;
Image_t _speed_icon;
private:
uint8_t _last_base_mode;
};
// Status page - for want of a better name
class PageStatus :
public Pages {
public:
PageStatus() {};
protected:
/// One off function, executes on page enter
virtual uint8_t _enter();
/// Force update the page
virtual uint8_t _forceUpdate(uint8_t reason);
/// One off function, executes on uav type change
virtual uint8_t _redefine(){};
/// refresh page - medium items (10Hz)
virtual uint8_t _refresh_med();
/// refresh page - slow items (0.5 Hz)
virtual uint8_t _refresh_slow();
/// Interact with the page
virtual uint8_t _interact(uint8_t buttonid);
private:
gText _textArea;
};
// Hardware display page
class PageHardware :
public Pages {
public:
PageHardware() {
};
protected:
/// One off function, executes on page enter
virtual uint8_t _enter() {
_refresh_med();
_refresh_slow();
};
/// Force update the page
virtual uint8_t _forceUpdate(uint8_t reason) {
};
/// One off function, executes on uav type change
virtual uint8_t _redefine(){};
/// refresh page - medium items (10Hz)
virtual uint8_t _refresh_med();
/// refresh page - slow items (0.5 Hz)
virtual uint8_t _refresh_slow();
/// Interact with the page
virtual uint8_t _interact(uint8_t buttonid);
};
// Test display page
class PageUAVtest :
public Pages {
public:
PageUAVtest() {
};
protected:
/// One off function, executes on page enter
virtual uint8_t _enter() {
};
/// Force update the page
virtual uint8_t _forceUpdate(uint8_t reason) {
};
/// One off function, executes on uav type change
virtual uint8_t _redefine(){};
/// refresh page - medium items (10Hz)
virtual uint8_t _refresh_med();
/// refresh page - slow items (0.5 Hz)
virtual uint8_t _refresh_slow();
/// Interact with the page
virtual uint8_t _interact(uint8_t buttonid);
};
// Test display page
class PageGLCDtest :
public Pages {
public:
PageGLCDtest() {
};
private:
byte x0,y0,x1,y1;
void calcangle(byte *x, byte *y);
protected:
/// One off function, executes on page enter
virtual uint8_t _enter() {
};
/// Force update the page
virtual uint8_t _forceUpdate(uint8_t reason) {
};
/// One off function, executes on uav type change
virtual uint8_t _redefine(){};
/// refresh page - medium items (10Hz)
virtual uint8_t _refresh_med();
/// refresh page - slow items (0.5 Hz)
virtual uint8_t _refresh_slow();
/// Interact with the page
virtual uint8_t _interact(uint8_t buttonid);
};
// Test display page
class PageSDtest :
public Pages {
public:
PageSDtest() {
};
protected:
/// One off function, executes on page enter
virtual uint8_t _enter();
/// Force update the page
virtual uint8_t _forceUpdate(uint8_t reason) {};
/// One off function, executes on uav type change
virtual uint8_t _redefine(){};
/// refresh page - medium items (10Hz)
virtual uint8_t _refresh_med();
/// refresh page - slow items (0.5 Hz)
virtual uint8_t _refresh_slow();
/// Interact with the page
virtual uint8_t _interact(uint8_t buttonid);
};
// Commands page
class PageCommands :
public Pages {
public:
PageCommands();
protected:
/// One off function, executes on page enter
virtual uint8_t _enter();
/// Force update the page
virtual uint8_t _forceUpdate(uint8_t reason) {};
/// One off function, executes on uav type change
virtual uint8_t _redefine(){};
/// refresh page - medium items (10Hz)
virtual uint8_t _refresh_med();
/// refresh page - slow items (0.5 Hz)
virtual uint8_t _refresh_slow();
/// Interact with the page
virtual uint8_t _interact(uint8_t buttonid);
protected:
void _clearMarker(void);
void _paintMarker(void);
void _drawLocal();
void _commandConfirm();
void _commandConfirmMessage(const prog_char *str);
void _commandSend();
// void _alterLocal(float alterMag);
// void _redrawLocal();
// void _voidLocal(void);
// void _uploadConfirm(void);
// void _uploadLocal(void);
private:
/// text to be displayed for APM settings, up to xxx characters
const prog_char *_textCommands;
/// current state of the internal navigation state machine
uint8_t _state;
/// Position on the screen when scrolling
/// Refers to first value out of four being displayed
uint8_t _stateFirstVal;
/// flag indicating that the data the page should be redrawn
bool _updated;
};
// PID Page
class PagePID :
public Pages {
public:
PagePID();
protected:
/// One off function, executes on page enter
virtual uint8_t _enter();
/// Force update the page
virtual uint8_t _forceUpdate(uint8_t reason);
/// One off function, executes on uav type change
virtual uint8_t _redefine(){};
/// refresh page - medium items (10Hz)
virtual uint8_t _refresh_med();
/// refresh page - slow items (0.5 Hz)
virtual uint8_t _refresh_slow();
/// Interact with the page
virtual uint8_t _interact(uint8_t buttonid);
protected:
void _clearMarker(void);
void _paintMarker(void);
void _drawLocal();
void _alterLocal(float alterMag);
void _redrawLocal();
void _voidLocal(void);
void _uploadConfirm(void);
void _uploadLocal(void);
private:
/// current state of the internal navigation state machine
/// 0 = Viewing
/// 1 - 9 = Navigating
/// 101 - 109 = Editing
/// 201 - 209 = Uploading
uint8_t _state;
/// Values onboard the aircraft
//struct msg_pid _pidlive[3];
/// Local temp value
//struct msg_pid _pidtemp;
/// Local editing temp value
///
float _value_temp;
int _value_encoder;
/// Availability of pid values
bool _avail[3];
protected:
/// flag indicating that the data the page should be redrawn
bool _updated;
/// timestamp of the last page redraw, used to rate-limit redraw operations
unsigned long _lastRedraw;
/// text to be displayed for PID headings
const prog_char *_textHeader;
/// PID Types to be displayed (in same order as _textHeader)
const uint8_t *_pidTypes;
/// PID indices (in same order as _textHeader)
uint8_t _pid_p[3];
uint8_t _pid_i[3];
uint8_t _pid_d[3];
};
#endif /* PAGES_H_ */