perif::BarPAT class

A barometric pressure/temperature sensor. TODO add altitude for upgraded mpl3115A2 sensor

Base classes

template<i2c_port_t port = I2C_NUM_0, bool sdaPullup = false, bool sclPullup = false, uint32_t frequency = 100000UL>
class I2CPerif

Constructors, destructors, conversion operators

BarPAT(uint8_t address = 0x60) explicit

Public functions

auto begin() -> bool override
auto isConnected() -> bool override
void update()
void registerHook(function<void(DevMap&)>&& hook)

Public variables

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

Protected functions

auto getTimer() -> Timer&

Protected variables

uint8_t address
Timer timer

Private functions

void updateData() override
void representData() override

Function documentation

perif::BarPAT::BarPAT(uint8_t address = 0x60) explicit

Parameters
address the I2C address

Explicit value constructor for MPL115A2 sensor.

bool perif::BarPAT::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::BarPAT::isConnected() override

Returns if the I2C port is initialized

Whether this I2C port is initialized.

void perif::BarPAT::update()

Performs a manual update of peripheral data and notifies observers.

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

Parameters
hook the observer function

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

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

Returns a timer reference

Obtains a reference to this peripheral's timer.

void perif::BarPAT::updateData() override private

Updates sensor data. Subclasses should maintain a reference to the data obtained from this function so it can be provided to observers.

void perif::BarPAT::representData() override private

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

Variable documentation

DevMap perif::BarPAT::data

The key-value mapping of peripheral data.

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

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

uint8_t perif::BarPAT::address protected

the address for this i2c device

Timer perif::BarPAT::timer protected

A timer for managing peripheral updates.