mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 14:12:05 +00:00
Merge branch 'master' into unify-tft
This commit is contained in:
commit
5f36da4374
@ -1,6 +1,6 @@
|
||||
version: 0.1
|
||||
cli:
|
||||
version: 1.22.15
|
||||
version: 1.24.0
|
||||
plugins:
|
||||
sources:
|
||||
- id: trunk
|
||||
@ -9,7 +9,7 @@ plugins:
|
||||
lint:
|
||||
enabled:
|
||||
- checkov@3.2.435
|
||||
- renovate@40.32.7
|
||||
- renovate@40.33.8
|
||||
- prettier@3.5.3
|
||||
- trufflehog@3.88.34
|
||||
- yamllint@1.37.1
|
||||
|
@ -161,6 +161,8 @@ lib_deps =
|
||||
sparkfun/SparkFun MAX3010x Pulse and Proximity Sensor Library@1.1.2
|
||||
# renovate: datasource=custom.pio depName=SparkFun 9DoF IMU Breakout ICM 20948 packageName=sparkfun/library/SparkFun 9DoF IMU Breakout - ICM 20948 - Arduino Library
|
||||
sparkfun/SparkFun 9DoF IMU Breakout - ICM 20948 - Arduino Library@1.3.2
|
||||
# renovate: datasource=custom.pio depName=Adafruit LTR390 Library packageName=adafruit/library/Adafruit LTR390 Library
|
||||
adafruit/Adafruit LTR390 Library@1.1.2
|
||||
# renovate: datasource=custom.pio depName=Adafruit PCT2075 packageName=adafruit/Adafruit PCT2075
|
||||
adafruit/Adafruit PCT2075@1.0.5
|
||||
|
||||
@ -190,4 +192,4 @@ lib_deps =
|
||||
# renovate: datasource=custom.pio depName=Bosch BME68x packageName=boschsensortec/library/BME68x Sensor Library
|
||||
boschsensortec/BME68x Sensor Library@1.3.40408
|
||||
# renovate: datasource=git-refs depName=meshtastic-DFRobot_LarkWeatherStation packageName=https://github.com/meshtastic/DFRobot_LarkWeatherStation gitBranch=master
|
||||
https://github.com/meshtastic/DFRobot_LarkWeatherStation/archive/4de3a9cadef0f6a5220a8a906cf9775b02b0040d.zip
|
||||
https://github.com/meshtastic/DFRobot_LarkWeatherStation/archive/4de3a9cadef0f6a5220a8a906cf9775b02b0040d.zip
|
@ -53,6 +53,13 @@ BMP280Sensor bmp280Sensor;
|
||||
NullSensor bme280Sensor;
|
||||
#endif
|
||||
|
||||
#if __has_include(<Adafruit_LTR390.h>)
|
||||
#include "Sensor/LTR390UVSensor.h"
|
||||
LTR390UVSensor ltr390uvSensor;
|
||||
#else
|
||||
NullSensor ltr390uvSensor;
|
||||
#endif
|
||||
|
||||
#if __has_include(<bsec2.h>)
|
||||
#include "Sensor/BME680Sensor.h"
|
||||
BME680Sensor bme680Sensor;
|
||||
@ -232,6 +239,8 @@ int32_t EnvironmentTelemetryModule::runOnce()
|
||||
#endif
|
||||
if (bme280Sensor.hasSensor())
|
||||
result = bme280Sensor.runOnce();
|
||||
if (ltr390uvSensor.hasSensor())
|
||||
result = ltr390uvSensor.runOnce();
|
||||
if (bmp3xxSensor.hasSensor())
|
||||
result = bmp3xxSensor.runOnce();
|
||||
if (bme680Sensor.hasSensor())
|
||||
@ -525,6 +534,10 @@ bool EnvironmentTelemetryModule::getEnvironmentTelemetry(meshtastic_Telemetry *m
|
||||
valid = valid && bme280Sensor.getMetrics(m);
|
||||
hasSensor = true;
|
||||
}
|
||||
if (ltr390uvSensor.hasSensor()) {
|
||||
valid = valid && ltr390uvSensor.getMetrics(m);
|
||||
hasSensor = true;
|
||||
}
|
||||
if (bmp3xxSensor.hasSensor()) {
|
||||
valid = valid && bmp3xxSensor.getMetrics(m);
|
||||
hasSensor = true;
|
||||
@ -753,6 +766,11 @@ AdminMessageHandleResult EnvironmentTelemetryModule::handleAdminMessageForModule
|
||||
if (result != AdminMessageHandleResult::NOT_HANDLED)
|
||||
return result;
|
||||
}
|
||||
if (ltr390uvSensor.hasSensor()) {
|
||||
result = ltr390uvSensor.handleAdminMessage(mp, request, response);
|
||||
if (result != AdminMessageHandleResult::NOT_HANDLED)
|
||||
return result;
|
||||
}
|
||||
if (bmp3xxSensor.hasSensor()) {
|
||||
result = bmp3xxSensor.handleAdminMessage(mp, request, response);
|
||||
if (result != AdminMessageHandleResult::NOT_HANDLED)
|
||||
|
73
src/modules/Telemetry/Sensor/LTR390UVSensor.cpp
Normal file
73
src/modules/Telemetry/Sensor/LTR390UVSensor.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
#include "configuration.h"
|
||||
|
||||
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include(<Adafruit_LTR390.h>)
|
||||
|
||||
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
||||
#include "LTR390UVSensor.h"
|
||||
#include "TelemetrySensor.h"
|
||||
#include <Adafruit_LTR390.h>
|
||||
|
||||
LTR390UVSensor::LTR390UVSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_LTR390UV, "LTR390UV") {}
|
||||
|
||||
int32_t LTR390UVSensor::runOnce()
|
||||
{
|
||||
LOG_INFO("Init sensor: %s", sensorName);
|
||||
if (!hasSensor()) {
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
|
||||
status = ltr390uv.begin(nodeTelemetrySensorsMap[sensorType].second);
|
||||
ltr390uv.setMode(LTR390_MODE_UVS);
|
||||
ltr390uv.setGain(LTR390_GAIN_18); // Datasheet default
|
||||
ltr390uv.setResolution(LTR390_RESOLUTION_20BIT); // Datasheet default
|
||||
|
||||
return initI2CSensor();
|
||||
}
|
||||
|
||||
void LTR390UVSensor::setup() {}
|
||||
|
||||
bool LTR390UVSensor::getMetrics(meshtastic_Telemetry *measurement)
|
||||
{
|
||||
LOG_DEBUG("LTR390UV getMetrics");
|
||||
|
||||
// Because the sensor does not measure Lux and UV at the same time, we need to read them in two passes.
|
||||
if (ltr390uv.newDataAvailable()) {
|
||||
measurement->variant.environment_metrics.has_lux = true;
|
||||
measurement->variant.environment_metrics.has_uv_lux = true;
|
||||
|
||||
if (ltr390uv.getMode() == LTR390_MODE_ALS) {
|
||||
lastLuxReading = 0.6 * ltr390uv.readALS() / (1 * 4); // Datasheet page 23 for gain x1 and 20bit resolution
|
||||
LOG_DEBUG("LTR390UV Lux reading: %f", lastLuxReading);
|
||||
|
||||
measurement->variant.environment_metrics.lux = lastLuxReading;
|
||||
measurement->variant.environment_metrics.uv_lux = lastUVReading;
|
||||
|
||||
ltr390uv.setGain(
|
||||
LTR390_GAIN_18); // Recommended for UVI - x18. Do not change, 2300 UV Sensitivity only specified for x18 gain
|
||||
ltr390uv.setMode(LTR390_MODE_UVS);
|
||||
|
||||
return true;
|
||||
|
||||
} else if (ltr390uv.getMode() == LTR390_MODE_UVS) {
|
||||
lastUVReading = ltr390uv.readUVS() /
|
||||
2300.f; // Datasheet page 23 and page 6, only characterisation for gain x18 and 20bit resolution
|
||||
LOG_DEBUG("LTR390UV UV reading: %f", lastUVReading);
|
||||
|
||||
measurement->variant.environment_metrics.lux = lastLuxReading;
|
||||
measurement->variant.environment_metrics.uv_lux = lastUVReading;
|
||||
|
||||
ltr390uv.setGain(
|
||||
LTR390_GAIN_1); // x1 gain will already max out the sensor at direct sunlight, so no need to increase it
|
||||
ltr390uv.setMode(LTR390_MODE_ALS);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// In case we fail to read the sensor mode, set the has_lux and has_uv_lux back to false
|
||||
measurement->variant.environment_metrics.has_lux = false;
|
||||
measurement->variant.environment_metrics.has_uv_lux = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
25
src/modules/Telemetry/Sensor/LTR390UVSensor.h
Normal file
25
src/modules/Telemetry/Sensor/LTR390UVSensor.h
Normal file
@ -0,0 +1,25 @@
|
||||
#include "configuration.h"
|
||||
|
||||
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include(<Adafruit_LTR390.h>)
|
||||
|
||||
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
||||
#include "TelemetrySensor.h"
|
||||
#include <Adafruit_LTR390.h>
|
||||
|
||||
class LTR390UVSensor : public TelemetrySensor
|
||||
{
|
||||
private:
|
||||
Adafruit_LTR390 ltr390uv = Adafruit_LTR390();
|
||||
float lastLuxReading = 0;
|
||||
float lastUVReading = 0;
|
||||
|
||||
protected:
|
||||
virtual void setup() override;
|
||||
|
||||
public:
|
||||
LTR390UVSensor();
|
||||
virtual int32_t runOnce() override;
|
||||
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user