perif::SPIPerif class

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

DevMap data
list<function<void(DevMap&)>> hooks

Protected functions

void updateData() pure virtual
void representData() pure virtual
auto getTimer() -> Timer&

Protected variables

Timer timer

Function documentation

bool perif::SPIPerif::begin() pure virtual

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

Returns if the sensor is connected

Returns whether the sensor is connected or not.

void perif::SPIPerif::update()

Performs a manual update of peripheral data and notifies observers.

void perif::SPIPerif::registerHook(function<void(DevMap&)>&& hook)

Parameters
hook the observer function

Registers a hook for obtaining sensor data on update in Json format.

void perif::SPIPerif::updateData() pure virtual protected

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

The representation of this peripheral's data in a meaningful way for debugging, caching, and database operations.

Timer& perif::SPIPerif::getTimer() protected

Returns a timer reference

Obtains a reference to this peripheral's timer.

Variable documentation

DevMap perif::SPIPerif::data

The key-value mapping of peripheral data.

list<function<void(DevMap&)>> perif::SPIPerif::hooks

Hooks registered to this peripheral so observers can be notified of any necessary changes.

Timer perif::SPIPerif::timer protected

A timer for managing peripheral updates.