-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenuScreen.cpp
More file actions
48 lines (41 loc) · 1.47 KB
/
Copy pathMainMenuScreen.cpp
File metadata and controls
48 lines (41 loc) · 1.47 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
// Author: Niklas Meinzer <meinzer.niklas@gmail.com>
// This code is open-source under the terms of the GPLv3 (see LICENSE file)
#include "./MainMenuScreen.h"
#include "./RaspiLCD.h"
// _____________________________________________________________________________
MainMenuScreen::MainMenuScreen(RaspiLCD& display, JukeBerry* jb) :
Screen(display, jb), _selectedEntry(0) {
// initialize Menu Options
_menuEntries.push_back("Library Browser");
_menuEntries.push_back("Player");
_menuEntries.push_back("Exit");
}
// _____________________________________________________________________________
void MainMenuScreen::update() {
// update the selected entry
if (_raspiLcd.buttonPressed(DOWN)) _selectedEntry++;
if (_raspiLcd.buttonPressed(UP)) _selectedEntry = (_selectedEntry == 0)?
_menuEntries.size() - 1:_selectedEntry - 1;
// wrap around
if (_selectedEntry >= _menuEntries.size()) _selectedEntry = 0;
if (_raspiLcd.buttonPressed(CENTER)) {
switch(_selectedEntry) {
case 0:
_jukeBerry->changeToScreen(SC_Library);
break;
case 1:
_jukeBerry->changeToScreen(SC_Player);
break;
case 2:
_jukeBerry->requestTermination();
break;
default:
break;
}
}
}
// _____________________________________________________________________________
void MainMenuScreen::draw() {
printTitle("JukeBerry");
_raspiLcd.printList(0, 10, _menuEntries, _selectedEntry);
}