32
32
#include " REG/QMC6310Constants.h"
33
33
#include " SensorPlatform.hpp"
34
34
35
+ static constexpr uint8_t QMC6310U_SLAVE_ADDRESS = 0x1C ;
36
+ static constexpr uint8_t QMC6310N_SLAVE_ADDRESS = 0x3C ;
37
+
35
38
class Polar
36
39
{
37
40
public:
@@ -98,27 +101,27 @@ class SensorQMC6310 : public QMC6310Constants
98
101
}
99
102
100
103
#if defined(ARDUINO)
101
- bool begin (TwoWire &wire, int sda = -1 , int scl = -1 )
104
+ bool begin (TwoWire &wire, uint8_t addr = QMC6310U_SLAVE_ADDRESS, int sda = -1 , int scl = -1 )
102
105
{
103
- if (!beginCommon<SensorCommI2C, HalArduino>(comm, hal, wire, QMC6310_SLAVE_ADDRESS , sda, scl)) {
106
+ if (!beginCommon<SensorCommI2C, HalArduino>(comm, hal, wire, addr , sda, scl)) {
104
107
return false ;
105
108
}
106
109
return initImpl ();
107
110
}
108
111
#elif defined(ESP_PLATFORM)
109
112
110
113
#if defined(USEING_I2C_LEGACY)
111
- bool begin (i2c_port_t port_num, int sda = -1 , int scl = -1 )
114
+ bool begin (i2c_port_t port_num, uint8_t addr = QMC6310U_SLAVE_ADDRESS, int sda = -1 , int scl = -1 )
112
115
{
113
- if (!beginCommon<SensorCommI2C, HalEspIDF>(comm, hal, port_num, QMC6310_SLAVE_ADDRESS , sda, scl)) {
116
+ if (!beginCommon<SensorCommI2C, HalEspIDF>(comm, hal, port_num, addr , sda, scl)) {
114
117
return false ;
115
118
}
116
119
return initImpl ();
117
120
}
118
121
#else
119
- bool begin (i2c_master_bus_handle_t handle)
122
+ bool begin (i2c_master_bus_handle_t handle, uint8_t addr = QMC6310U_SLAVE_ADDRESS )
120
123
{
121
- if (!beginCommon<SensorCommI2C, HalEspIDF>(comm, hal, handle, QMC6310_SLAVE_ADDRESS , sda, scl)) {
124
+ if (!beginCommon<SensorCommI2C, HalEspIDF>(comm, hal, handle, addr , sda, scl)) {
122
125
return false ;
123
126
}
124
127
return initImpl ();
@@ -127,10 +130,11 @@ class SensorQMC6310 : public QMC6310Constants
127
130
#endif
128
131
129
132
bool begin (SensorCommCustom::CustomCallback callback,
130
- SensorCommCustomHal::CustomHalCallback hal_callback)
133
+ SensorCommCustomHal::CustomHalCallback hal_callback,
134
+ uint8_t addr = QMC6310U_SLAVE_ADDRESS)
131
135
{
132
136
if (!beginCommCustomCallback<SensorCommCustom, SensorCommCustomHal>(COMM_CUSTOM,
133
- callback, hal_callback, QMC6310_SLAVE_ADDRESS , comm, hal)) {
137
+ callback, hal_callback, addr , comm, hal)) {
134
138
return false ;
135
139
}
136
140
return initImpl ();
0 commit comments