ReactESP 3.0.1
Asynchronous programming for the ESP microcontrollers
Loading...
Searching...
No Matches
reactesp::TimedEvent Class Reference

TimedEvents are called based on elapsing of time. More...

#include <ReactESP.h>

Inheritance diagram for reactesp::TimedEvent:
[legend]
Collaboration diagram for reactesp::TimedEvent:
[legend]

Public Member Functions

 TimedEvent (uint32_t interval, react_callback callback)
 Construct a new Timed Event object.
 
 TimedEvent (uint64_t interval, react_callback callback)
 Construct a new Timed Event object.
 
bool operator< (const TimedEvent &other) const
 Return the current time since the device restart in microseconds.
 
void add (EventLoop *event_loop) override
 
void remove (EventLoop *event_loop) override
 
uint32_t getTriggerTime () const
 
uint64_t getTriggerTimeMicros () const
 
bool isEnabled () const
 
- Public Member Functions inherited from reactesp::Event
 Event (react_callback callback)
 Construct a new Event object.
 
 Event (const Event &)=delete
 
 Event (Event &&)=delete
 
Eventoperator= (const Event &)=delete
 
Eventoperator= (Event &&)=delete
 
- Public Member Functions inherited from reactesp::EventInterface
virtual ~EventInterface ()=default
 Default virtual destructor.
 
virtual void tick (EventLoop *event_loop)=0
 

Protected Attributes

const uint64_t interval
 
uint64_t last_trigger_time
 
bool enabled
 
- Protected Attributes inherited from reactesp::Event
const react_callback callback
 

Detailed Description

TimedEvents are called based on elapsing of time.

Definition at line 63 of file ReactESP.h.

Constructor & Destructor Documentation

◆ TimedEvent() [1/2]

reactesp::TimedEvent::TimedEvent ( uint32_t interval,
react_callback callback )
inline

Construct a new Timed Event object.

Parameters
intervalInterval or delay for the event, in milliseconds
callbackFunction to be called when the event is triggered

Definition at line 76 of file ReactESP.h.

◆ TimedEvent() [2/2]

reactesp::TimedEvent::TimedEvent ( uint64_t interval,
react_callback callback )
inline

Construct a new Timed Event object.

Parameters
intervalInterval, in microseconds
callbackFunction to be called when the event is triggered

Definition at line 87 of file ReactESP.h.

Member Function Documentation

◆ add()

void reactesp::TimedEvent::add ( EventLoop * event_loop)
overridevirtual

Implements reactesp::EventInterface.

Definition at line 29 of file ReactESP.cpp.

◆ getTriggerTime()

uint32_t reactesp::TimedEvent::getTriggerTime ( ) const
inline

Definition at line 96 of file ReactESP.h.

◆ getTriggerTimeMicros()

uint64_t reactesp::TimedEvent::getTriggerTimeMicros ( ) const
inline

Definition at line 99 of file ReactESP.h.

◆ isEnabled()

bool reactesp::TimedEvent::isEnabled ( ) const
inline

Definition at line 102 of file ReactESP.h.

◆ operator<()

bool reactesp::TimedEvent::operator< ( const TimedEvent & other) const

Return the current time since the device restart in microseconds.

Returns the time since the device restart. Even though the time is in microseconds, a 64-bit integer is all but guaranteed not to rewrap, ever.

Definition at line 24 of file ReactESP.cpp.

◆ remove()

void reactesp::TimedEvent::remove ( EventLoop * event_loop)
overridevirtual

Implements reactesp::EventInterface.

Definition at line 33 of file ReactESP.cpp.

Member Data Documentation

◆ enabled

bool reactesp::TimedEvent::enabled
protected

Definition at line 67 of file ReactESP.h.

◆ interval

const uint64_t reactesp::TimedEvent::interval
protected

Definition at line 65 of file ReactESP.h.

◆ last_trigger_time

uint64_t reactesp::TimedEvent::last_trigger_time
protected

Definition at line 66 of file ReactESP.h.


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