![]() |
Tempo
Tempo is an app that allows users to create and manage timers, stopwatches, and alarms.
|
A class to manage alarms with time-based triggers. More...
#include <Alarm.hpp>

Public Member Functions | |
| Alarm (int h, int m) | |
| Constructor for the Alarm object. More... | |
| chrono::time_point< chrono::system_clock > | getTime (int h, int m) |
Creates the nearest future time point with hours h and minutes m. More... | |
| string | timeToString (chrono::time_point< chrono::system_clock > t) |
| Converts a given time point to a string format (HH:MM). More... | |
| chrono::time_point< chrono::system_clock > | getStartTime () |
| Returns the alarm's start time. More... | |
| chrono::time_point< chrono::system_clock > | getEndTime () |
| Returns the alarm's end time. More... | |
| void | start () |
| bool | isRunning () |
| Checks if the alarm is currently running. More... | |
| bool | isDone () |
| Checks if the alarm has finished. More... | |
| int | remainingMilliseconds () |
| Calculates the remaining time in milliseconds until the alarm ends. More... | |
| double | percentElapsed () |
| Calculates the percentage of time that has elapsed from start to end. More... | |
Static Public Member Functions | |
| static chrono::time_point< chrono::system_clock > | currentTime () |
| Returns the current system time. More... | |
Private Attributes | |
| int | _remainingMilliseconds |
| bool | _running |
| chrono::time_point< chrono::system_clock > | _startTime |
| chrono::time_point< chrono::system_clock > | _endTime |
A class to manage alarms with time-based triggers.
The Alarm class allows setting up an alarm for a future time, checking the progress of time, and determining when the alarm has finished.
| Alarm::Alarm | ( | int | h, |
| int | m | ||
| ) |
Constructor for the Alarm object.
Initializes the alarm with the specified hours and minutes. If the current time is past the set time, it schedules the alarm for the next day.
| h | Hour value for the new alarm (0-23). |
| m | Minute value for the new alarm (0-59). |
Definition at line 18 of file Alarm.cpp.
References _endTime, _remainingMilliseconds, _running, _startTime, currentTime(), and getTime().

|
static |
Returns the current system time.
Definition at line 159 of file Alarm.cpp.
Referenced by Alarm(), getTime(), percentElapsed(), remainingMilliseconds(), and timeToString().

| chrono::time_point< chrono::system_clock > Alarm::getEndTime | ( | ) |
Returns the alarm's end time.
Definition at line 123 of file Alarm.cpp.
References _endTime.
Referenced by Display::tickAlarm().

| chrono::time_point< chrono::system_clock > Alarm::getStartTime | ( | ) |
Returns the alarm's start time.
Definition at line 114 of file Alarm.cpp.
References _startTime.
| chrono::time_point< chrono::system_clock > Alarm::getTime | ( | int | h, |
| int | m | ||
| ) |
Creates the nearest future time point with hours h and minutes m.
If the specified time has already passed today, this method sets the alarm for the same time on the next day.
| h | Hour value for the new alarm (0-23). |
| m | Minute value for the new alarm (0-59). |
Definition at line 38 of file Alarm.cpp.
References currentTime().
Referenced by Alarm().


| bool Alarm::isDone | ( | ) |
Checks if the alarm has finished.
If the remaining milliseconds are less than or equal to 0, the alarm is considered done.
Definition at line 134 of file Alarm.cpp.
References _remainingMilliseconds, _running, and remainingMilliseconds().
Referenced by Menu::alarmSequence(), and Display::tickAlarm().


| bool Alarm::isRunning | ( | ) |
| double Alarm::percentElapsed | ( | ) |
Calculates the percentage of time that has elapsed from start to end.
This method calculates the percentage of time passed relative to the alarm's start and end times.
Definition at line 78 of file Alarm.cpp.
References _endTime, _startTime, and currentTime().
Referenced by Display::tickAlarm().


| int Alarm::remainingMilliseconds | ( | ) |
Calculates the remaining time in milliseconds until the alarm ends.
Definition at line 102 of file Alarm.cpp.
References _endTime, and currentTime().
Referenced by isDone().


| void Alarm::start | ( | ) |
| string Alarm::timeToString | ( | chrono::time_point< chrono::system_clock > | t | ) |
Converts a given time point to a string format (HH:MM).
| t | Time point to convert to string. |
Definition at line 59 of file Alarm.cpp.
References currentTime().
Referenced by Display::tickAlarm().


|
private |
Definition at line 42 of file Alarm.hpp.
Referenced by Alarm(), getEndTime(), percentElapsed(), and remainingMilliseconds().
|
private |
|
private |
Definition at line 39 of file Alarm.hpp.
Referenced by Alarm(), isDone(), and isRunning().
|
private |
Definition at line 41 of file Alarm.hpp.
Referenced by Alarm(), getStartTime(), and percentElapsed().
1.8.13