Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::PinObserver Class Reference

#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.
 

Detailed Description

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.

Member Typedef Documentation

◆ PinCallback

using Boardcore::PinObserver::PinCallback = std::function<void(PinTransition)>

Definition at line 69 of file PinObserver.h.

Constructor & Destructor Documentation

◆ PinObserver()

Boardcore::PinObserver::PinObserver ( TaskScheduler & scheduler,
uint32_t pollInterval = 20 )
inlineexplicit

Construct a new PinObserver object.

Parameters
schedulerScheduler to be used by this PinObserver.
pollIntervalPin transition polling interval, defaults to 20 [ms].

Definition at line 77 of file PinObserver.h.

Member Function Documentation

◆ getPinData()

PinData Boardcore::PinObserver::getPinData ( miosix::GpioPin pin)

Returns the information for the specified pin.

Definition at line 59 of file PinObserver.cpp.

◆ registerPinCallback()

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.

Parameters
pinPin to listen to.
callbackFunction to call on button events.
detectionThresholdHow many times the pin should be observed in the post-transition state to trigger the actual transition callback, defaults to 1.
Returns
False if another callback was already registered for the pin.

Definition at line 32 of file PinObserver.cpp.

◆ resetPinChangesCount()

void Boardcore::PinObserver::resetPinChangesCount ( miosix::GpioPin pin)

Resets the changes counter for the specified pin.

Definition at line 61 of file PinObserver.cpp.


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