-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmenu.cpp
More file actions
101 lines (93 loc) · 2.28 KB
/
menu.cpp
File metadata and controls
101 lines (93 loc) · 2.28 KB
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
#include "menu.h"
#include <Arduino.h>
#include "icons.h"
#include "screen.h"
#include "joystick.h"
#include "usb.h"
#include "sweep.h"
#include "survey.h"
#include "settings.h"
#define POINTER_OFFSET (4)
int cursor;
/**************************************************************************/
/*!
@brief Ease of use function for moving the curso on screen
*/
/**************************************************************************/
void moveCursor(int newLine) {
clearSpace(0,cursor,20);
cursor = newLine;
if((cursor == 1 || cursor == 2) && !isDeviceProvisioned()) {
drawText(POINTER_OFFSET,cursor,"X");
} else {
drawText(POINTER_OFFSET,cursor,">");
}
}
/**************************************************************************/
/*!
@brief Sets up the screen for the main menu
*/
/**************************************************************************/
void initMenuState() {
cursor = 1;
setLineInverted(0, false);
setLineInverted(1, true);
setLineInverted(2, true);
setLineInverted(3, true);
setLineInverted(4, true);
clearScreen();
drawText(55,0,"Menu");
drawText(20,1,"Survey");
drawText(20,2,"Sweep");
drawText(20,3,"Settings");
drawText(20,4,"USB");
cursor = 0;
moveCursor(1);
}
/**************************************************************************/
/*!
@brief Checks the yostick for inputs and updates the screen or changes state accordingly
*/
/**************************************************************************/
void menuStateLoop() {
drawGPSIcon();
drawBatteryIcon();
joyState joy = readJoystick();
switch(joy) {
case JOY_PRESSED:
switch(cursor) {
case 1:
if(isDeviceProvisioned()) {
setState(&surveyState);
return;
}
break;
case 2:
if(isDeviceProvisioned()) {
setState(&sweepState);
return;
}
break;
case 3:
setState(&settingsState);
return;
case 4:
setState(&usbState);
return;
}
break;
case JOY_UP:
if(cursor>1)
moveCursor(cursor-1);
break;
case JOY_DOWN:
if(cursor<4)
moveCursor(cursor+1);
break;
}
}
state menuState = {
&initMenuState,
&menuStateLoop,
NULL
};