-
Notifications
You must be signed in to change notification settings - Fork 5
/
pages.h
592 lines (455 loc) · 12.5 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
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
// 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_MEASURE,
P_PLOT,
P_SETTINGS,
P_COMMANDS,
P_PARAMS1,
P_PARAMS2,
P_PARAMETERS,
P_PARAMETERS_CTUN,
P_PARAMETERS_NTUN,
P_PARAMETERS_TECS,
P_ROVER_PARAMETERS,
P_ROVER_PARAMETERS_SONAR,
P_COPTER_PARAMETERS,
P_TRACKER,
P_HARDWARE,
P_UAVTEST,
P_GLCD,
P_SD,
P_PID,
P_COUNT
};
public:
/// Constructor
Pages();
/// Move page
static uint8_t move(int8_t dir);
/// Move to specific page
static uint8_t moveTo(int8_t pageid);
/// 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;
};
class PageMeasure :
public Pages {
public:
PageMeasure() {_state = 0;_measurementids[0]=M_PITCH;_measurementids[1]=M_AIRSPEED;};
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);
/// Print the measurement name
void _printName(uint8_t measurementid);
/// Print the measurement value
void _printValue(uint8_t measurementid, gText *area);
private:
uint8_t _state;
int _measurementids[2];
gText _textArea1, _textArea2;
enum MEASUREMENTS {
M_NONE = 0,
M_ROLL,
M_PITCH,
M_AIRSPEED,
M_GROUNDSPEED,
M_THROTTLE,
M_CLIMBRATE,
M_COUNT
};
};
#define PLOTW 121
class PagePlot :
public Pages {
public:
PagePlot() {_state = 0;_measurementid=M_ROLL;};
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);
/// Print the measurement name
void _printName(uint8_t measurementid);
/// Get the value for the measurement
uint8_t _getValueInt(uint8_t measurementid);
float _getValue(uint8_t measurementid);
/// Plots the stored values
void _plot();
/// Clears the last plot
void _clearPlot();
/// Adds a value to the buffer
void _addValue(uint8_t value);
private:
uint8_t _state;
int _measurementid;
uint8_t _values[PLOTW];
enum MEASUREMENTS {
M_NONE = 0,
M_ROLL,
M_PITCH,
M_AIRSPEED,
M_GROUNDSPEED,
M_THROTTLE,
M_CLIMBRATE,
M_COUNT
};
};
// Tracker page - for debugging or configuring the antenna tracker
class PageTracker :
public Pages {
public:
PageTracker() {_state = 0;};
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:
uint8_t _state;
int _value_encoder;
};
// 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;
/// Local LCD
uint8_t _linecount;
gText _cmdLCD;
/// 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_ */