3#include <freertos/semphr.h>
18 xSemaphoreTakeRecursive(
event_loop->timed_queue_mutex_, portMAX_DELAY);
20 xSemaphoreGiveRecursive(
event_loop->timed_queue_mutex_);
46 xSemaphoreTakeRecursive(
event_loop->timed_queue_mutex_, portMAX_DELAY);
55 xSemaphoreGiveRecursive(
event_loop->timed_queue_mutex_);
59 xSemaphoreTakeRecursive(
event_loop->untimed_list_mutex_, portMAX_DELAY);
61 xSemaphoreGiveRecursive(
event_loop->untimed_list_mutex_);
69 if (0 != stream.available()) {
77bool ISREvent::isr_service_installed =
false;
79void ISREvent::isr(
void* this_ptr) {
80 auto* this_ =
static_cast<ISREvent*
>(this_ptr);
86 xSemaphoreTakeRecursive(
event_loop->isr_event_list_mutex_, portMAX_DELAY);
88 gpio_isr_handler_add((gpio_num_t)pin_number, ISREvent::isr, (
void*)
this);
90 attachInterrupt(digitalPinToInterrupt(pin_number),
callback, mode);
93 xSemaphoreGiveRecursive(
event_loop->isr_event_list_mutex_);
DelayEvent(uint32_t delay, react_callback callback)
Construct a new Delay Event object.
void tick(EventLoop *event_loop) override
const react_callback callback
Asynchronous event loop supporting timed (repeating and non-repeating), interrupt and stream events.
std::priority_queue< TimedEvent *, std::vector< TimedEvent * >, TriggerTimeCompare > timed_queue
Event that is triggered on an input pin change.
void remove(EventLoop *event_loop) override
void add(EventLoop *event_loop) override
void tick(EventLoop *event_loop) override
void tick(EventLoop *event_loop) override
void tick(EventLoop *event_loop) override
TimedEvents are called based on elapsing of time.
virtual void add(EventLoop *event_loop) override
virtual void remove(EventLoop *event_loop) override
bool operator<(const TimedEvent &other) const
uint64_t last_trigger_time
void add(EventLoop *event_loop) override
void remove(EventLoop *event_loop) override
std::function< void()> react_callback
uint64_t ICACHE_RAM_ATTR micros64()
Return the current time since the device restart in microseconds.