Adafruit Library
|
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. | |
bool | Handle_I2cDeviceOutputWrite (wippersnapper_i2c_v1_I2CDeviceOutputWrite *msgDeviceWrite) |
Handles an I2CDeviceOutputWrite message. More... | |
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... | |
Class that provides an interface with the I2C bus.
WipperSnapper_Component_I2C::WipperSnapper_Component_I2C | ( | wippersnapper_i2c_v1_I2CBusInitRequest * | msgInitRequest | ) |
Creates a new WipperSnapper I2C component.
msgInitRequest | The I2C initialization request message. |
bool WipperSnapper_Component_I2C::isInitialized | ( | ) |
Returns if i2c port is initialized.
wippersnapper_i2c_v1_BusResponse WipperSnapper_Component_I2C::getBusStatus | ( | ) |
Returns the state of the I2C bus.
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.
bool WipperSnapper_Component_I2C::initI2CDevice | ( | wippersnapper_i2c_v1_I2CDeviceInitRequest * | msgDeviceInitReq | ) |
Initializes I2C device driver.
msgDeviceInitReq | A decoded I2CDevice initialization request message. |
void WipperSnapper_Component_I2C::updateI2CDeviceProperties | ( | wippersnapper_i2c_v1_I2CDeviceUpdateRequest * | msgDeviceUpdateReq | ) |
Updates the properties of an I2C device driver.
msgDeviceUpdateReq | A decoded I2CDeviceUpdateRequest. |
void WipperSnapper_Component_I2C::deinitI2CDevice | ( | wippersnapper_i2c_v1_I2CDeviceDeinitRequest * | msgDeviceDeinitReq | ) |
Deinitializes and deletes an I2C device driver object.
msgDeviceDeinitReq | A decoded I2CDeviceDeinitRequest. |
bool WipperSnapper_Component_I2C::Handle_I2cDeviceOutputWrite | ( | wippersnapper_i2c_v1_I2CDeviceOutputWrite * | msgDeviceWrite | ) |
Handles an I2CDeviceOutputWrite message.
msgDeviceWrite | A decoded I2CDeviceOutputWrite message. |
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.
iter | An iterator pointing to the current I2C device driver. |
curTime | The current time in milliseconds. |
msgi2cResponse | A pointer to the I2CResponse message. |
getEventFunc | A pointer to the I2C device driver's getEvent function. |
getPeriodFunc | A pointer to the I2C device driver's getPeriod function. |
getPeriodPrvFunc | A pointer to the I2C device driver's getPeriodPrv function. |
setPeriodPrvFunc | A pointer to the I2C device driver's setPeriodPrv function. |
sensorType | The type of sensor being read. |
sensorName | The name of the sensor being read. |
unit | The unit of measurement for the sensor. |
event | A sensors_event_t struct. |
valueMember | Pointer to sensors_event_t struct's value member unless data[0]. |
sensorsReturningFalse | A boolean indicating if the sensor is returning false. |
retries | The number of retries left for the sensor. |
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.
msgi2cResponse | A pointer to the signal's I2CResponse message. |
value | The value read by the sensor. |
sensorType | The SI unit represented by the sensor's value. |
void WipperSnapper_Component_I2C::displayDeviceEventMessage | ( | wippersnapper_signal_v1_I2CResponse * | msgi2cResponse, |
uint32_t | sensorAddress | ||
) |
Displays a sensor event message on the TFT.
msgi2cResponse | A pointer to an I2CResponse message. |
sensorAddress | The unique I2C address of the sensor. |
bool WipperSnapper_Component_I2C::encodePublishI2CDeviceEventMsg | ( | wippersnapper_signal_v1_I2CResponse * | msgi2cResponse, |
uint32_t | sensorAddress | ||
) |
Encodes an I2C sensor device's signal message.
msgi2cResponse | Pointer to an I2CResponse signal message. |
sensorAddress | The unique I2C address of the sensor. |