-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainMenuView.cpp
97 lines (80 loc) · 3.24 KB
/
MainMenuView.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
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
//
// Lucky Resistor's Deluxe Data Logger
// ---------------------------------------------------------------------------
// (c)2015 by Lucky Resistor. See LICENSE for details.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
#include "MainMenuView.h"
#include "Application.h"
#include "SharpDisplay.h"
#include "ViewManager.h"
namespace lr {
namespace MainMenuView {
// The items in the start menu.
static const char cItem1[] PROGMEM = "Start Rec.";
static const char cItem2[] PROGMEM = "View Records";
static const char cItem3[] PROGMEM = "Send Records";
static const char cItem4[] PROGMEM = "Set Interval";
static const char cItem5[] PROGMEM = "Erase All";
static const char cItem6[] PROGMEM = "Adjust Time";
static const char cItem7[] PROGMEM = "Version Info";
static const char *cItems[7] = {cItem1, cItem2, cItem3, cItem4, cItem5, cItem6, cItem7};
static const uint8_t cItemCount = 7;
// The currently selected item.
static uint8_t gSelectedItem = 0;
void updateDisplay()
{
SharpDisplay::setTextInverse(false);
SharpDisplay::setLineText(0, PSTR("Main Menu"));
SharpDisplay::fillRow(1, '\x89');
const uint8_t visibleLines = SharpDisplay::getScreenHeight()-5;
for (uint8_t i = 0; i < visibleLines; ++i) {
if (i < cItemCount) {
SharpDisplay::setTextInverse(i == gSelectedItem);
SharpDisplay::setLineText(i+2, cItems[i]);
} else {
SharpDisplay::setTextInverse(false);
SharpDisplay::fillRow(i+2, ' ');
}
}
}
void handleKey(KeyPad::Key key)
{
if (key == KeyPad::Down && gSelectedItem < (cItemCount-1)) {
++gSelectedItem;
ViewManager::setNeedsDisplayUpdate();
} else if (key == KeyPad::Up && gSelectedItem > 0) {
--gSelectedItem;
ViewManager::setNeedsDisplayUpdate();
} else if (key == KeyPad::Enter || key == KeyPad::Right) {
switch (gSelectedItem) {
case 0: ViewManager::setNextView(ViewManager::RecordView); break;
case 1: ViewManager::setNextView(ViewManager::ViewRecordView); break;
case 2: ViewManager::setNextView(ViewManager::SendRecordView); break;
case 3: ViewManager::setNextView(ViewManager::SetIntervalView); break;
case 4: ViewManager::setNextView(ViewManager::EraseAllView); break;
case 5: ViewManager::setNextView(ViewManager::AdjustTimeView); break;
case 6: ViewManager::setNextView(ViewManager::VersionInfoView); break;
}
}
}
void viewWillAppear()
{
KeyPad::clear();
Application::setOperationMode(Application::MenuMode);
}
}
}