Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3bb927e
rework I2C sensor init
Links2004 Sep 21, 2025
5e7cb4c
add missing ifdef
Links2004 Sep 21, 2025
48a07d9
Merge branch 'develop' into save_memory_bme680
Links2004 Sep 26, 2025
113ce64
refactor a bunch of more sensors
Links2004 Sep 26, 2025
4844c81
fix build for t1000
Links2004 Sep 26, 2025
a673b76
refactor more sensors
Links2004 Sep 27, 2025
2bf6b1f
improve error handling
Links2004 Sep 27, 2025
2d55000
fix build
Links2004 Sep 27, 2025
5e85a14
fix build
Links2004 Sep 27, 2025
1ab1e1d
Merge branch 'develop' into save_memory_bme680
Links2004 Sep 27, 2025
d1faa83
fix IndicatorSensor
Links2004 Sep 27, 2025
3fa84eb
fix tracker-t1000-e build
Links2004 Sep 27, 2025
f08931b
Merge branch 'develop' into save_memory_bme680
thebentern Oct 2, 2025
de4ccf6
Merge branch 'develop' into save_memory_bme680
Links2004 Oct 12, 2025
dd788e2
Merge branch 'develop' into save_memory_bme680
thebentern Oct 12, 2025
9647e3f
Merge branch 'develop' into save_memory_bme680
thebentern Oct 12, 2025
c22e304
Merge branch 'develop' into save_memory_bme680
thebentern Oct 12, 2025
5f65ec6
Apply suggestion from @Copilot
thebentern Oct 12, 2025
a94f867
Apply suggestion from @Copilot
thebentern Oct 12, 2025
45d767c
Apply suggestion from @Copilot
thebentern Oct 12, 2025
012c6e9
Update src/modules/Telemetry/Sensor/DFRobotGravitySensor.h
thebentern Oct 12, 2025
a02dba8
Fix
thebentern Oct 13, 2025
8f3f7b5
Merge branch 'develop' into save_memory_bme680
thebentern Oct 13, 2025
0d11bcc
Merge branch 'develop' into save_memory_bme680
thebentern Oct 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/detect/ScanI2CConsumer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "ScanI2CConsumer.h"
#include <forward_list>

static std::forward_list<ScanI2CConsumer *> ScanI2CConsumers;

ScanI2CConsumer::ScanI2CConsumer()
{
ScanI2CConsumers.push_front(this);
}

void ScanI2CCompleted(ScanI2C *i2cScanner)
{
for (ScanI2CConsumer *consumer : ScanI2CConsumers) {
consumer->i2cScanFinished(i2cScanner);
}
}
13 changes: 13 additions & 0 deletions src/detect/ScanI2CConsumer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include "ScanI2C.h"
#include <stddef.h>

class ScanI2CConsumer
{
public:
ScanI2CConsumer();
virtual void i2cScanFinished(ScanI2C *i2cScanner) = 0;
};

void ScanI2CCompleted(ScanI2C *i2cScanner);
2 changes: 1 addition & 1 deletion src/detect/ScanI2CTwoWire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port)
scanPort(port, nullptr, 0);
}

TwoWire *ScanI2CTwoWire::fetchI2CBus(ScanI2C::DeviceAddress address) const
TwoWire *ScanI2CTwoWire::fetchI2CBus(ScanI2C::DeviceAddress address)
{
if (address.port == ScanI2C::I2CPort::WIRE) {
return &Wire;
Expand Down
4 changes: 2 additions & 2 deletions src/detect/ScanI2CTwoWire.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class ScanI2CTwoWire : public ScanI2C

ScanI2C::FoundDevice find(ScanI2C::DeviceType) const override;

TwoWire *fetchI2CBus(ScanI2C::DeviceAddress) const;

bool exists(ScanI2C::DeviceType) const override;

size_t countDevices() const override;

static TwoWire *fetchI2CBus(ScanI2C::DeviceAddress);

protected:
FoundDevice firstOfOrNONE(size_t, DeviceType[]) const override;

Expand Down
32 changes: 7 additions & 25 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "power.h"

#if !MESHTASTIC_EXCLUDE_I2C
#include "detect/ScanI2CConsumer.h"
#include "detect/ScanI2CTwoWire.h"
#include <Wire.h>
#endif
Expand Down Expand Up @@ -718,46 +719,21 @@ void setup()
LOG_DEBUG("acc_info = %i", acc_info.type);
#endif

scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BME_680, meshtastic_TelemetrySensorType_BME680);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BME_280, meshtastic_TelemetrySensorType_BME280);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BMP_280, meshtastic_TelemetrySensorType_BMP280);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BMP_3XX, meshtastic_TelemetrySensorType_BMP3XX);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BMP_085, meshtastic_TelemetrySensorType_BMP085);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA260, meshtastic_TelemetrySensorType_INA260);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA226, meshtastic_TelemetrySensorType_INA226);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA219, meshtastic_TelemetrySensorType_INA219);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA3221, meshtastic_TelemetrySensorType_INA3221);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MAX17048, meshtastic_TelemetrySensorType_MAX17048);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MCP9808, meshtastic_TelemetrySensorType_MCP9808);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SHT31, meshtastic_TelemetrySensorType_SHT31);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SHTC3, meshtastic_TelemetrySensorType_SHTC3);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::LPS22HB, meshtastic_TelemetrySensorType_LPS22);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::QMC6310, meshtastic_TelemetrySensorType_QMC6310);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::QMI8658, meshtastic_TelemetrySensorType_QMI8658);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::QMC5883L, meshtastic_TelemetrySensorType_QMC5883L);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::HMC5883L, meshtastic_TelemetrySensorType_QMC5883L);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::PMSA0031, meshtastic_TelemetrySensorType_PMSA003I);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::RCWL9620, meshtastic_TelemetrySensorType_RCWL9620);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::VEML7700, meshtastic_TelemetrySensorType_VEML7700);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::TSL2591, meshtastic_TelemetrySensorType_TSL25911FN);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::OPT3001, meshtastic_TelemetrySensorType_OPT3001);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MLX90632, meshtastic_TelemetrySensorType_MLX90632);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MLX90614, meshtastic_TelemetrySensorType_MLX90614);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SHT4X, meshtastic_TelemetrySensorType_SHT4X);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::AHT10, meshtastic_TelemetrySensorType_AHT10);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::DFROBOT_LARK, meshtastic_TelemetrySensorType_DFROBOT_LARK);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::ICM20948, meshtastic_TelemetrySensorType_ICM20948);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MAX30102, meshtastic_TelemetrySensorType_MAX30102);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::CGRADSENS, meshtastic_TelemetrySensorType_RADSENS);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::DFROBOT_RAIN, meshtastic_TelemetrySensorType_DFROBOT_RAIN);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::LTR390UV, meshtastic_TelemetrySensorType_LTR390UV);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::DPS310, meshtastic_TelemetrySensorType_DPS310);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::RAK12035, meshtastic_TelemetrySensorType_RAK12035);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::PCT2075, meshtastic_TelemetrySensorType_PCT2075);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SCD4X, meshtastic_TelemetrySensorType_SCD4X);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::TSL2561, meshtastic_TelemetrySensorType_TSL2561);

i2cScanner.reset();
#endif

#ifdef HAS_SDCARD
Expand Down Expand Up @@ -964,6 +940,12 @@ void setup()
// Now that the mesh service is created, create any modules
setupModules();

#if !MESHTASTIC_EXCLUDE_I2C
// Inform modules about I2C devices
ScanI2CCompleted(i2cScanner.get());
i2cScanner.reset();
#endif

// warn the user about a low entropy key
if (nodeDB->keyIsLowEntropy && !nodeDB->hasWarned) {
LOG_WARN(LOW_ENTROPY_WARNING);
Expand Down
Loading