Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
time_handling.h
1
6#ifndef COMPONENT_TIME_HANDLING
7#define COMPONENT_TIME_HANDLING
8
9#include <cstdint>
10
11namespace lampda {
12namespace component {
14namespace time {
15
18{
19 bool is_valid() const
20 {
21 return dayOfTheWeek >= 0 and dayOfTheWeek < 7 and hour >= 0 && hour < 24 && minutes >= 0 && minutes < 60 &&
22 seconds >= 0 && seconds < 60;
23 }
24
25 int32_t as_seconds() const;
26
27 // default values are always wrong
28 uint8_t dayOfTheWeek = UINT8_MAX;
29 uint8_t hour = UINT8_MAX;
30 uint8_t minutes = UINT8_MAX;
31 uint8_t seconds = UINT8_MAX;
32};
33
37bool set_real_time(const RealTime& realTime);
38
43RealTime convert_to_real_time(const uint32_t time_s);
44
49
57
58} // namespace time
59} // namespace component
60} // namespace lampda
61
62#endif
uint32_t get_platform_time_from_target_time(const RealTime &time)
Given a real time, return the expected platform time in seconds at wich it will be reached.
Definition: time_handling.cpp:92
RealTime get_real_time()
Return a real time value, only valid if it was set first.
Definition: time_handling.cpp:90
RealTime convert_to_real_time(const uint32_t time_s)
Convert a platform time in seconds to a real time value.
Definition: time_handling.cpp:85
bool set_real_time(const RealTime &realTime)
Set the real time in the lamp, only valid until the next shutdown.
Definition: time_handling.cpp:75
Program scope.
Definition: control_fixed_modes.hpp:12
Store a real time reference.
Definition: time_handling.h:18
uint8_t minutes
minutes, in the [0; 59]
Definition: time_handling.h:30
uint8_t dayOfTheWeek
[0; 6] the index of the day of the week. Monday is 0, sunday is 6
Definition: time_handling.h:28
uint8_t hour
hour of the day, in the [0; 23]
Definition: time_handling.h:29
uint8_t seconds
seconds, in the [0; 59]
Definition: time_handling.h:31