modm API documentation
modm::GenericTimeout< Clock, Duration > Class Template Reference

#include <modm/processing/timer/timeout.hpp>

Public Typedefs

using clock = Clock
 
using period = typename Duration::period
 
using rep = typename Duration::rep
 
using time_point = std::chrono::time_point< Clock, Duration >
 
using duration = Duration
 
using wide_signed_duration = std::chrono::duration< modm::WideType< std::make_signed_t< rep > >, period >
 

Public Member Functions

 GenericTimeout () = default
 Create a stopped timeout.
 
template<typename Rep , typename Period >
 GenericTimeout (std::chrono::duration< Rep, Period > interval)
 Create and start the timeout.
 
void restart ()
 Restart the timer with the current timeout.
 
template<typename Rep , typename Period >
void restart (std::chrono::duration< Rep, Period > interval)
 Set a new timeout value.
 
void stop ()
 Stops the timer and sets isStopped() to true, and isExpired() to false.
 
wide_signed_duration remaining () const
 
duration interval () const
 
TimerState state () const
 
bool isStopped () const
 
bool isExpired () const
 
bool isArmed () const
 
bool execute ()
 
void wait ()
 

Protected Types

enum  InternalState : uint8_t {
  STOPPED = int(TimerState::Stopped), EXPIRED = int(TimerState::Expired), ARMED = int(TimerState::Armed), EXECUTED = 0b1000,
  STATUS_MASK = (EXPIRED | ARMED | STOPPED)
}
 

Protected Member Functions

bool checkExpiration () const
 
time_point now () const
 

Protected Attributes

time_point _start {duration{0}}
 
duration _interval {0}
 
uint8_t _state {STOPPED}
 

Friends

class GenericPeriodicTimer< Clock, Duration >
 

Detailed Description

template<class Clock, class Duration>
class modm::GenericTimeout< Clock, Duration >

Generic software timeout class for variable timebase and timestamp width.

See also
GenericPeriodicTimer
Template Parameters
ClockUsed clock which inherits from modm::Clock, may have a variable timebase.
DurationTypeUsed timestamp which is compatible with the chosen Clock.
Author
Fabian Greif
Niklas Hauser

Member Function Documentation

template<class Clock , class Duration >
bool modm::GenericTimeout< Clock, Duration >::execute ( )
Returns
true exactly once, after the timeout expired
template<class Clock , class Duration >
duration modm::GenericTimeout< Clock, Duration >::interval ( ) const
Returns
the currently set interval
template<class Clock , class Duration >
bool modm::GenericTimeout< Clock, Duration >::isArmed ( ) const
Returns
true if the timeout is armed (not stopped and not expired), false otherwise
template<class Clock , class Duration >
bool modm::GenericTimeout< Clock, Duration >::isExpired ( ) const
Returns
true if the timeout has expired, false otherwise
template<class Clock , class Duration >
bool modm::GenericTimeout< Clock, Duration >::isStopped ( ) const
Returns
true if the timeout is stopped, false otherwise
template<class Clock , class Duration >
wide_signed_duration modm::GenericTimeout< Clock, Duration >::remaining ( ) const
Returns
the time until (positive time) or since (negative time) expiration, or 0 if stopped
template<class Clock , class Duration >
TimerState modm::GenericTimeout< Clock, Duration >::state ( ) const
Returns
the current state of the timeout
template<class Clock , class Duration >
void modm::GenericTimeout< Clock, Duration >::wait ( )

Wait until the timeout expired.

Warning
This is a blocking call! Inside a fiber, this function yields.

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