Skyward boardcore
|
#include <PinObserver.h>
Classes | |
struct | PinConfig |
Pin configuration. More... | |
struct | PinData |
Pin information. More... | |
Public Types | |
using | Clock = std::chrono::steady_clock |
using | TimePoint = Clock::time_point |
using | PinCallback = std::function< void(PinTransition transition, const PinData &data)> |
Callback function type for pin transitions. | |
Public Member Functions | |
PinObserver (TaskScheduler &scheduler, uint32_t pollInterval=20) | |
Construct a new PinObserver object. | |
bool | registerPinCallback (miosix::GpioPin pin, PinCallback callback, uint32_t detectionThreshold=1, bool reverted=false) |
PinData | getPinData (miosix::GpioPin pin) |
Returns the information for the specified pin. | |
void | resetPinChangesCount (miosix::GpioPin pin) |
Resets the changes counter for the specified pin. | |
Class used to call a callback after a pin performs a specific transition (RISING or FALLING edge) and stays in the new state for a specific amount of time. Useful if you want to monitor pin transitions but you want to avoid spurious state changes.
A callback to monitor each state change no matter the threshold or the transition is also available, in order to be able to observe the current state of the pin.
Definition at line 54 of file PinObserver.h.
using Boardcore::PinObserver::Clock = std::chrono::steady_clock |
Definition at line 57 of file PinObserver.h.
using Boardcore::PinObserver::PinCallback = std::function<void(PinTransition transition, const PinData& data)> |
Callback function type for pin transitions.
transition | The type of transition that triggered the callback. |
data | The data associated with the pin, updated with the latest transition information. |
Definition at line 88 of file PinObserver.h.
using Boardcore::PinObserver::TimePoint = Clock::time_point |
Definition at line 58 of file PinObserver.h.
|
inline |
Construct a new PinObserver object.
scheduler | Scheduler to be used by this PinObserver. |
pollInterval | Pin transition polling interval, defaults to 20 [ms]. |
Definition at line 107 of file PinObserver.h.
PinData Boardcore::PinObserver::getPinData | ( | miosix::GpioPin | pin | ) |
Returns the information for the specified pin.
Definition at line 71 of file PinObserver.cpp.
bool Boardcore::PinObserver::registerPinCallback | ( | miosix::GpioPin | pin, |
PinCallback | callback, | ||
uint32_t | detectionThreshold = 1 , |
||
bool | reverted = false |
||
) |
Observe a pin for a specific transition, and optionally for every single state change. The callback receives the transition and the time point when the transition happened as parameters.
pin | Pin to listen to. |
callback | Function to call on pin events. |
detectionThreshold | How many times the pin should be observed in the post-transition state to trigger the actual transition callback, defaults to 1. |
Definition at line 28 of file PinObserver.cpp.
void Boardcore::PinObserver::resetPinChangesCount | ( | miosix::GpioPin | pin | ) |
Resets the changes counter for the specified pin.
Definition at line 80 of file PinObserver.cpp.