2222#include " sfTk/sfDevXM125Core.h"
2323#include " sfTk/sfDevXM125Distance.h"
2424#include " sfTk/sfDevXM125Presence.h"
25+
26+ // To support version 1.* API
27+ #include " sfTk/sfDevXM125DistanceV1.h"
2528// clang-format on
2629
2730#include < Arduino.h>
@@ -116,3 +119,51 @@ class SparkFunXM125Presence : public sfDevXM125Presence
116119 // I2C bus class
117120 sfTkArdI2C _i2cBus;
118121};
122+
123+ // Version 1 - for backward compatibility
124+ /* *
125+ * @class SparkFunXM125DistanceV1
126+ * @brief Arduino class for the SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125 (Qwiic) for distance detection.
127+ *
128+ * This class is to provide Version 1 compatibility for the SparkFun Pulsed Coherent Radar Sensor - distance detection.
129+ *
130+ * This class provides methods for initializing the sensor, checking connection status, and configuring the device
131+ * for distance detection using I2C communication.
132+ */
133+ class SparkFunXM125DistanceV1 : public sfDevXM125DistanceV1
134+ {
135+ public:
136+ SparkFunXM125DistanceV1 ()
137+ {
138+ }
139+
140+ /* *
141+ * @brief Sets up Arduino I2C driver using the specified I2C address then calls the super class begin.
142+ *
143+ * @param deviceAddress Address of the I2C device. Default is SFE_XM125_I2C_ADDRESS.
144+ * @param wirePort Wire port of the I2C device. Default is Wire.
145+ * @return True if successful, false otherwise.
146+ */
147+ bool begin (uint8_t deviceAddress = SFE_XM125_I2C_ADDRESS, TwoWire &wirePort = Wire)
148+ {
149+ // Give the I2C port provided by the user to the I2C bus class.
150+ _i2cBus.init (wirePort, deviceAddress);
151+
152+ // Initialize the system - return results
153+ return this ->sfDevXM125DistanceV1 ::begin (&_i2cBus) == ksfTkErrOk;
154+ }
155+
156+ /* *
157+ * @brief Checks if the device is connected.
158+ *
159+ * @return True if the sensor is connected, false otherwise.
160+ */
161+ bool isConnected ()
162+ {
163+ return _i2cBus.ping () == ksfTkErrOk;
164+ }
165+
166+ private:
167+ // I2C bus class
168+ sfTkArdI2C _i2cBus;
169+ };
0 commit comments