1- #include " sfe_bus.h"
2- #include " sfeXM125Regs.h"
1+ #include " sfeQwiicXM125.h"
2+ #include < Arduino.h>
3+ #include < Wire.h>
34
4- // Add any definitions hereby
5-
6-
7- class QwDevXM125
5+ class SfeXM125 : public QwDevXM125
86{
97 public:
108
11- //
12- // /////////////////////////////////////////////////////////////////////
13- // begin()
14- //
15- //
16- // This method follows the standard startup pattern in SparkFun Arduino
17- // libraries.
18- //
19- // Parameter Description
20- // --------- ----------------------------
21- // wirePort optional. The Wire port. If not provided, the default port is used
22- // address optional. I2C Address. If not provided, the default address is used.
23- // retval true on success, false on startup failure
24- //
25- // This method is overridden, implementing two versions.
26- //
27- // Version 1:
28- // User skips passing in an I2C object which then defaults to Wire.
29- bool begin (uint8_t deviceAddress = SFE_XM125_I2C_ADDRESS)
9+ SfeXM125 ()
3010 {
31- // Setup I2C object and pass into the superclass
32- setCommunicationBus (_i2cBus, deviceAddress);
33-
34- // Initialize the I2C buss class i.e. setup default Wire port
35- _i2cBus.init ();
36-
37- // Initialize the system - return results
38- return this ->QwDevXM125 ::init ();
3911 }
4012
41- // Version 2:
42- // User passes in an I2C object and an address (optional).
43- bool begin (TwoWire &wirePort, uint8_t deviceAddress = SFE_XM125_I2C_ADDRESS)
13+ // / @brief Sets up Arduino I2C driver using the specified I2C address then calls the super class begin.
14+ // / @param address Address of the I2C device.
15+ // / @return True if successful, false otherwise.
16+ bool begin (uint8_t deviceAddress = SFE_XM125_I2C_ADDRESS, TwoWire &wirePort = Wire)
4417 {
45- // Setup I2C object and pass into the superclass
46- setCommunicationBus (_i2cBus, deviceAddress);
47-
4818 // Give the I2C port provided by the user to the I2C bus class.
49- _i2cBus.init (wirePort, true );
19+ _i2cBus.init (wirePort, deviceAddress );
5020
5121 // Initialize the system - return results
52- return this ->QwDevXM125 ::init ( );
22+ return this ->QwDevXM125 ::begin (&_i2cBus );
5323 }
5424
5525 private:
5626
5727 // I2C bus class
58- sfe_XM125::QwI2C _i2cBus;
59-
60-
61-
62- }
28+ sfeTkArdI2C _i2cBus;
29+ // QwDevXM125::QwI2C _i2cBus; // original code
30+ };
0 commit comments