diff --git a/src/F_AK09918.hpp b/src/F_AK09918.hpp index 366c37c..12d63d3 100644 --- a/src/F_AK09918.hpp +++ b/src/F_AK09918.hpp @@ -58,7 +58,7 @@ enum AK09918_err_type_t { class AK09918 : public IMUBase { public: - AK09918() {}; + explicit AK09918(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -109,35 +109,36 @@ class AK09918 : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } diff --git a/src/F_AK8963.hpp b/src/F_AK8963.hpp index 2fa7d3f..29b156c 100644 --- a/src/F_AK8963.hpp +++ b/src/F_AK8963.hpp @@ -33,7 +33,7 @@ class AK8963 : public IMUBase { public: - AK8963() {}; + explicit AK8963(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -81,35 +81,36 @@ class AK8963 : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } diff --git a/src/F_AK8975.hpp b/src/F_AK8975.hpp index 42b9b11..4f382a8 100644 --- a/src/F_AK8975.hpp +++ b/src/F_AK8975.hpp @@ -33,7 +33,7 @@ class AK8975 : public IMUBase { public: - AK8975() {}; + explicit AK8975(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -81,35 +81,36 @@ class AK8975 : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } diff --git a/src/F_BMI055.hpp b/src/F_BMI055.hpp index 1906432..93dfc56 100644 --- a/src/F_BMI055.hpp +++ b/src/F_BMI055.hpp @@ -41,7 +41,7 @@ class BMI055 : public IMUBase { public: - BMI055() {}; + explicit BMI055(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -94,35 +94,36 @@ class BMI055 : public IMUBase { uint8_t AccelAddress; uint8_t GyroAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } }; diff --git a/src/F_BMI055_AK8975.hpp b/src/F_BMI055_AK8975.hpp index 6b79eae..e3426d0 100644 --- a/src/F_BMI055_AK8975.hpp +++ b/src/F_BMI055_AK8975.hpp @@ -8,7 +8,7 @@ class BMI055_QMC5883L : public IMUBase { public: - BMI055_QMC5883L() {}; + explicit BMI055_QMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_BMI055_HMC5883L.hpp b/src/F_BMI055_HMC5883L.hpp index 362d832..5dc7b6b 100644 --- a/src/F_BMI055_HMC5883L.hpp +++ b/src/F_BMI055_HMC5883L.hpp @@ -8,7 +8,7 @@ class BMI055_HMC5883L : public IMUBase { public: - BMI055_HMC5883L() {}; + explicit BMI055_HMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_BMI055_QMC5883L.hpp b/src/F_BMI055_QMC5883L.hpp index 6b79eae..e3426d0 100644 --- a/src/F_BMI055_QMC5883L.hpp +++ b/src/F_BMI055_QMC5883L.hpp @@ -8,7 +8,7 @@ class BMI055_QMC5883L : public IMUBase { public: - BMI055_QMC5883L() {}; + explicit BMI055_QMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_BMI160.hpp b/src/F_BMI160.hpp index 5d58cc0..6dc506a 100644 --- a/src/F_BMI160.hpp +++ b/src/F_BMI160.hpp @@ -103,7 +103,7 @@ class BMI160 : public IMUBase { public: - BMI160() {}; + explicit BMI160(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -154,35 +154,36 @@ class BMI160 : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } }; diff --git a/src/F_BMI160_AK8975.hpp b/src/F_BMI160_AK8975.hpp index 1de5c54..d77c362 100644 --- a/src/F_BMI160_AK8975.hpp +++ b/src/F_BMI160_AK8975.hpp @@ -8,7 +8,7 @@ class BMI160_AK8975 : public IMUBase { public: - BMI160_AK8975() {}; + explicit BMI160_AK8975(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_BMI160_HMC5883L.hpp b/src/F_BMI160_HMC5883L.hpp index ff59a9c..90149e7 100644 --- a/src/F_BMI160_HMC5883L.hpp +++ b/src/F_BMI160_HMC5883L.hpp @@ -8,7 +8,7 @@ class BMI160_HMC5883L : public IMUBase { public: - BMI160_HMC5883L() {}; + explicit BMI160_HMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_BMI160_QMC5883L.hpp b/src/F_BMI160_QMC5883L.hpp index efc09f2..2354d5b 100644 --- a/src/F_BMI160_QMC5883L.hpp +++ b/src/F_BMI160_QMC5883L.hpp @@ -8,7 +8,7 @@ class BMI160_QMC5883L : public IMUBase { public: - BMI160_QMC5883L() {}; + explicit BMI160_QMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_BMX055.hpp b/src/F_BMX055.hpp index cc4abb9..19d5ff2 100644 --- a/src/F_BMX055.hpp +++ b/src/F_BMX055.hpp @@ -61,7 +61,7 @@ class BMX055 : public IMUBase { public: - BMX055() {}; + explicit BMX055(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -118,35 +118,36 @@ class BMX055 : public IMUBase { uint8_t GyroAddress; uint8_t MagAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } }; diff --git a/src/F_HMC5883L.hpp b/src/F_HMC5883L.hpp index 7f0b6a3..23f52b1 100644 --- a/src/F_HMC5883L.hpp +++ b/src/F_HMC5883L.hpp @@ -28,7 +28,7 @@ class HMC5883L : public IMUBase { public: - HMC5883L() {}; + explicit HMC5883L(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -74,34 +74,36 @@ class HMC5883L : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; + void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } }; diff --git a/src/F_ICM20689.hpp b/src/F_ICM20689.hpp index 6ee2655..fecc011 100644 --- a/src/F_ICM20689.hpp +++ b/src/F_ICM20689.hpp @@ -84,7 +84,7 @@ class ICM20689 : public IMUBase { public: - ICM20689() {}; + explicit ICM20689(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -135,35 +135,36 @@ class ICM20689 : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } diff --git a/src/F_ICM20689_AK8975.hpp b/src/F_ICM20689_AK8975.hpp index 423218b..9984ec2 100644 --- a/src/F_ICM20689_AK8975.hpp +++ b/src/F_ICM20689_AK8975.hpp @@ -8,7 +8,7 @@ class ICM20689_AK8975 : public IMUBase { public: - ICM20689_AK8975() {}; + explicit ICM20689_AK8975(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_ICM20689_HMC5883L.hpp b/src/F_ICM20689_HMC5883L.hpp index 04a8088..8a73b84 100644 --- a/src/F_ICM20689_HMC5883L.hpp +++ b/src/F_ICM20689_HMC5883L.hpp @@ -8,7 +8,7 @@ class ICM20689_HMC5883L : public IMUBase { public: - ICM20689_HMC5883L() {}; + explicit ICM20689_HMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_ICM20689_QMC5883L.hpp b/src/F_ICM20689_QMC5883L.hpp index c62dfc7..12698b8 100644 --- a/src/F_ICM20689_QMC5883L.hpp +++ b/src/F_ICM20689_QMC5883L.hpp @@ -8,7 +8,7 @@ class ICM20689_QMC5883L : public IMUBase { public: - ICM20689_QMC5883L() {}; + explicit ICM20689_QMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_ICM20690.hpp b/src/F_ICM20690.hpp index 977f2d9..e01b9b9 100644 --- a/src/F_ICM20690.hpp +++ b/src/F_ICM20690.hpp @@ -84,7 +84,7 @@ class ICM20690 : public IMUBase { public: - ICM20690() {}; + explicit ICM20690(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -134,35 +134,36 @@ class ICM20690 : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } diff --git a/src/F_ICM20690_AK8975.hpp b/src/F_ICM20690_AK8975.hpp index 31ca3d2..5965946 100644 --- a/src/F_ICM20690_AK8975.hpp +++ b/src/F_ICM20690_AK8975.hpp @@ -8,7 +8,7 @@ class ICM20690_AK8975 : public IMUBase { public: - ICM20690_AK8975() {}; + explicit ICM20690_AK8975(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_ICM20690_HMC5883L.hpp b/src/F_ICM20690_HMC5883L.hpp index 9722aa9..4e6412b 100644 --- a/src/F_ICM20690_HMC5883L.hpp +++ b/src/F_ICM20690_HMC5883L.hpp @@ -8,7 +8,7 @@ class ICM20690_HMC5883L : public IMUBase { public: - ICM20690_HMC5883L() {}; + explicit ICM20690_HMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_ICM20690_QMC5883L.hpp b/src/F_ICM20690_QMC5883L.hpp index 894a8f6..f96aea2 100644 --- a/src/F_ICM20690_QMC5883L.hpp +++ b/src/F_ICM20690_QMC5883L.hpp @@ -8,7 +8,7 @@ class ICM20690_QMC5883L : public IMUBase { public: - ICM20690_QMC5883L() {}; + explicit ICM20690_QMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_IMU_Generic.hpp b/src/F_IMU_Generic.hpp index ba5ed23..bb7d5c4 100644 --- a/src/F_IMU_Generic.hpp +++ b/src/F_IMU_Generic.hpp @@ -161,7 +161,7 @@ class IMU_Generic : public IMUBase { public: - IMU_Generic() {}; + explicit IMU_Generic(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -214,35 +214,36 @@ class IMU_Generic : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } diff --git a/src/F_IMU_Generic_AK8975.hpp b/src/F_IMU_Generic_AK8975.hpp index 532f213..565ea5c 100644 --- a/src/F_IMU_Generic_AK8975.hpp +++ b/src/F_IMU_Generic_AK8975.hpp @@ -8,7 +8,7 @@ class IMU_Generic_AK8975 : public IMUBase { public: - IMU_Generic_AK8975() {}; + explicit IMU_Generic_AK8975(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_IMU_Generic_HMC5883L.hpp b/src/F_IMU_Generic_HMC5883L.hpp index 7f255d7..31643a9 100644 --- a/src/F_IMU_Generic_HMC5883L.hpp +++ b/src/F_IMU_Generic_HMC5883L.hpp @@ -8,7 +8,7 @@ class IMU_Generic_HMC5883L : public IMUBase { public: - IMU_Generic_HMC5883L() {}; + explicit IMU_Generic_HMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_IMU_Generic_QMC5883L.hpp b/src/F_IMU_Generic_QMC5883L.hpp index e4a2685..2814cc6 100644 --- a/src/F_IMU_Generic_QMC5883L.hpp +++ b/src/F_IMU_Generic_QMC5883L.hpp @@ -8,7 +8,7 @@ class IMU_Generic_QMC5883L : public IMUBase { public: - IMU_Generic_QMC5883L() {}; + explicit IMU_Generic_QMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_LSM6DS3.hpp b/src/F_LSM6DS3.hpp index ae0a59d..4a93f78 100644 --- a/src/F_LSM6DS3.hpp +++ b/src/F_LSM6DS3.hpp @@ -54,7 +54,7 @@ class LSM6DS3 : public IMUBase { public: - LSM6DS3() {}; + explicit LSM6DS3(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -104,35 +104,36 @@ class LSM6DS3 : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } }; diff --git a/src/F_LSM6DS3_AK8975.hpp b/src/F_LSM6DS3_AK8975.hpp index 1371c4a..3cf13b6 100644 --- a/src/F_LSM6DS3_AK8975.hpp +++ b/src/F_LSM6DS3_AK8975.hpp @@ -8,7 +8,7 @@ class LSM6DS3_AK8975 : public IMUBase { public: - LSM6DS3_AK8975() {}; + explicit LSM6DS3_AK8975(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_LSM6DS3_HMC5883L.hpp b/src/F_LSM6DS3_HMC5883L.hpp index 9c61243..5d47137 100644 --- a/src/F_LSM6DS3_HMC5883L.hpp +++ b/src/F_LSM6DS3_HMC5883L.hpp @@ -8,7 +8,7 @@ class LSM6DS3_HMC5883L : public IMUBase { public: - LSM6DS3_HMC5883L() {}; + explicit LSM6DS3_HMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_LSM6DS3_QMC5883L.hpp b/src/F_LSM6DS3_QMC5883L.hpp index 7ebfb48..7c7e1d8 100644 --- a/src/F_LSM6DS3_QMC5883L.hpp +++ b/src/F_LSM6DS3_QMC5883L.hpp @@ -8,7 +8,7 @@ class LSM6DS3_QMC5883L : public IMUBase { public: - LSM6DS3_QMC5883L() {}; + explicit LSM6DS3_QMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_LSM6DSL.hpp b/src/F_LSM6DSL.hpp index ad14fbd..2b52681 100644 --- a/src/F_LSM6DSL.hpp +++ b/src/F_LSM6DSL.hpp @@ -55,7 +55,7 @@ class LSM6DSL : public IMUBase { public: - LSM6DSL() {}; + explicit LSM6DSL(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -105,35 +105,36 @@ class LSM6DSL : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } }; diff --git a/src/F_LSM6DSL_AK8975.hpp b/src/F_LSM6DSL_AK8975.hpp index 94915f2..e6d09a2 100644 --- a/src/F_LSM6DSL_AK8975.hpp +++ b/src/F_LSM6DSL_AK8975.hpp @@ -8,7 +8,7 @@ class LSM6DSL_AK8975 : public IMUBase { public: - LSM6DSL_AK8975() {}; + explicit LSM6DSL_AK8975(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_LSM6DSL_HMC5883L.hpp b/src/F_LSM6DSL_HMC5883L.hpp index 556d8ee..b2842a6 100644 --- a/src/F_LSM6DSL_HMC5883L.hpp +++ b/src/F_LSM6DSL_HMC5883L.hpp @@ -8,7 +8,7 @@ class LSM6DSL_HMC5883L : public IMUBase { public: - LSM6DSL_HMC5883L() {}; + explicit LSM6DSL_HMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_LSM6DSL_QMC5883L.hpp b/src/F_LSM6DSL_QMC5883L.hpp index 40f908c..202087d 100644 --- a/src/F_LSM6DSL_QMC5883L.hpp +++ b/src/F_LSM6DSL_QMC5883L.hpp @@ -8,7 +8,7 @@ class LSM6DSL_QMC5883L : public IMUBase { public: - LSM6DSL_QMC5883L() {}; + explicit LSM6DSL_QMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_MPU6050.hpp b/src/F_MPU6050.hpp index c62266e..da0e586 100644 --- a/src/F_MPU6050.hpp +++ b/src/F_MPU6050.hpp @@ -70,7 +70,7 @@ class MPU6050 : public IMUBase { public: - MPU6050() {}; + explicit MPU6050(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -120,35 +120,36 @@ class MPU6050 : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } diff --git a/src/F_MPU6050_AK8975.hpp b/src/F_MPU6050_AK8975.hpp index ce21d23..8a449b0 100644 --- a/src/F_MPU6050_AK8975.hpp +++ b/src/F_MPU6050_AK8975.hpp @@ -8,7 +8,7 @@ class MPU6050_AK8975 : public IMUBase { public: - MPU6050_AK8975() {}; + explicit MPU6050_AK8975(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_MPU6050_HMC5883L.hpp b/src/F_MPU6050_HMC5883L.hpp index 49b47c6..36a5cdd 100644 --- a/src/F_MPU6050_HMC5883L.hpp +++ b/src/F_MPU6050_HMC5883L.hpp @@ -8,7 +8,7 @@ class MPU6050_HMC5883L : public IMUBase { public: - MPU6050_HMC5883L() {}; + explicit MPU6050_HMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_MPU6050_QMC5883L.hpp b/src/F_MPU6050_QMC5883L.hpp index 811a82d..831b536 100644 --- a/src/F_MPU6050_QMC5883L.hpp +++ b/src/F_MPU6050_QMC5883L.hpp @@ -8,7 +8,7 @@ class MPU6050_QMC5883L : public IMUBase { public: - MPU6050_QMC5883L() {}; + explicit MPU6050_QMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_MPU6500.hpp b/src/F_MPU6500.hpp index 7756d3c..d83bfcc 100644 --- a/src/F_MPU6500.hpp +++ b/src/F_MPU6500.hpp @@ -140,7 +140,7 @@ class MPU6500 : public IMUBase { public: - MPU6500() {}; + explicit MPU6500(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -190,35 +190,36 @@ class MPU6500 : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } diff --git a/src/F_MPU6500_AK8975.hpp b/src/F_MPU6500_AK8975.hpp index 7eec836..75d43a1 100644 --- a/src/F_MPU6500_AK8975.hpp +++ b/src/F_MPU6500_AK8975.hpp @@ -8,7 +8,7 @@ class MPU6500_AK8975 : public IMUBase { public: - MPU6500_AK8975() {}; + explicit MPU6500_AK8975(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_MPU6500_HMC5883L.hpp b/src/F_MPU6500_HMC5883L.hpp index 0f315f8..27fad8b 100644 --- a/src/F_MPU6500_HMC5883L.hpp +++ b/src/F_MPU6500_HMC5883L.hpp @@ -8,7 +8,7 @@ class MPU6500_HMC5883L : public IMUBase { public: - MPU6500_HMC5883L() {}; + explicit MPU6500_HMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_MPU6500_QMC5883L.hpp b/src/F_MPU6500_QMC5883L.hpp index 7b629b3..e00c287 100644 --- a/src/F_MPU6500_QMC5883L.hpp +++ b/src/F_MPU6500_QMC5883L.hpp @@ -8,7 +8,7 @@ class MPU6500_QMC5883L : public IMUBase { public: - MPU6500_QMC5883L() {}; + explicit MPU6500_QMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_MPU6515.hpp b/src/F_MPU6515.hpp index 63e5484..8af263b 100644 --- a/src/F_MPU6515.hpp +++ b/src/F_MPU6515.hpp @@ -140,7 +140,7 @@ class MPU6515 : public IMUBase { public: - MPU6515() {}; + explicit MPU6515(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -190,35 +190,36 @@ class MPU6515 : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } diff --git a/src/F_MPU6515_AK8975.hpp b/src/F_MPU6515_AK8975.hpp index 88dcb8b..9d66a66 100644 --- a/src/F_MPU6515_AK8975.hpp +++ b/src/F_MPU6515_AK8975.hpp @@ -8,7 +8,7 @@ class MPU6515_AK8975 : public IMUBase { public: - MPU6515_AK8975() {}; + explicit MPU6515_AK8975(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_MPU6515_HMC5883L.hpp b/src/F_MPU6515_HMC5883L.hpp index aaad875..c72ca09 100644 --- a/src/F_MPU6515_HMC5883L.hpp +++ b/src/F_MPU6515_HMC5883L.hpp @@ -8,7 +8,7 @@ class MPU6515_HMC5883L : public IMUBase { public: - MPU6515_HMC5883L() {}; + explicit MPU6515_HMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_MPU6515_QMC5883L.hpp b/src/F_MPU6515_QMC5883L.hpp index e8a68f7..a321eff 100644 --- a/src/F_MPU6515_QMC5883L.hpp +++ b/src/F_MPU6515_QMC5883L.hpp @@ -8,7 +8,7 @@ class MPU6515_QMC5883L : public IMUBase { public: - MPU6515_QMC5883L() {}; + explicit MPU6515_QMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_MPU6886.hpp b/src/F_MPU6886.hpp index 05c95d7..e950515 100644 --- a/src/F_MPU6886.hpp +++ b/src/F_MPU6886.hpp @@ -140,7 +140,7 @@ class MPU6886 : public IMUBase { public: - MPU6886() {}; + explicit MPU6886(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -190,35 +190,36 @@ class MPU6886 : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } diff --git a/src/F_MPU9250.hpp b/src/F_MPU9250.hpp index 709fa45..e9c5e6b 100644 --- a/src/F_MPU9250.hpp +++ b/src/F_MPU9250.hpp @@ -142,7 +142,7 @@ class MPU9250 : public IMUBase { public: - MPU9250() {}; + explicit MPU9250(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -199,35 +199,36 @@ class MPU9250 : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } diff --git a/src/F_MPU9255.hpp b/src/F_MPU9255.hpp index 9701bb9..1375480 100644 --- a/src/F_MPU9255.hpp +++ b/src/F_MPU9255.hpp @@ -142,7 +142,7 @@ class MPU9255 : public IMUBase { public: - MPU9255() {}; + explicit MPU9255(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -199,35 +199,36 @@ class MPU9255 : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } diff --git a/src/F_QMC5883L.hpp b/src/F_QMC5883L.hpp index 528d818..0facf08 100644 --- a/src/F_QMC5883L.hpp +++ b/src/F_QMC5883L.hpp @@ -28,7 +28,7 @@ class QMC5883L : public IMUBase { public: - QMC5883L() {}; + explicit QMC5883L(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -79,34 +79,36 @@ class QMC5883L : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; + void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } }; diff --git a/src/F_QMI8658.hpp b/src/F_QMI8658.hpp index aa1c768..ea4c0b1 100644 --- a/src/F_QMI8658.hpp +++ b/src/F_QMI8658.hpp @@ -59,7 +59,7 @@ class QMI8658 : public IMUBase { public: - QMI8658() {}; + explicit QMI8658(TwoWire& wire = Wire) : wire(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override; @@ -110,36 +110,38 @@ class QMI8658 : public IMUBase { calData calibration; uint8_t IMUAddress; + TwoWire& wire; + bool dataAvailable(){ return (readByte(IMUAddress, QMI8658_STATUS0) & 0x03);} void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.write(data); // Put data in Tx buffer - Wire.endTransmission(); // Send the Tx buffer + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.write(data); // Put data in Tx buffer + wire.endTransmission(); // Send the Tx buffer } uint8_t readByte(uint8_t address, uint8_t subAddress) { uint8_t data; // `data` will store the register data - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address - data = Wire.read(); // Fill Rx buffer with result + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.requestFrom(address, (uint8_t)1); // Read one byte from slave register address + data = wire.read(); // Fill Rx buffer with result return data; // Return data read from slave register } void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t* dest) { - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive + wire.beginTransmission(address); // Initialize the Tx buffer + wire.write(subAddress); // Put slave register address in Tx buffer + wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; - Wire.requestFrom(address, count); // Read bytes from slave register address - while (Wire.available()) { - dest[i++] = Wire.read(); + wire.requestFrom(address, count); // Read bytes from slave register address + while (wire.available()) { + dest[i++] = wire.read(); } // Put read results in the Rx buffer } }; diff --git a/src/F_QMI8658_AK09918.hpp b/src/F_QMI8658_AK09918.hpp index a4c7ed0..66a4544 100644 --- a/src/F_QMI8658_AK09918.hpp +++ b/src/F_QMI8658_AK09918.hpp @@ -8,7 +8,7 @@ class QMI8658_AK09918 : public IMUBase { public: - QMI8658_AK09918() {}; + explicit QMI8658_AK09918(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_QMI8658_AK8975.hpp b/src/F_QMI8658_AK8975.hpp index 7ba084a..36e16c6 100644 --- a/src/F_QMI8658_AK8975.hpp +++ b/src/F_QMI8658_AK8975.hpp @@ -8,7 +8,7 @@ class QMI8658_AK8975 : public IMUBase { public: - QMI8658_AK8975() {}; + explicit QMI8658_AK8975(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_QMI8658_HMC5883L.hpp b/src/F_QMI8658_HMC5883L.hpp index 9e253ef..3eac5be 100644 --- a/src/F_QMI8658_HMC5883L.hpp +++ b/src/F_QMI8658_HMC5883L.hpp @@ -8,7 +8,7 @@ class QMI8658_HMC5883L : public IMUBase { public: - QMI8658_HMC5883L() {}; + explicit QMI8658_HMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override { diff --git a/src/F_QMI8658_QMC5883L.hpp b/src/F_QMI8658_QMC5883L.hpp index b202020..8346cd5 100644 --- a/src/F_QMI8658_QMC5883L.hpp +++ b/src/F_QMI8658_QMC5883L.hpp @@ -8,7 +8,7 @@ class QMI8658_QMC5883L : public IMUBase { public: - QMI8658_QMC5883L() {}; + explicit QMI8658_QMC5883L(TwoWire& wire = Wire) : IMU(wire), MAG(wire) {}; // Inherited via IMUBase int init(calData cal, uint8_t address) override {