Adafruit Library
Public Member Functions | List of all members
WipperSnapper_Component_I2C Class Reference

Class that provides an interface with the I2C bus. More...

#include <WipperSnapper_I2C.h>

Public Member Functions

 WipperSnapper_Component_I2C (wippersnapper_i2c_v1_I2CBusInitRequest *msgInitRequest)
 Creates a new WipperSnapper I2C component. More...
 
 ~WipperSnapper_Component_I2C ()
 Destructor for a WipperSnapper I2C component.
 
bool isInitialized ()
 Returns if i2c port is initialized. More...
 
wippersnapper_i2c_v1_BusResponse getBusStatus ()
 Returns the state of the I2C bus. More...
 
wippersnapper_i2c_v1_I2CBusScanResponse scanAddresses ()
 Scans all I2C addresses on the bus between 0x08 and 0x7F inclusive and returns an array of the devices found. More...
 
bool initI2CDevice (wippersnapper_i2c_v1_I2CDeviceInitRequest *msgDeviceInitReq)
 Initializes I2C device driver. More...
 
void updateI2CDeviceProperties (wippersnapper_i2c_v1_I2CDeviceUpdateRequest *msgDeviceUpdateReq)
 Updates the properties of an I2C device driver. More...
 
void deinitI2CDevice (wippersnapper_i2c_v1_I2CDeviceDeinitRequest *msgDeviceDeinitReq)
 Deinitializes and deletes an I2C device driver object. More...
 
void update ()
 Queries all I2C device drivers for new values. Fills and sends an I2CSensorEvent with the sensor event data.
 
void sensorEventRead (std::vector< WipperSnapper_I2C_Driver *>::iterator &iter, unsigned long curTime, wippersnapper_signal_v1_I2CResponse *msgi2cResponse, bool(WipperSnapper_I2C_Driver::*getEventFunc)(sensors_event_t *), long(WipperSnapper_I2C_Driver::*getPeriodFunc)(), long(WipperSnapper_I2C_Driver::*getPeriodPrvFunc)(), void(WipperSnapper_I2C_Driver::*setPeriodPrvFunc)(long), wippersnapper_i2c_v1_SensorType sensorType, const char *sensorName, const char *unit, sensors_event_t event, float sensors_event_t::*valueMember, bool &sensorsReturningFalse, int &retries)
 Reads a sensor event from an I2C device driver. More...
 
void fillEventMessage (wippersnapper_signal_v1_I2CResponse *msgi2cResponse, float value, wippersnapper_i2c_v1_SensorType sensorType)
 Fills a sensor_event message with the sensor's value and type. More...
 
void displayDeviceEventMessage (wippersnapper_signal_v1_I2CResponse *msgi2cResponse, uint32_t sensorAddress)
 Displays a sensor event message on the TFT. More...
 
bool encodePublishI2CDeviceEventMsg (wippersnapper_signal_v1_I2CResponse *msgi2cResponse, uint32_t sensorAddress)
 Encodes an I2C sensor device's signal message. More...
 

Detailed Description

Class that provides an interface with the I2C bus.

Constructor & Destructor Documentation

◆ WipperSnapper_Component_I2C()

WipperSnapper_Component_I2C::WipperSnapper_Component_I2C ( wippersnapper_i2c_v1_I2CBusInitRequest *  msgInitRequest)

Creates a new WipperSnapper I2C component.

Parameters
msgInitRequestThe I2C initialization request message.

Member Function Documentation

◆ isInitialized()

bool WipperSnapper_Component_I2C::isInitialized ( )

Returns if i2c port is initialized.

Returns
True if initialized, False otherwise.

◆ getBusStatus()

wippersnapper_i2c_v1_BusResponse WipperSnapper_Component_I2C::getBusStatus ( )

Returns the state of the I2C bus.

Returns
wippersnapper_i2c_v1_BusResponse.

◆ scanAddresses()

wippersnapper_i2c_v1_I2CBusScanResponse WipperSnapper_Component_I2C::scanAddresses ( )

Scans all I2C addresses on the bus between 0x08 and 0x7F inclusive and returns an array of the devices found.

Returns
wippersnapper_i2c_v1_I2CBusScanResponse

◆ initI2CDevice()

bool WipperSnapper_Component_I2C::initI2CDevice ( wippersnapper_i2c_v1_I2CDeviceInitRequest *  msgDeviceInitReq)

Initializes I2C device driver.

Parameters
msgDeviceInitReqA decoded I2CDevice initialization request message.
Returns
True if I2C device is initialized and attached, False otherwise.

◆ updateI2CDeviceProperties()

void WipperSnapper_Component_I2C::updateI2CDeviceProperties ( wippersnapper_i2c_v1_I2CDeviceUpdateRequest *  msgDeviceUpdateReq)

Updates the properties of an I2C device driver.

Parameters
msgDeviceUpdateReqA decoded I2CDeviceUpdateRequest.

◆ deinitI2CDevice()

void WipperSnapper_Component_I2C::deinitI2CDevice ( wippersnapper_i2c_v1_I2CDeviceDeinitRequest *  msgDeviceDeinitReq)

Deinitializes and deletes an I2C device driver object.

Parameters
msgDeviceDeinitReqA decoded I2CDeviceDeinitRequest.

◆ sensorEventRead()

void WipperSnapper_Component_I2C::sensorEventRead ( std::vector< WipperSnapper_I2C_Driver *>::iterator &  iter,
unsigned long  curTime,
wippersnapper_signal_v1_I2CResponse *  msgi2cResponse,
bool(WipperSnapper_I2C_Driver::*)(sensors_event_t *)  getEventFunc,
long(WipperSnapper_I2C_Driver::*)()  getPeriodFunc,
long(WipperSnapper_I2C_Driver::*)()  getPeriodPrvFunc,
void(WipperSnapper_I2C_Driver::*)(long)  setPeriodPrvFunc,
wippersnapper_i2c_v1_SensorType  sensorType,
const char *  sensorName,
const char *  unit,
sensors_event_t  event,
float sensors_event_t::*  valueMember,
bool &  sensorsReturningFalse,
int &  retries 
)

Reads a sensor event from an I2C device driver.

Parameters
iterAn iterator pointing to the current I2C device driver.
curTimeThe current time in milliseconds.
msgi2cResponseA pointer to the I2CResponse message.
getEventFuncA pointer to the I2C device driver's getEvent function.
getPeriodFuncA pointer to the I2C device driver's getPeriod function.
getPeriodPrvFuncA pointer to the I2C device driver's getPeriodPrv function.
setPeriodPrvFuncA pointer to the I2C device driver's setPeriodPrv function.
sensorTypeThe type of sensor being read.
sensorNameThe name of the sensor being read.
unitThe unit of measurement for the sensor.
eventA sensors_event_t struct.
valueMemberPointer to sensors_event_t struct's value member unless data[0].
sensorsReturningFalseA boolean indicating if the sensor is returning false.
retriesThe number of retries left for the sensor.

◆ fillEventMessage()

void WipperSnapper_Component_I2C::fillEventMessage ( wippersnapper_signal_v1_I2CResponse *  msgi2cResponse,
float  value,
wippersnapper_i2c_v1_SensorType  sensorType 
)

Fills a sensor_event message with the sensor's value and type.

Parameters
msgi2cResponseA pointer to the signal's I2CResponse message.
valueThe value read by the sensor.
sensorTypeThe SI unit represented by the sensor's value.

◆ displayDeviceEventMessage()

void WipperSnapper_Component_I2C::displayDeviceEventMessage ( wippersnapper_signal_v1_I2CResponse *  msgi2cResponse,
uint32_t  sensorAddress 
)

Displays a sensor event message on the TFT.

Parameters
msgi2cResponseA pointer to an I2CResponse message.
sensorAddressThe unique I2C address of the sensor.

◆ encodePublishI2CDeviceEventMsg()

bool WipperSnapper_Component_I2C::encodePublishI2CDeviceEventMsg ( wippersnapper_signal_v1_I2CResponse *  msgi2cResponse,
uint32_t  sensorAddress 
)

Encodes an I2C sensor device's signal message.

Parameters
msgi2cResponsePointer to an I2CResponse signal message.
sensorAddressThe unique I2C address of the sensor.
Returns
True if message encoded successfully, False otherwise.

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