-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.h
More file actions
81 lines (63 loc) · 1.63 KB
/
Copy pathapp.h
File metadata and controls
81 lines (63 loc) · 1.63 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
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
#pragma once
#include "button.h"
#include "timer.h"
#include "display.h"
enum class Screen { MENU,
TIMER,
CONFIG };
enum class HoldAction {
NONE,
BACK_TO_MENU,
SKIP_TIMER_SESSION
};
enum class DurationPreset : uint8_t {
QUICK,
LONG
};
struct Config {
uint8_t magic;
uint8_t version;
bool buzzerEnabled;
DurationPreset durationPreset;
};
/**
Coordinates button input, timer state, and screen updates.
*/
class Reloj {
public:
explicit Reloj(LiquidCrystal& lcd);
void begin(unsigned long now);
void update();
private:
void handleMenuSelect(unsigned long now);
void handleTimerInput(unsigned long now);
void handleMenuNav(unsigned long now);
void handleHoldAction(unsigned long now);
void startHoldAction(HoldAction action, unsigned long now);
void resetHoldActionState();
void cancelHoldAction(unsigned long now);
void executeHoldAction(unsigned long now);
void applyConfigTimerPreset();
void maybePlayBuzzer();
void loadConfig();
void saveConfig();
Config config_;
Button pauseBtn_;
Button resetBtn_;
Button menuNavBtn_;
Button selectBtn_;
Timer timer_;
Display display_;
int selectedItemIndex_ = 0;
Screen screen_ = Screen::MENU;
HoldAction holdAction_ = HoldAction::NONE;
unsigned long holdStartedAt_ = 0;
/**
Tracks when the hold progress bar has visually completed so the action fires
only after the user sees the fully filled UI state.
*/
// True once the hold progress bar has fully filled.
bool holdConfirmed_ = false;
// Time when the hold progress bar first reached full.
unsigned long holdConfirmedAt_ = 0;
};