FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
time.h File Reference

Simple time utilities. More...

#include <stdint.h>
#include "boards/io.h"
#include <util/delay_basic.h>
#include "utilities.h"
Include dependency graph for time.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  time::RTTTime
 Structure used to hold a time value with microsecond precision. More...
 
class  time::auto_delay
 Set a new time::delay function for the duration of the current scope; when the scope is left, the previous time::delay function is restored. More...
 
class  time::auto_millis
 Set a new time::millis function for the duration of the current scope; when the scope is left, the previous time::millis function is restored. More...
 

Namespaces

namespace  time
 Defines simple API to handle time and delays.
 

Typedefs

using time::DELAY_PTR = void(*)(uint32_t ms)
 Function pointer type used for time::delay global variable. More...
 
using time::MILLIS_PTR = uint32_t(*)()
 Function pointer type used for time::millis global variable. More...
 

Functions

RTTTime time::operator- (const RTTTime &a, const RTTTime &b)
 Subtract 2 RTTTime instances. More...
 
bool time::operator> (const RTTTime &a, const RTTTime &b)
 Compare 2 RTTTime instances. More...
 
bool time::operator>= (const RTTTime &a, const RTTTime &b)
 Compare 2 RTTTime instances. More...
 
bool time::operator< (const RTTTime &a, const RTTTime &b)
 Compare 2 RTTTime instances. More...
 
bool time::operator<= (const RTTTime &a, const RTTTime &b)
 Compare 2 RTTTime instances. More...
 
bool time::operator== (const RTTTime &a, const RTTTime &b)
 Compare 2 RTTTime instances. More...
 
bool time::operator!= (const RTTTime &a, const RTTTime &b)
 Compare 2 RTTTime instances. More...
 
RTTTime time::operator+ (const RTTTime &a, const RTTTime &b)
 Add 2 RTTTime instances. More...
 
void time::yield ()
 Utility method used by many FastArduino API in order to "yield" some processor time; concretely it just calls power::Power::sleep() which will put the MCU into a default sleep mode. More...
 
RTTTime time::delta (const RTTTime &time1, const RTTTime &time2)
 Compute the time delta from time1 and time2. More...
 
uint32_t time::since (uint32_t start_ms)
 Compute the time elapsed, in milliseconds, since start_ms. More...
 
void time::delay_us (uint16_t us) INLINE
 Delay program execution for the given amount of microseconds. More...
 
void time::delay_ms (uint16_t ms) INLINE
 Delay program execution for the given amount of milliseconds. More...
 
void time::default_delay (uint32_t ms)
 Delay program execution for the given amount of milliseconds. More...
 
template<typename CLOCK >
void time::set_clock (const CLOCK &clock)
 Utility method to transform millis() and delay() methods of a clock instance of any CLOCK class into static method equivalents, and assign the resulting static methods to time::millis and time::delay global function pointers. More...
 

Variables

DELAY_PTR time::delay = time::default_delay
 Delay program execution for the given amount of milliseconds. More...
 
MILLIS_PTR time::millis = nullptr
 Count number of milliseconds elapsed since some time base reference (generally since MCU startup). More...
 

Detailed Description

Simple time utilities.

Definition in file time.h.