8#include "../emlalock/EmlaLockApi.h"
10#include <RotaryEncoder.h>
38 : lcd::ViewBase(
display,
"LockedView")
65 initializeSpecialCharacters();
76 virtual void tick(
const bool& forceRedraw) {
77 auto direction =
encoder->getDirection();
78 auto click =
encoder->getNewClick();
82 if (click || (direction != RotaryEncoder::Direction::NOROTATION)) {
83 if (!getBacklightTimeoutManager().delayTimeout()) {
87 getBacklightTimeoutManager().tick(
display);
104 display->print(
"Passed: ***:**:**:**");
106 display->print(
"Left: ***:**:**:**");
116 static time_t lastDisplayedCurrentTime = 0;
117 time_t currentTime = time(NULL);
118 if (forceRedraw || (lastDisplayedCurrentTime / 60 != currentTime / 60)) {
119 lastDisplayedCurrentTime = currentTime;
120 strftime(buf, 6,
"%R", localtime_r(¤tTime, &tmBuf));
130 static time_t lastDisplayedTime = 0;
134 if (forceRedraw || (lastDisplayedTime != timePassed)) {
135 lastDisplayedTime = timePassed;
137 int sec = timePassed % 60;
138 timePassed = timePassed / 60;
139 int min = timePassed % 60;
140 timePassed = timePassed / 60;
141 int hour = timePassed % 24;
142 int day = std::min((
int)timePassed / 24, 999);
144 sprintf(buf,
"Passed: %03d:%02d:%02d:%02d", day, hour, min, sec);
153 static time_t lastDisplayedTime = 0;
157 if (forceRedraw || (lastDisplayedTime != timeLeft)) {
158 lastDisplayedTime = timeLeft;
160 int sec = timeLeft % 60;
161 timeLeft = timeLeft / 60;
162 int min = timeLeft % 60;
163 timeLeft = timeLeft / 60;
164 int hour = timeLeft % 24;
165 int day = std::min((
int)timeLeft / 24, 999);
167 sprintf(buf,
"Left: %03d:%02d:%02d:%02d", day, hour, min, sec);
175 static String lastString =
"";
188 if (forceRedraw || (s != lastString)) {
#define COIL_PIN
GPIO the coil of the safe is connected to.
Definition: HardwareConfiguration.h:10
#define SAFE_COIL_LOCKED
Value of the COIL_PIN if the coil should be locked.
Definition: HardwareConfiguration.h:25
static const time_t & getEndDate()
Get the End Date.
Definition: LockState.h:325
static const DisplayTimePassed & getDisplayTimePassed()
Get how the time passed should be displayed.
Definition: LockState.h:256
static const String & getTemperatureString()
Get the temperature string.
Definition: LockState.h:371
static const time_t & getStartDate()
Get the Start Date.
Definition: LockState.h:302
static const DisplayTimeLeft & getDisplayTimeLeft()
Get how the time left should be displayed.
Definition: LockState.h:279
void triggerRefresh()
Triggers the client to reload the current state from the EmlaLock server.
Definition: EmlaLockApi.h:105
static EmlaLockApi & getSingleton(bool offlineMode=false)
Get the singleton instance of the API handler.
Definition: EmlaLockApi.h:71
View used when the safe is locked.
Definition: LockedView.h:17
virtual void tick(const bool &forceRedraw)
called during the loop function
Definition: LockedView.h:76
RotaryEncoder * encoder
pointer to the encoder instance
Definition: LockedView.h:22
virtual void activate()
called as soon as the view becomes active
Definition: LockedView.h:64
LockedView(LockedView &&other) noexcept=delete
Move constructor.
LockedView(const LockedView &other)=delete
Copy constructor - not available.
String temperatureStrings[6]
temperature strings if they are not provided by the emlalock API
Definition: LockedView.h:28
LockedView(LiquidCrystal_PCF8574 *display, RotaryEncoder *encoder)
Construct the locked view.
Definition: LockedView.h:37
views::ConfigurationServerView configurationServerView & display
Definition: main.cpp:57
Definition: ConfigurationServerView.h:10