-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.cpp
More file actions
111 lines (96 loc) · 1.74 KB
/
menu.cpp
File metadata and controls
111 lines (96 loc) · 1.74 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
102
103
104
105
106
107
108
109
110
111
#include "menu.h"
#include "display.h"
#include <stdint.h>
// remoteButton = state - 2, hubPort = substate - 1
static MenuState stateMax = Menu1;
static MenuState subStateMax = Init;
static MenuState state = Init;
static MenuState substate = Init;
void updateSubState (bool reverse)
{
display_set (static_cast<uint8_t>(substate), 0, 0, 0, 0, true);
if (reverse == false)
{
if (static_cast<int>(substate) < static_cast<int>(subStateMax))
{
substate = static_cast<MenuState>(static_cast<int>(substate) + 1);
}
else
{
substate = Menu1;
}
}
else
{
if (static_cast<int>(substate) > static_cast<int>(Menu1))
{
substate = static_cast<MenuState>(static_cast<int>(substate) - 1);
}
else
{
substate = subStateMax;
}
}
display_set (static_cast<uint8_t>(substate), 0, 255, 255, 255, true);
}
uint8_t getMaxPortId()
{
return subStateMax - 1;
}
uint8_t getMaxRemoteButton()
{
return stateMax - 2;
}
MenuState getMaxSubState()
{
return subStateMax;
}
MenuState getMaxState()
{
return stateMax;
}
MenuState getSubState()
{
return substate;
}
MenuState getState()
{
return state;
}
void setStateMax(MenuState state)
{
stateMax = state;
}
void setSubStateMax(MenuState state)
{
subStateMax = state;
}
uint8_t getPortId()
{
return substate - 1;
}
uint8_t getRemoteButton()
{
return state - 2;
}
void resetSubState()
{
substate = Init;
}
// Intermediate until hub is abstracted
// true on reset
bool updateAndResetState()
{
bool ret = false;
if (static_cast<int>(state) < static_cast<int>(stateMax))
{
state = static_cast<MenuState>(static_cast<int>(state) + 1);
ret = false;
}
else
{
state = Menu1;
ret = true;
}
return ret;
}