Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Classes | Functions | Variables
lampda::component::time Namespace Reference

Handle the platform realtime functions. More...

Classes

struct  RealTime
 Store a real time reference. More...
 

Functions

bool set_real_time (const RealTime &realTime)
 Set the real time in the lamp, only valid until the next shutdown.
 
RealTime convert_to_real_time (const uint32_t time_s)
 Convert a platform time in seconds to a real time value.
 
RealTime get_real_time ()
 Return a real time value, only valid if it was set first.
 
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.
 

Variables

static constexpr uint32_t secondsPerMinutes = 60
 
static constexpr uint32_t MinutesPerHours = 60
 
static constexpr uint32_t hoursPerDays = 24
 
static constexpr uint32_t daysPerWeeks = 7
 
static constexpr uint32_t secondsPerHours = secondsPerMinutes * MinutesPerHours
 
static constexpr uint32_t secondsPerDays = secondsPerHours * hoursPerDays
 
static constexpr uint32_t secondsPerWeeks = secondsPerDays * daysPerWeeks
 

Detailed Description

Handle the platform realtime functions.

Function Documentation

◆ convert_to_real_time()

RealTime lampda::component::time::convert_to_real_time ( const uint32_t  time_s)

Convert a platform time in seconds to a real time value.

Returns
if the global time is unset, the function return an invalid time

◆ get_platform_time_from_target_time()

uint32_t lampda::component::time::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.

Warning
The returned time in seconds is only valid if the real time was set before.
The returned time could be greater than the maximum platform time.
Returns
if the global time is unset, the function return 0

TODO: handle the clock wrap around