|
25 | 25 |
|
26 | 26 | // To support version 1.* API
|
27 | 27 | #include "sfTk/sfDevXM125DistanceV1.h"
|
| 28 | +#include "sfTk/sfDevXM125PresenceV1.h" |
28 | 29 | // clang-format on
|
29 | 30 |
|
30 | 31 | #include <Arduino.h>
|
@@ -163,6 +164,53 @@ class SparkFunXM125DistanceV1 : public sfDevXM125DistanceV1
|
163 | 164 | return _i2cBus.ping() == ksfTkErrOk;
|
164 | 165 | }
|
165 | 166 |
|
| 167 | + private: |
| 168 | + // I2C bus class |
| 169 | + sfTkArdI2C _i2cBus; |
| 170 | +}; |
| 171 | + |
| 172 | +/** |
| 173 | + * @class SparkFunXM125Presence |
| 174 | + * @brief Arduino class for the SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125 (Qwiic) for presence detection. |
| 175 | + * |
| 176 | + * This class is to provide Version 1 compatibility for the SparkFun Pulsed Coherent Radar Sensor - presence detection. |
| 177 | + * |
| 178 | + * This class provides methods for initializing the sensor, checking connection status, and configuring the device |
| 179 | + * for presence detection using I2C communication. |
| 180 | + */ |
| 181 | +class SparkFunXM125PresenceV1 : public sfDevXM125PresenceV1 |
| 182 | +{ |
| 183 | + public: |
| 184 | + SparkFunXM125PresenceV1() |
| 185 | + { |
| 186 | + } |
| 187 | + |
| 188 | + /** |
| 189 | + * @brief Sets up Arduino I2C driver using the specified I2C address then calls the super class begin. |
| 190 | + * |
| 191 | + * @param deviceAddress Address of the I2C device. Default is SFE_XM125_I2C_ADDRESS. |
| 192 | + * @param wirePort Wire port of the I2C device. Default is Wire. |
| 193 | + * @return True if successful, false otherwise. |
| 194 | + */ |
| 195 | + bool begin(uint8_t deviceAddress = SFE_XM125_I2C_ADDRESS, TwoWire &wirePort = Wire) |
| 196 | + { |
| 197 | + // Give the I2C port provided by the user to the I2C bus class. |
| 198 | + _i2cBus.init(wirePort, deviceAddress); |
| 199 | + |
| 200 | + // Initialize the system - return results |
| 201 | + return this->sfDevXM125PresenceV1::begin(&_i2cBus) == ksfTkErrOk; |
| 202 | + } |
| 203 | + |
| 204 | + /** |
| 205 | + * @brief Checks if the device is connected. |
| 206 | + * |
| 207 | + * @return True if the sensor is connected, false otherwise. |
| 208 | + */ |
| 209 | + bool isConnected() |
| 210 | + { |
| 211 | + return _i2cBus.ping() == ksfTkErrOk; |
| 212 | + } |
| 213 | + |
166 | 214 | private:
|
167 | 215 | // I2C bus class
|
168 | 216 | sfTkArdI2C _i2cBus;
|
|
0 commit comments