@@ -123,11 +123,26 @@ static const std::map<std::string, FnCreateI2CDriver> I2cFactory = {
123
123
const char *driver_name) -> drvBase * {
124
124
return new drvHtu21d (i2c, addr, mux_channel, driver_name);
125
125
}},
126
+ {" htu31d" ,
127
+ [](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
128
+ const char *driver_name) -> drvBase * {
129
+ return new drvHtu31d (i2c, addr, mux_channel, driver_name);
130
+ }},
131
+ {" hdc302x" ,
132
+ [](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
133
+ const char *driver_name) -> drvBase * {
134
+ return new drvHdc302x (i2c, addr, mux_channel, driver_name);
135
+ }},
126
136
{" ina219" ,
127
137
[](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
128
138
const char *driver_name) -> drvBase * {
129
139
return new drvIna219 (i2c, addr, mux_channel, driver_name);
130
140
}},
141
+ {" ina260" ,
142
+ [](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
143
+ const char *driver_name) -> drvBase * {
144
+ return new drvIna260 (i2c, addr, mux_channel, driver_name);
145
+ }},
131
146
{" lc709203f" ,
132
147
[](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
133
148
const char *driver_name) -> drvBase * {
@@ -148,6 +163,11 @@ static const std::map<std::string, FnCreateI2CDriver> I2cFactory = {
148
163
const char *driver_name) -> drvBase * {
149
164
return new drvLps25hb (i2c, addr, mux_channel, driver_name);
150
165
}},
166
+ {" lps28dfw" ,
167
+ [](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
168
+ const char *driver_name) -> drvBase * {
169
+ return new drvLps28dfw (i2c, addr, mux_channel, driver_name);
170
+ }},
151
171
{" ltr329" ,
152
172
[](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
153
173
const char *driver_name) -> drvBase * {
@@ -223,6 +243,11 @@ static const std::map<std::string, FnCreateI2CDriver> I2cFactory = {
223
243
const char *driver_name) -> drvBase * {
224
244
return new drvScd30 (i2c, addr, mux_channel, driver_name);
225
245
}},
246
+ {" sgp30" ,
247
+ [](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
248
+ const char *driver_name) -> drvBase * {
249
+ return new drvSgp30 (i2c, addr, mux_channel, driver_name);
250
+ }},
226
251
{" sgp40" ,
227
252
[](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
228
253
const char *driver_name) -> drvBase * {
@@ -278,6 +303,36 @@ static const std::map<std::string, FnCreateI2CDriver> I2cFactory = {
278
303
const char *driver_name) -> drvBase * {
279
304
return new drvSen5x (i2c, addr, mux_channel, driver_name);
280
305
}},
306
+ {" sen60" ,
307
+ [](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
308
+ const char *driver_name) -> drvBase * {
309
+ return new drvSen6x (i2c, addr, mux_channel, driver_name);
310
+ }},
311
+ {" sen63c" ,
312
+ [](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
313
+ const char *driver_name) -> drvBase * {
314
+ return new drvSen6x (i2c, addr, mux_channel, driver_name);
315
+ }},
316
+ {" sen65" ,
317
+ [](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
318
+ const char *driver_name) -> drvBase * {
319
+ return new drvSen6x (i2c, addr, mux_channel, driver_name);
320
+ }},
321
+ {" sen66" ,
322
+ [](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
323
+ const char *driver_name) -> drvBase * {
324
+ return new drvSen6x (i2c, addr, mux_channel, driver_name);
325
+ }},
326
+ {" sen68" ,
327
+ [](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
328
+ const char *driver_name) -> drvBase * {
329
+ return new drvSen6x (i2c, addr, mux_channel, driver_name);
330
+ }},
331
+ {" sen6x" ,
332
+ [](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
333
+ const char *driver_name) -> drvBase * {
334
+ return new drvSen6x (i2c, addr, mux_channel, driver_name);
335
+ }},
281
336
{" shtc3" ,
282
337
[](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
283
338
const char *driver_name) -> drvBase * {
@@ -318,6 +373,11 @@ static const std::map<std::string, FnCreateI2CDriver> I2cFactory = {
318
373
const char *driver_name) -> drvBase * {
319
374
return new drvVncl4040 (i2c, addr, mux_channel, driver_name);
320
375
}},
376
+ {" vncl4200" ,
377
+ [](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
378
+ const char *driver_name) -> drvBase * {
379
+ return new drvVncl4200 (i2c, addr, mux_channel, driver_name);
380
+ }},
321
381
{" vl53l0x" ,
322
382
[](TwoWire *i2c, uint16_t addr, uint32_t mux_channel,
323
383
const char *driver_name) -> drvBase * {
@@ -365,10 +425,14 @@ static const std::unordered_map<uint16_t, std::vector<const char *>>
365
425
{0x2A , {" nau7802" }},
366
426
{0x38 , {" aht20" , " max17048" }},
367
427
{0x39 , {" tsl2591" }},
368
- {0x40 , {" htu21d" , " ina219" , " ms8607" , " si7021" , " stemma_soil" }},
369
- {0x41 , {" ina219" }},
370
- {0x44 , {" sht3x" , " sht4x" }},
371
- {0x45 , {" sht3x" }},
428
+ {0x40 ,
429
+ {" htu21d" , " htu31d" , " ina219" , " ina260" , " ms8607" , " si7021" ,
430
+ " stemma_soil" }},
431
+ {0x41 , {" htu31d" , " ina219" , " ina260" }},
432
+ {0x44 , {" hdc302x" , " ina260" , " sht3x" , " sht4x" }},
433
+ {0x45 , {" hdc302x" , " ina260" , " sht3x" }},
434
+ {0x46 , {" hdc302x" }},
435
+ {0x47 , {" hdc302x" }},
372
436
{0x48 , {" adt7410" , " pct2075" , " tmp117" }},
373
437
{0x49 , {" adt7410" , " pct2075" , " tmp117" , " tsl2591" }},
374
438
{0x4A , {" adt7410" , " pct2075" , " tmp117" }},
@@ -377,17 +441,21 @@ static const std::unordered_map<uint16_t, std::vector<const char *>>
377
441
{0x4D , {" pct2075" }},
378
442
{0x4E , {" pct2075" }},
379
443
{0x4F , {" pct2075" }},
444
+ {0x51 , {" vcnl4200" }},
380
445
{0x52 , {" ens160" }},
381
446
{0x53 , {" ens160" , " ltr390" }},
447
+ {0x58 , {" sgp30" }},
382
448
{0x59 , {" sgp40" }},
383
- {0x5C , {" bh1750" , " lps22hb" , " lps25hb" }},
384
- {0x5D , {" lps22hb" , " lps25hb" }},
449
+ {0x5C ,
450
+ {" bh1750" , " lps22hb" , " lps25hb" , " lps28dfw" , " lps33hw" , " lps35hw" }},
451
+ {0x5D , {" lps22hb" , " lps25hb" , " lps28dfw" , " lps33hw" , " lps35hw" }},
385
452
{0x5F , {" hts2221" }},
386
453
{0x60 , {" mpl115a2" , " vncl4040" }},
387
454
{0x61 , {" scd30" }},
388
455
{0x62 , {" scd40" }},
389
456
{0x68 , {" mcp3421" }},
390
- {0x69 , {" sen50" }},
457
+ {0x69 , {" sen55" }},
458
+ {0x6B , {" sen66" }},
391
459
{0x70 , {" pct2075" , " shtc3" }},
392
460
{0x71 , {" pct2075" }},
393
461
{0x72 , {" pct2075" }},
@@ -862,11 +930,39 @@ bool I2cController::Handle_I2cDeviceAddOrReplace(pb_istream_t *stream) {
862
930
*/
863
931
/* **********************************************************************/
864
932
bool I2cController::ScanI2cBus (bool default_bus = true ) {
865
- _i2c_bus_default-> InitBus (default_bus);
933
+ // zero-out the scan I2cBusScanned message before attempting a scan
866
934
_scan_results = wippersnapper_i2c_I2cBusScanned_init_zero;
867
- if (!default_bus)
935
+
936
+ // Scan the desired i2c bus
937
+ if (default_bus) {
938
+ if (_i2c_bus_default->GetBusStatus () !=
939
+ wippersnapper_i2c_I2cBusStatus_I2C_BUS_STATUS_SUCCESS) {
940
+ _i2c_bus_default->InitBus (default_bus);
941
+ }
942
+ return _i2c_bus_default->ScanBus (&_scan_results);
943
+ } else {
944
+ if (_i2c_bus_alt->GetBusStatus () !=
945
+ wippersnapper_i2c_I2cBusStatus_I2C_BUS_STATUS_SUCCESS) {
946
+ _i2c_bus_alt->InitBus (default_bus);
947
+ }
868
948
return _i2c_bus_alt->ScanBus (&_scan_results);
869
- return _i2c_bus_default->ScanBus (&_scan_results);
949
+ }
950
+ }
951
+
952
+ /* **********************************************************************/
953
+ /* !
954
+ @brief Returns the I2C bus object.
955
+ @param is_alt_bus
956
+ True if the alternative I2C bus is being used, False
957
+ otherwise.
958
+ @returns A pointer to the I2C bus object.
959
+ */
960
+ /* **********************************************************************/
961
+ TwoWire *I2cController::GetI2cBus (bool is_alt_bus) {
962
+ if (is_alt_bus) {
963
+ return _i2c_bus_alt->GetBus ();
964
+ }
965
+ return _i2c_bus_default->GetBus ();
870
966
}
871
967
872
968
/* **********************************************************************/
@@ -934,6 +1030,13 @@ void I2cController::ConfigureMuxChannel(uint32_t mux_channel, bool is_alt_bus) {
934
1030
_i2c_bus_default->SelectMuxChannel (mux_channel);
935
1031
}
936
1032
1033
+ void I2cController::PrintAllDrivers () {
1034
+ WS_DEBUG_PRINTLN (" [i2c] Printing all drivers..." );
1035
+ for (drvBase *drv : _i2c_drivers) {
1036
+ drv->printSensorInfo ();
1037
+ }
1038
+ }
1039
+
937
1040
/* **********************************************************************/
938
1041
/* !
939
1042
@brief Handles polling, reading, and logger for i2c devices
0 commit comments