mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-09 14:42:05 +00:00
fix variable scope and getMetrics returns
This commit is contained in:
parent
7ec187791d
commit
fbfc80c55e
@ -28,13 +28,13 @@ void LTR390UVSensor::setup() {}
|
||||
|
||||
bool LTR390UVSensor::getMetrics(meshtastic_Telemetry *measurement)
|
||||
{
|
||||
measurement->variant.environment_metrics.has_lux = true;
|
||||
measurement->variant.environment_metrics.has_uv_lux = true;
|
||||
|
||||
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);
|
||||
@ -45,6 +45,9 @@ bool LTR390UVSensor::getMetrics(meshtastic_Telemetry *measurement)
|
||||
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
|
||||
@ -56,9 +59,11 @@ bool LTR390UVSensor::getMetrics(meshtastic_Telemetry *measurement)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user