EmlaLockSafe
UnlockedMainMenu.h
Go to the documentation of this file.
1
5#pragma once
6
7#include "../Tools.h"
8#include "ViewStore.h"
9
10#include <Esp.h>
11#include <MenuView.h>
12
13namespace views {
17class UnlockedMainMenu : public lcd::MenuView {
18public:
27 UnlockedMainMenu(LiquidCrystal_PCF8574* display, RotaryEncoder* encoder, const int& numberOfColumns, const int& numberOfRows)
28 : lcd::MenuView(display, "UnlockedMainMenu", encoder, "Unlocked Main Menu", numberOfColumns, numberOfRows) {}
29
30public:
34 UnlockedMainMenu(const UnlockedMainMenu& other) = delete;
35
36public:
41 UnlockedMainMenu(UnlockedMainMenu&& other) noexcept = delete;
42
43protected:
47 virtual void activate() {
48 // is this the first time activate is called?
49 if (menuItems.empty()) {
50 // create menu items
51
52 createMenuItem("Open Safe", [](MenuItem*) {
54 if (!timeRestictions.restrictUnlockTimes || timeRestictions.checkTime()) {
56 }
57 else {
59 }
60 });
61 createMenuItem("Set Custom Timer", [](MenuItem*) {
63 });
64 createMenuItem("Emlalock Unlock Key", [](MenuItem*) {
66 });
67 createMenuItem("Preferences", [](MenuItem*) {
69 });
70 createMenuItem("Hardware Test View", [](MenuItem*) {
72 });
73 createMenuItem("Reboot", [](MenuItem*) {
74 ESP.restart();
75 });
76 }
77 lcd::MenuView::activate();
78 }
79
80public:
86 virtual void tick(const bool& forceRedraw) {
87 // updated the view of the menu
88 lcd::MenuView::tick(forceRedraw);
89
90 // update the signal strength symbol
91 Tools::tickWifiSymbol(display, forceRedraw);
92 }
93};
94} // namespace views
static void tickWifiSymbol(LiquidCrystal_PCF8574 *display, bool forceRedraw)
tick routine updating the wifi signal strength icon
Definition: Tools.h:23
const TimeRestrictions & getTimeRestrictions() const
get the timeout of display backlight in seconds
Definition: Configuration.h:354
static Configuration & getSingleton()
Get the Singleton object.
Definition: Configuration.h:162
Main menu as long as there is no active session.
Definition: UnlockedMainMenu.h:17
UnlockedMainMenu(const UnlockedMainMenu &other)=delete
Copy constructor - not available.
virtual void tick(const bool &forceRedraw)
called during the loop function
Definition: UnlockedMainMenu.h:86
UnlockedMainMenu(LiquidCrystal_PCF8574 *display, RotaryEncoder *encoder, const int &numberOfColumns, const int &numberOfRows)
Construct a new main menu object.
Definition: UnlockedMainMenu.h:27
virtual void activate()
called as soon as the view becomes active
Definition: UnlockedMainMenu.h:47
UnlockedMainMenu(UnlockedMainMenu &&other) noexcept=delete
Move constructor - not available otherwise we get problems with the callbacks.
static bool activateView(const ViewId &id)
activates the view described by the id
Definition: ViewStore.h:98
@ PreferencesMenu
Definition: ViewStore.h:32
@ UnlockSafeView
Definition: ViewStore.h:38
@ HardwareTestView
Definition: ViewStore.h:29
@ TimeRestrictedView
Definition: ViewStore.h:36
@ SetTimerView
Definition: ViewStore.h:35
@ EmlalockUnlockKeyMenu
Definition: ViewStore.h:28
views::ConfigurationServerView configurationServerView & display
Definition: main.cpp:57
RotaryEncoder encoder(ENCODER_PIN_CLK, ENCODER_PIN_DT, ENCODER_SWITCH)
Definition: ConfigurationServerView.h:10