Speeduino
Loading...
Searching...
No Matches
polling.hpp
Go to the documentation of this file.
1#pragma once
2#include <stdint.h>
3#include "bit_manip.h"
4
12using byte = uint8_t;
13
19
25static inline void executePolledAction(const polledAction_t &action, byte loopTimer)
26{
27 if (BIT_CHECK(loopTimer, action.timerBit)) {
28 action.pCallback();
29 }
30}
31
Bit twiddling macros.
#define BIT_CHECK(var, pos)
Is bit pos (0-7) in byte var set?
Definition bit_manip.h:15
uint8_t byte
Definition config_pages.h:16
static TIntegral readSerialIntegralTimeout(void)
Reads an integral type, timing out if necessary.
Definition comms.cpp:173
static void executePolledAction(const polledAction_t &action, byte loopTimer)
Conditionally execute a polled action if the timer bit is set.
Definition polling.hpp:25
static void executePolledArrayAction(uint8_t index, const polledAction_t *pActions, byte loopTimer)
Execute a polled action at a specific index in the array of actions.
Definition polling.hpp:40
An action to be polled at a specific frequency.
Definition polling.hpp:15
void(* pCallback)(void)
The function to call when the timer bit is set.
Definition polling.hpp:17
uint8_t timerBit
The timer bit to poll this action. E.g. BIT_TIMER_1HZ.
Definition polling.hpp:16