Class that provides an interface with the I2C bus.
More...
#include <WipperSnapper_I2C.h>
|
| 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...
|
|
Class that provides an interface with the I2C bus.
◆ WipperSnapper_Component_I2C()
WipperSnapper_Component_I2C::WipperSnapper_Component_I2C |
( |
wippersnapper_i2c_v1_I2CBusInitRequest * |
msgInitRequest | ) |
|
Creates a new WipperSnapper I2C component.
- Parameters
-
msgInitRequest | The I2C initialization request message. |
◆ 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
-
msgDeviceInitReq | A 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
-
msgDeviceUpdateReq | A decoded I2CDeviceUpdateRequest. |
◆ deinitI2CDevice()
void WipperSnapper_Component_I2C::deinitI2CDevice |
( |
wippersnapper_i2c_v1_I2CDeviceDeinitRequest * |
msgDeviceDeinitReq | ) |
|
Deinitializes and deletes an I2C device driver object.
- Parameters
-
msgDeviceDeinitReq | A 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
-
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. |
◆ 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
-
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. |
◆ displayDeviceEventMessage()
void WipperSnapper_Component_I2C::displayDeviceEventMessage |
( |
wippersnapper_signal_v1_I2CResponse * |
msgi2cResponse, |
|
|
uint32_t |
sensorAddress |
|
) |
| |
Displays a sensor event message on the TFT.
- Parameters
-
msgi2cResponse | A pointer to an I2CResponse message. |
sensorAddress | The 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
-
msgi2cResponse | Pointer to an I2CResponse signal message. |
sensorAddress | The 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: