SPIPerif class
#include <main/perif/SPIPerif.hpp>
Contents
A peripheral for SPI connections.
Base classes
- class Perif
Public functions
- auto begin() -> bool pure virtual
- auto isConnected() -> bool pure virtual
- 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
bool perif:: SPIPerif:: begin() pure virtual
#include <main/perif/Perif.hpp>
| 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:: SPIPerif:: isConnected() pure virtual
#include <main/perif/Perif.hpp>
| Returns | if the sensor is connected |
|---|
Returns whether the sensor is connected or not.
void perif:: SPIPerif:: update()
#include <main/perif/Perif.hpp>
Performs a manual update of peripheral data and notifies observers.
void perif:: SPIPerif:: 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:: SPIPerif:: 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:: SPIPerif:: 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:: SPIPerif:: getTimer() protected
#include <main/perif/Perif.hpp>
| Returns | a timer reference |
|---|
Obtains a reference to this peripheral's timer.
Variable documentation
DevMap perif:: SPIPerif:: data
#include <main/perif/Perif.hpp>
The key-value mapping of peripheral data.
list<function<void(DevMap&)>> perif:: SPIPerif:: hooks
#include <main/perif/Perif.hpp>
Hooks registered to this peripheral so observers can be notified of any necessary changes.
Timer perif:: SPIPerif:: timer protected
#include <main/perif/Perif.hpp>
A timer for managing peripheral updates.