forked from afarhan/ubitxv6
-
Notifications
You must be signed in to change notification settings - Fork 11
/
menu.cpp
43 lines (40 loc) · 1.22 KB
/
menu.cpp
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
#include "menu.h"
#include "menu_main.h"
void runActiveMenu(const ButtonPress_e tuner_button,
const ButtonPress_e touch_button,
const Point touch_point,
const int16_t knob)
{
Menu_t* parent_menu = rootMenu;//rootMenu is it's own parent
Menu_t* active_menu = rootMenu;
while(nullptr != active_menu->active_submenu){
parent_menu = active_menu;
active_menu = parent_menu->active_submenu;
}
MenuReturn_e mr = active_menu->runMenu(tuner_button,touch_button,touch_point,knob);
switch(mr){
case MenuReturn_e::StillActive://Fallthrough intended
case MenuReturn_e::ExitedNoRedraw:
{
//Nothing to do here - just return
break;
}
default://Fallthrough intended. Default to this menu being active
case MenuReturn_e::ExitedRedraw:
{
//Turn off submenu, redraw, then return
parent_menu->active_submenu = nullptr;
parent_menu->initMenu();
break;
}
}//end switch
}
void enterSubmenu(Menu_t *const submenu)
{
Menu_t* current_menu = rootMenu;
while(nullptr != current_menu->active_submenu){
current_menu = current_menu->active_submenu;
}
current_menu->active_submenu = submenu;
submenu->initMenu();
}