|
enum class | Mode : uint8_t {
TIME
, HUMIDITY
, TEMPERATURE
, STOPWATCH
,
TIMER
, MODE_NUM
} |
|
Definition at line 7 of file mode_manager.hpp.
◆ Mode
enum class ModeManager::Mode : uint8_t |
|
strong |
Definition at line 10 of file mode_manager.hpp.
10 : uint8_t {
11 TIME,
12 HUMIDITY,
13 TEMPERATURE,
14 STOPWATCH,
15 TIMER,
16 MODE_NUM
17 };
◆ ModeManager()
ModeManager::ModeManager |
( |
| ) |
|
|
inline |
◆ AdjustTimer()
void ModeManager::AdjustTimer |
( |
int |
delta_sec | ) |
|
|
inline |
Definition at line 118 of file mode_manager.hpp.
118 {
119 if (!timer_active_) {
120 timer_duration_sec_ = std::clamp(timer_duration_sec_ + delta_sec, 0,
121 60 * 99 - 1);
122 }
123 }
◆ GetMaxTimerDuration()
int ModeManager::GetMaxTimerDuration |
( |
| ) |
const |
|
inline |
◆ GetMode()
Mode ModeManager::GetMode |
( |
| ) |
const |
|
inline |
◆ GetRemainingTimerSeconds()
int64_t ModeManager::GetRemainingTimerSeconds |
( |
| ) |
|
|
inline |
Definition at line 94 of file mode_manager.hpp.
94 {
95 int64_t remaining = timer_duration_sec_;
96 if (timer_active_) {
97 auto now = std::chrono::steady_clock::now();
98 int64_t elapsed = std::chrono::duration_cast<std::chrono::seconds>(
99 now - timer_start_time_)
100 .count();
101 if (elapsed >= timer_duration_sec_) {
102 remaining = 0;
103 std::cout << "Timer finished\n";
104 } else {
105 remaining -= elapsed;
106 }
107 }
108 return remaining;
109 }
◆ GetStopwatchSeconds()
int64_t ModeManager::GetStopwatchSeconds |
( |
| ) |
const |
|
inline |
Definition at line 60 of file mode_manager.hpp.
60 {
61 int64_t display_sec = stopwatch_elapsed_sec_;
62 if (stopwatch_running_) {
63 auto now = std::chrono::steady_clock::now();
64 display_sec += std::chrono::duration_cast<std::chrono::seconds>(
65 now - stopwatch_start_time_)
66 .count();
67 }
68 return display_sec;
69 }
◆ IsLandscape()
bool ModeManager::IsLandscape |
( |
| ) |
const |
|
inline |
◆ IsStopwatchRunning()
bool ModeManager::IsStopwatchRunning |
( |
| ) |
const |
|
inline |
◆ IsTimerRunning()
bool ModeManager::IsTimerRunning |
( |
| ) |
const |
|
inline |
◆ NextMode()
void ModeManager::NextMode |
( |
| ) |
|
|
inline |
Definition at line 23 of file mode_manager.hpp.
23 {
24 mode_ = static_cast<Mode>((static_cast<int>(mode_) + 1) %
25 static_cast<int>(Mode::MODE_NUM));
26 }
◆ SetLandscape()
void ModeManager::SetLandscape |
( |
bool |
val | ) |
|
|
inline |
◆ SetMode()
void ModeManager::SetMode |
( |
Mode |
mode | ) |
|
|
inline |
◆ StartStopwatch()
void ModeManager::StartStopwatch |
( |
| ) |
|
|
inline |
Definition at line 41 of file mode_manager.hpp.
41 {
42 if (!stopwatch_running_) {
43 stopwatch_start_time_ = std::chrono::steady_clock::now();
44 stopwatch_running_ = true;
45 mode_ = Mode::STOPWATCH;
46 std::cout << "Stopwatch started\n";
47 }
48 }
◆ StartTimer()
void ModeManager::StartTimer |
( |
int |
duration_sec | ) |
|
|
inline |
Definition at line 77 of file mode_manager.hpp.
77 {
78 timer_duration_sec_ = duration_sec;
79 max_duration_sec_ = duration_sec;
80 timer_start_time_ = std::chrono::steady_clock::now();
81 timer_active_ = true;
82 mode_ = Mode::TIMER;
83 std::cout << "Timer started for " << duration_sec << " seconds\n";
84 }
◆ StopStopwatch()
void ModeManager::StopStopwatch |
( |
| ) |
|
|
inline |
Definition at line 51 of file mode_manager.hpp.
51 {
52 if (stopwatch_running_) {
53 stopwatch_running_ = false;
54 stopwatch_elapsed_sec_ = 0;
55 std::cout << "Stopwatch stopped\n";
56 }
57 }
◆ StopTimer()
void ModeManager::StopTimer |
( |
| ) |
|
|
inline |
Definition at line 87 of file mode_manager.hpp.
87 {
88 timer_active_ = false;
89 timer_duration_sec_ = 0;
90 std::cout << "Timer stopped\n";
91 }
◆ landscape_
bool ModeManager::landscape_ = false |
|
private |
◆ max_duration_sec_
int ModeManager::max_duration_sec_ = 0 |
|
private |
◆ mode_
◆ stopwatch_elapsed_sec_
int64_t ModeManager::stopwatch_elapsed_sec_ = 0 |
|
private |
◆ stopwatch_running_
bool ModeManager::stopwatch_running_ = false |
|
private |
◆ stopwatch_start_time_
std::chrono::steady_clock::time_point ModeManager::stopwatch_start_time_ |
|
private |
◆ timer_active_
bool ModeManager::timer_active_ = false |
|
private |
◆ timer_duration_sec_
int ModeManager::timer_duration_sec_ = 0 |
|
private |
◆ timer_start_time_
std::chrono::steady_clock::time_point ModeManager::timer_start_time_ |
|
private |
The documentation for this class was generated from the following file: