LSH-Core
A robust C++ framework for Arduino-based home automation nodes
Loading...
Searching...
No Matches
timekeeper.hpp
Go to the documentation of this file.
1
21#ifndef LSHCORE_UTIL_TIMEKEEPER_HPP
22#define LSHCORE_UTIL_TIMEKEEPER_HPP
23
24#include <stdint.h>
25
27
32namespace timeKeeper
33{
34 extern uint32_t now;
35
43 inline auto getTime() -> const uint32_t &
44 {
45 return now;
46 }
47
52 __attribute__((always_inline)) inline void update()
53 {
54 now = millis();
55 }
56
64 inline auto getRealTime() -> uint32_t
65 {
66 return millis();
67 }
68} // namespace timeKeeper
69
70#endif // LSHCORE_TIMEKEEPER_HPP
Time utility to keep track of time around the code.
Definition timekeeper.hpp:33
uint32_t now
Stored time.
Definition timekeeper.cpp:23
auto getTime() -> const uint32_t &
Gets the cached timestamp from the last timeKeeper::update() call.
Definition timekeeper.hpp:43
__attribute__((always_inline)) inline void update()
Update stored time to real time.
Definition timekeeper.hpp:52
auto getRealTime() -> uint32_t
Gets the current time directly by calling millis().
Definition timekeeper.hpp:64
Internal bridge that imports user-defined macros into the library's scope.