-
Notifications
You must be signed in to change notification settings - Fork 0
/
k0-menu.ino
115 lines (90 loc) · 2.37 KB
/
k0-menu.ino
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
/***************************************************
* Multi-instrumento
*
* Author: Pavel Milanes Costa
* Email: pavelmc@gmail.com
****************************************************/
// menu functions
void menu() {
// fail safe
if (smode == 0) smode = 1;
// draw the main box
tft.drawRect(0, 22, TFT_WIDTH, 218, ILI9340_WHITE);
// set text size
tft.setTextSize(2);
tft.setTextColor(ILI9340_CYAN, ILI9340_BLACK);
// update numbers
menuUpdate();
// print labels for the mode
for (byte i = 1; i < MODE_COUNT; i++) {
// label of the mode
tft.setCursor(30, 26 + 26 * i);
// print the mode label, always on the same color
tft.setTextColor(ILI9340_CYAN, ILI9340_BLACK);
tft.print(modeLabels[i]);
}
}
// update menu position
void menuUpdate() {
for (byte i = 1; i < MODE_COUNT; i++) {
// print the mode number, activated or not.
tft.setCursor(12, 26 + 26 * i);
// mark if selected
if (smode == i) tft.setTextColor(ILI9340_BLACK, ILI9340_YELLOW);
else tft.setTextColor(ILI9340_CYAN, ILI9340_BLACK);
// print the number
tft.print(i);
}
}
// mode change
void changeMode() {
// change the mode between the modes
// erase the screen
tft.fillScreen(ILI9340_BLACK);
// redraw the top box
drawtopbox();
// MENU
if (mode == MODE_MENU) {
// draw the main menu
menu();
}
// SIGNAL GENERATOR
if (mode == MODE_SIGEN) {
// draw the signal generator interface
vfobox();
}
// SWEEP & SA
if (mode == MODE_SWEEP || mode == MODE_SA) {
// draw the sweeper interface
sweep_box();
}
// METER
if (mode == MODE_METER) {
// draw the meter interface
showMeterMode();
}
// PC
if (mode == MODE_PC) {
// draw the PC interface
showPCMode();
}
// LC
if (mode == MODE_LC) {
// draw the LC interface
lcInterface();
}
// CONFIGURE
if (mode == MODE_CONFIG) {
// draw the Configurations menu
settings();
}
// save settings
saveEEPROM();
}
// move between the menu entries
void moveMenu(char dir) {
// increment smenu and pass it away to the menu...
smode = moveWithLimits(smode, dir, 1, MODE_COUNT - 1);
// call it
menuUpdate();
}