Skyward boardcore
|
#include <PinObserver.h>
Public Types | |
using | PinCallback = std::function<void(PinTransition)> |
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 66 of file PinObserver.h.
using Boardcore::PinObserver::PinCallback = std::function<void(PinTransition)> |
Definition at line 69 of file PinObserver.h.
|
inlineexplicit |
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 77 of file PinObserver.h.
PinData Boardcore::PinObserver::getPinData | ( | miosix::GpioPin | pin | ) |
Returns the information for the specified pin.
Definition at line 59 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.
pin | Pin to listen to. |
callback | Function to call on button 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 32 of file PinObserver.cpp.
void Boardcore::PinObserver::resetPinChangesCount | ( | miosix::GpioPin | pin | ) |
Resets the changes counter for the specified pin.
Definition at line 61 of file PinObserver.cpp.