Skip to content

Commit f3c19b8

Browse files
committed
add V1 Presence class for backward compat
1 parent 74cc750 commit f3c19b8

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/SparkFun_Qwiic_XM125_Arduino_Library.h

+48
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
// To support version 1.* API
2727
#include "sfTk/sfDevXM125DistanceV1.h"
28+
#include "sfTk/sfDevXM125PresenceV1.h"
2829
// clang-format on
2930

3031
#include <Arduino.h>
@@ -163,6 +164,53 @@ class SparkFunXM125DistanceV1 : public sfDevXM125DistanceV1
163164
return _i2cBus.ping() == ksfTkErrOk;
164165
}
165166

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+
166214
private:
167215
// I2C bus class
168216
sfTkArdI2C _i2cBus;

0 commit comments

Comments
 (0)