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

Structure used to hold a time value with microsecond precision. More...

#include <fastarduino/time.h>

Public Member Functions

 RTTTime (uint32_t micros=0UL)
 Construct a new RTTTime value. More...
 
 RTTTime (uint32_t millis, uint16_t micros)
 Construct a new RTTTime value. More...
 
 RTTTime (const RTTTime &that)
 Construct a copy of that. More...
 
RTTTimeoperator= (const RTTTime &that)
 Assign this RTTTime instance from that. More...
 
RTTTimeoperator+= (uint32_t microseconds)
 Add microseconds to this RTTTime instance. More...
 
RTTTimeoperator-= (uint32_t microseconds)
 Remove microseconds from this RTTTime instance. More...
 
uint32_t total_micros () const
 Return current elapsed time in microseconds only. More...
 
uint32_t millis () const
 Number of elapsed milliseconds. More...
 
uint16_t micros () const
 Number of elapsed microseconds (0..999). More...
 

Detailed Description

Structure used to hold a time value with microsecond precision.

Note that this value is not absolute but relative to some time base, not defined here, but depending on the API producing or consuming an RTTTime.

Parameters
millisnumber of milliseconds elapsed since some predefined time base
microsnumber of microseconds, added to millis, elapsed since some predefined time base reference, between 0 and 999; setting a greater value is not supported and will have an undefined behavior of the API consuming such an RTTTime instance.

Definition at line 49 of file time.h.

Constructor & Destructor Documentation

◆ RTTTime() [1/3]

time::RTTTime::RTTTime ( uint32_t  micros = 0UL)
inlineexplicit

Construct a new RTTTime value.

Parameters
microsnumber of microseconds (can be > 1000us)

Definition at line 56 of file time.h.

◆ RTTTime() [2/3]

time::RTTTime::RTTTime ( uint32_t  millis,
uint16_t  micros 
)
inline

Construct a new RTTTime value.

Parameters
millisnumber of milliseconds
microsnumber of microseconds (0..999)

Definition at line 63 of file time.h.

◆ RTTTime() [3/3]

time::RTTTime::RTTTime ( const RTTTime that)
inline

Construct a copy of that.

Parameters
that

Definition at line 69 of file time.h.

Member Function Documentation

◆ operator=()

RTTTime & time::RTTTime::operator= ( const RTTTime that)
inline

Assign this RTTTime instance from that.

Parameters
thatthe source real time value
Returns
this instance

Definition at line 76 of file time.h.

◆ operator+=()

RTTTime & time::RTTTime::operator+= ( uint32_t  microseconds)
inline

Add microseconds to this RTTTime instance.

Parameters
microsecondsthe number of us to add to this RTTTime
Returns
this instance

Definition at line 91 of file time.h.

◆ operator-=()

RTTTime & time::RTTTime::operator-= ( uint32_t  microseconds)
inline

Remove microseconds from this RTTTime instance.

Parameters
microsecondsthe number of us to subtract from this RTTTime; results are undetermined if microseconds is larger than total_micros().
Returns
this instance

Definition at line 111 of file time.h.

◆ total_micros()

uint32_t time::RTTTime::total_micros ( ) const
inline

Return current elapsed time in microseconds only.

Definition at line 119 of file time.h.

◆ millis()

uint32_t time::RTTTime::millis ( ) const
inline

Number of elapsed milliseconds.

Definition at line 125 of file time.h.

◆ micros()

uint16_t time::RTTTime::micros ( ) const
inline

Number of elapsed microseconds (0..999).

Definition at line 131 of file time.h.


The documentation for this class was generated from the following file: