LSH-Core
Deterministic firmware core for Controllino-based Labo Smart Home nodes
Loading...
Searching...
No Matches
saturating_time.hpp
Go to the documentation of this file.
1
21
#ifndef LSH_CORE_UTIL_SATURATING_TIME_HPP
22
#define LSH_CORE_UTIL_SATURATING_TIME_HPP
23
24
#include <stdint.h>
25
26
namespace
timeUtils
27
{
40
[[nodiscard]]
constexpr
inline
auto
addElapsedTimeSaturated
(uint16_t currentAge_ms, uint16_t elapsed_ms) -> uint16_t
41
{
42
const
uint16_t updatedAge_ms =
static_cast<
uint16_t
>
(currentAge_ms + elapsed_ms);
43
if
(updatedAge_ms < currentAge_ms)
44
{
45
return
UINT16_MAX;
46
}
47
return
updatedAge_ms;
48
}
49
}
// namespace timeUtils
50
51
#endif
// LSH_CORE_UTIL_SATURATING_TIME_HPP
timeUtils::addElapsedTimeSaturated
constexpr auto addElapsedTimeSaturated(uint16_t currentAge_ms, uint16_t elapsed_ms) -> uint16_t
Add one elapsed-time delta to a 16-bit age without wrapping.
Definition
saturating_time.hpp:40
src
util
saturating_time.hpp
Generated by
1.9.8