GPIOPerif class
#include <main/perif/GPIOPerif.hpp>
Contents
A peripheral that interfaces with GPIO pins directly.
Base classes
- class Perif
Derived classes
- class USDist
Constructors, destructors, conversion operators
- GPIOPerif(const char* name) explicit
Public functions
- auto begin() -> bool override
- auto isConnected() -> bool override
- auto setPin(uint8_t pin, gpio_mode_t mode = GPIO_MODE_INPUT_OUTPUT, bool pullUp = false, bool pullDown = false) -> bool
- auto setIntrPin(uint8_t pin, gpioFunc&& handler, uint8_t isrFlags = 0, gpio_int_type_t intrType = GPIO_INTR_ANYEDGE, gpio_mode_t mode = GPIO_MODE_INPUT_OUTPUT, bool pullUp = false, bool pullDown = false) -> bool
- void update()
- void registerHook(function<void(DevMap&)>&& hook)
Public variables
Protected functions
- void updateData() pure virtual
- void representData() pure virtual
- auto getTimer() -> Timer&
Protected variables
Function documentation
perif:: GPIOPerif:: GPIOPerif(const char* name) explicit
| Parameters | |
|---|---|
| name | the name of the peripheral |
Explicit value constructor for GPIO peripherals.
bool perif:: GPIOPerif:: begin() override
| Returns | whether the peripheral initialization succeeded |
|---|
Performs initialization of a peripheral. Necessary to avoid initialization in the constructor which causes many side effects.
bool perif:: GPIOPerif:: isConnected() override
| Returns | if the sensor is connected |
|---|
Returns whether the sensor is connected or not.
bool perif:: GPIOPerif:: setPin(uint8_t pin,
gpio_mode_t mode = GPIO_MODE_INPUT_OUTPUT,
bool pullUp = false,
bool pullDown = false)
| Parameters | |
|---|---|
| pin | the GPIO pin number |
| mode | the GPIO pin mode |
| pullUp | whether the pin is a pullup |
| pullDown | whether the pin is a pulldown |
| Returns | if the pin was setup successfully |
Sets up a pin for GPIO operations with interrupts disabled.
bool perif:: GPIOPerif:: setIntrPin(uint8_t pin,
gpioFunc&& handler,
uint8_t isrFlags = 0,
gpio_int_type_t intrType = GPIO_INTR_ANYEDGE,
gpio_mode_t mode = GPIO_MODE_INPUT_OUTPUT,
bool pullUp = false,
bool pullDown = false)
| Parameters | |
|---|---|
| pin | the pin number |
| handler | the interrupt handler |
| isrFlags | any interrupt configuration flags |
| intrType | the interrupt type |
| mode | the GPIO pin mode |
| pullUp | whether the pin is a pullup |
| pullDown | whether the pin is a pulldown |
| Returns | if the interrupt pin was setup successfully |
Specify a pin to use as an interrupt.
void perif:: GPIOPerif:: update()
#include <main/perif/Perif.hpp>
Performs a manual update of peripheral data and notifies observers.
void perif:: GPIOPerif:: registerHook(function<void(DevMap&)>&& hook)
#include <main/perif/Perif.hpp>
| Parameters | |
|---|---|
| hook | the observer function |
Registers a hook for obtaining sensor data on update in Json format.
void perif:: GPIOPerif:: updateData() pure virtual protected
#include <main/perif/Perif.hpp>
Updates sensor data. Subclasses should maintain a reference to the data obtained from this function so it can be provided to observers.
void perif:: GPIOPerif:: representData() pure virtual protected
#include <main/perif/Perif.hpp>
The representation of this peripheral's data in a meaningful way for debugging, caching, and database operations.
Timer& perif:: GPIOPerif:: getTimer() protected
#include <main/perif/Perif.hpp>
| Returns | a timer reference |
|---|
Obtains a reference to this peripheral's timer.
Variable documentation
DevMap perif:: GPIOPerif:: data
#include <main/perif/Perif.hpp>
The key-value mapping of peripheral data.
list<function<void(DevMap&)>> perif:: GPIOPerif:: hooks
#include <main/perif/Perif.hpp>
Hooks registered to this peripheral so observers can be notified of any necessary changes.
Timer perif:: GPIOPerif:: timer protected
#include <main/perif/Perif.hpp>
A timer for managing peripheral updates.