|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
Abstract IMU device interface for polymorphic IMU sensor implementations. More...
#include <ImuBase.hpp>
Public Types | |
| enum class | DataReadyMask : uint8_t { ACCEL = 0x01 , GYRO = 0x02 , BOTH = 0x03 } |
Public Member Functions | |
| virtual | ~ImuBase ()=default |
| virtual bool | reset ()=0 |
| Reset the IMU sensor to its default state. | |
| virtual bool | selfTest ()=0 |
| Perform self-test on the IMU sensor. | |
| virtual bool | isPresent ()=0 |
| Check if the IMU sensor is responding. | |
| virtual uint8_t | getChipID ()=0 |
| Get the chip ID / WHO_AM_I value. | |
| virtual uint32_t | getFirmwareVersion ()=0 |
| Get the firmware version. | |
| virtual bool | setOperationMode (OperationMode mode)=0 |
| Set IMU operation mode. | |
| bool | powerOn () |
| Compatibility wrapper: switch IMU to NORMAL mode. | |
| bool | powerDown () |
| Compatibility wrapper: switch IMU to SUSPEND mode. | |
| virtual float | getTemperature ()=0 |
| Get the temperature reading from the sensor. | |
| virtual uint32_t | getTimestamp ()=0 |
| Get the timestamp from the sensor. | |
| virtual bool | isDataReady (uint8_t mask=static_cast< uint8_t >(DataReadyMask::BOTH))=0 |
| Check if requested IMU data is available. | |
| virtual bool | readAccel (AccelerometerData &out)=0 |
| Read accelerometer data. | |
| virtual bool | enableAccel ()=0 |
| Enable the accelerometer. | |
| virtual bool | disableAccel ()=0 |
| Disable the accelerometer. | |
| virtual bool | isAccelEnabled ()=0 |
| Check if accelerometer is enabled. | |
| virtual bool | setAccelFullScaleRange (AccelFullScaleRange range)=0 |
| Set accelerometer full scale range. | |
| virtual bool | setAccelOutputDataRate (float data_rate_hz)=0 |
| Set accelerometer output data rate. | |
| virtual bool | readAccelRaw (int16_t &x, int16_t &y, int16_t &z)=0 |
| Read raw accelerometer data without scaling. | |
| virtual bool | readGyro (GyroscopeData &out)=0 |
| Read gyroscope data. | |
| virtual bool | enableGyro ()=0 |
| Enable the gyroscope. | |
| virtual bool | disableGyro ()=0 |
| Disable the gyroscope. | |
| virtual bool | isGyroEnabled ()=0 |
| Check if gyroscope is enabled. | |
| virtual bool | setGyroFullScaleRange (GyroFullScaleRange range)=0 |
| Set gyroscope full scale range. | |
| virtual bool | setGyroOutputDataRate (float data_rate_hz)=0 |
| Set gyroscope output data rate. | |
| virtual bool | readGyroRaw (int16_t &x, int16_t &y, int16_t &z)=0 |
| Read raw gyroscope data without scaling. | |
| virtual bool | enableSyncMode ()=0 |
| Enable synchronous sampling mode. | |
| virtual bool | disableSyncMode ()=0 |
| Disable synchronous sampling mode. | |
| virtual bool | configureFifo (bool enable, uint8_t watermark_samples=16)=0 |
| Configure the FIFO buffer. | |
| virtual uint16_t | readFromFifo (AccelerometerData *accel_data, uint16_t accel_count, GyroscopeData *gyro_data, uint16_t gyro_count)=0 |
| Read data from FIFO buffer. | |
Abstract IMU device interface for polymorphic IMU sensor implementations.
This interface defines the common contract that all IMU drivers must implement. It enables polymorphic usage of different IMU sensors through a unified interface.
A concrete IMU driver (e.g., QMI8658...) should implement this. Then adapters can expose AccelerometerBase / GyroscopeBase views without multiple inheritance.
Definition at line 42 of file ImuBase.hpp.
|
strong |
| Enumerator | |
|---|---|
| ACCEL | |
| GYRO | |
| BOTH | |
Definition at line 45 of file ImuBase.hpp.
|
virtualdefault |
|
pure virtual |
Configure the FIFO buffer.
| enable | true to enable FIFO, false to disable. |
| watermark_samples | Number of samples for watermark interrupt. |
Implemented in SensorQMI8658.
|
pure virtual |
Disable the accelerometer.
Implemented in SensorQMI8658.
|
pure virtual |
Disable the gyroscope.
Implemented in SensorQMI8658.
|
pure virtual |
Disable synchronous sampling mode.
Implemented in SensorQMI8658.
|
pure virtual |
Enable the accelerometer.
Implemented in SensorQMI8658.
|
pure virtual |
Enable the gyroscope.
Implemented in SensorQMI8658.
|
pure virtual |
Enable synchronous sampling mode.
Implemented in SensorQMI8658.
|
pure virtual |
Get the chip ID / WHO_AM_I value.
Implemented in SensorQMI8658, and SensorQMI8658.
|
pure virtual |
|
pure virtual |
Get the temperature reading from the sensor.
Implemented in SensorQMI8658.
|
pure virtual |
Get the timestamp from the sensor.
Implemented in SensorQMI8658, and SensorQMI8658.
|
pure virtual |
Check if accelerometer is enabled.
Implemented in SensorQMI8658.
|
pure virtual |
Check if requested IMU data is available.
| mask | Data-ready target mask (ACCEL / GYRO / BOTH). |
Implemented in SensorQMI8658.
Referenced by ImuAccelerometerAdapter::isDataReady(), and ImuGyroscopeAdapter::isDataReady().
|
pure virtual |
Check if gyroscope is enabled.
Implemented in SensorQMI8658.
|
pure virtual |
Check if the IMU sensor is responding.
Implemented in SensorQMI8658.
|
inline |
Compatibility wrapper: switch IMU to SUSPEND mode.
Definition at line 103 of file ImuBase.hpp.
References setOperationMode(), and SUSPEND.
|
inline |
Compatibility wrapper: switch IMU to NORMAL mode.
Definition at line 95 of file ImuBase.hpp.
References NORMAL, and setOperationMode().
|
pure virtual |
Read accelerometer data.
| [out] | out | Reference to store the read data. |
Implemented in SensorQMI8658.
Referenced by ImuAccelerometerAdapter::readData().
|
pure virtual |
Read raw accelerometer data without scaling.
| [out] | x | X-axis raw value. |
| [out] | y | Y-axis raw value. |
| [out] | z | Z-axis raw value. |
Implemented in SensorQMI8658.
|
pure virtual |
Read data from FIFO buffer.
| [out] | accel_data | Array to store accelerometer samples. |
| accel_count | Maximum number of accelerometer samples. | |
| [out] | gyro_data | Array to store gyroscope samples. |
| gyro_count | Maximum number of gyroscope samples. |
Implemented in SensorQMI8658.
|
pure virtual |
Read gyroscope data.
| [out] | out | Reference to store the read data. |
Implemented in SensorQMI8658.
Referenced by ImuGyroscopeAdapter::readData().
|
pure virtual |
Read raw gyroscope data without scaling.
| [out] | x | X-axis raw value. |
| [out] | y | Y-axis raw value. |
| [out] | z | Z-axis raw value. |
Implemented in SensorQMI8658.
|
pure virtual |
Reset the IMU sensor to its default state.
Implemented in SensorQMI8658.
Referenced by ImuAccelerometerAdapter::reset(), and ImuGyroscopeAdapter::reset().
|
pure virtual |
Perform self-test on the IMU sensor.
Implemented in SensorQMI8658.
Referenced by ImuAccelerometerAdapter::selfTest(), and ImuGyroscopeAdapter::selfTest().
|
pure virtual |
Set accelerometer full scale range.
| range | Full scale range setting. |
Implemented in SensorQMI8658.
Referenced by ImuAccelerometerAdapter::setFullScaleRange().
|
pure virtual |
Set accelerometer output data rate.
| data_rate_hz | Output data rate in Hz. |
Implemented in SensorQMI8658.
Referenced by ImuAccelerometerAdapter::setOutputDataRate().
|
pure virtual |
Set gyroscope full scale range.
| range | Full scale range setting. |
Implemented in SensorQMI8658.
Referenced by ImuGyroscopeAdapter::setFullScaleRange().
|
pure virtual |
Set gyroscope output data rate.
| data_rate_hz | Output data rate in Hz. |
Implemented in SensorQMI8658.
Referenced by ImuGyroscopeAdapter::setOutputDataRate().
|
pure virtual |
Set IMU operation mode.
| mode | Target operation mode. |
Implemented in SensorQMI8658.
Referenced by powerDown(), powerOn(), ImuAccelerometerAdapter::setOperationMode(), and ImuGyroscopeAdapter::setOperationMode().