EmlaLockSafe
ConfigurationServerView.h
Go to the documentation of this file.
1
5#pragma once
6#include "../Tools.h"
7
8#include <MenuView.h>
9
10namespace views {
14class ConfigurationServerView : public lcd::MenuView {
15public:
24 ConfigurationServerView(LiquidCrystal_PCF8574* display,
25 RotaryEncoder* encoder,
26 const int& numberOfColumns,
27 const int& numberOfRows)
28 : lcd::MenuView(display, "ConfigurationServerView", encoder, "Open in Browser:", numberOfColumns, numberOfRows) {}
29
30public:
35
36public:
41
42protected:
46 virtual void activate() {
47 // is this the first time activate is called?
48 if (menuItems.empty()) {
49
50 // create menu items
51 createMenuItem("http://" + WiFi.localIP().toString(), [this](MenuItem*) {});
52 createMenuItem("Change Wifi Settings", [this](MenuItem*) {
54 ESP.restart();
55 });
56 createMenuItem("Back", [this](MenuItem*) {
57 activatePreviousView();
58 });
59 }
60
61 lcd::MenuView::activate();
62 }
63
64public:
70 virtual void tick(const bool& forceRedraw) {
71 static unsigned long nextCheck = millis();
72
73 if (nextCheck < millis()) {
74 static String ip = "";
75 String tmpIp = WiFi.localIP().toString();
76 if (ip != tmpIp) {
77 ip = tmpIp;
78 menuItems.front().setText("http://" + tmpIp);
79 }
80 nextCheck = millis() + 100;
81 }
82 lcd::MenuView::tick(forceRedraw);
83 }
84};
85} // namespace views
static Configuration & getSingleton()
Get the Singleton object.
Definition: Configuration.h:162
void setWifiSettings(const String &ssid, const String &pwd)
Set the Wifi Settings.
Definition: Configuration.h:368
preferences menu
Definition: ConfigurationServerView.h:14
virtual void activate()
called as soon as the view becomes active
Definition: ConfigurationServerView.h:46
ConfigurationServerView(ConfigurationServerView &&other) noexcept=delete
Move constructor - not available otherwise we get problems with the callbacks.
ConfigurationServerView(LiquidCrystal_PCF8574 *display, RotaryEncoder *encoder, const int &numberOfColumns, const int &numberOfRows)
Construct a new menu object.
Definition: ConfigurationServerView.h:24
ConfigurationServerView(const ConfigurationServerView &other)=delete
Copy constructor - not available.
virtual void tick(const bool &forceRedraw)
Overload Tick.
Definition: ConfigurationServerView.h:70
views::ConfigurationServerView configurationServerView & display
Definition: main.cpp:57
RotaryEncoder encoder(ENCODER_PIN_CLK, ENCODER_PIN_DT, ENCODER_SWITCH)
Definition: ConfigurationServerView.h:10