-
Notifications
You must be signed in to change notification settings - Fork 4
/
menus_and_arrows.ino
87 lines (76 loc) · 2.33 KB
/
menus_and_arrows.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
byte menuNavigation()
{
// If there is an incomplete Mode switch (e.g. triggered from 3d5 serial port) ignore any manual input until complete
if (g_modeSwitchIncomplete)
return 0;
byte softKey = touchpadSenseKey();
//If Nav arrows (softKey 1 & 4) are pressed or forced - change menu
if ((softKey == 1 && g_currentMenu == 0) || (softKey == 4 && g_currentMenu ==4)) //throw out of bound clicks out...
return 99;
if (softKey == 1 && g_currentMenu > 0)
g_currentMenu--;
if (softKey == 4 && g_currentMenu < 4)
g_currentMenu++;
return softKey;
}
void menuDrawSoftKeys(char* softKey2Label, bool isSoftKey2Selected, char* softKey3Label, bool isSoftKey3Selected)
{
#if DRAW_MENUS
// set font for menus
tft.setFont(&FreeSans9pt7b);
if (isSoftKey2Selected)
{
tft.fillRoundRect(31,286,85,28,3,ILI9341_DARKGREEN);
tft.drawRoundRect(29,284,87,32,3,ILI9341_WHITE);
tft.setTextColor(text_light_Color);
}
else
{
tft.fillRoundRect(31,286,85,28,3,bg_Color);
tft.drawRoundRect(29,284,87,32,3,ILI9341_DARKGREY);
tft.setTextColor(text_dark_Color);
}
// Print label text centered on soft key 2
int x1, y1;
uint16_t w, h;
tft.getTextBounds(softKey2Label, 0, 200, &x1, &y1, &w, &h); // size of label is used to center label on button
tft.setCursor(31 + 42 - (w >> 1), 305);
tft.print(softKey2Label);
if (isSoftKey3Selected)
{
tft.fillRoundRect(126, 286, 85, 28, 3, ILI9341_DARKGREEN);
tft.drawRoundRect(124, 284, 87, 32, 3, ILI9341_WHITE);
tft.setTextColor(text_light_Color);
}
else
{
tft.fillRoundRect(126, 286, 85, 28, 3, bg_Color);
tft.drawRoundRect(124, 284, 87, 32, 3,ILI9341_DARKGREY);
tft.setTextColor(text_dark_Color);
}
// Print label text centered on soft key 3
tft.getTextBounds(softKey3Label, 0, 200, &x1, &y1, &w, &h);
tft.setCursor(126 + 42 - (w >> 1), 305);
tft.print(softKey3Label);
#endif
}
void menuDrawNavArrows()
{
#if DRAW_MENU
// display proper navigation arrows
if (g_currentMenu > 0)
tft.fillTriangle(9,300,19,308,19,292,ILI9341_GREEN);
else
{
tft.fillTriangle(9,300,19,308,19,292,bg_Color);
tft.drawTriangle(9,300,19,308,19,292,ILI9341_DARKGREEN);
}
if (g_currentMenu < 6)
tft.fillTriangle(231,300,221,308,221,292,ILI9341_GREEN);
else
{
tft.fillTriangle(231,300,221,308,221,292,bg_Color);
tft.drawTriangle(231,300,221,308,221,292,ILI9341_DARKGREEN);
}
#endif
}