From 9f7d9eda2524d0d89a370adca5fa47f1fe57d03d Mon Sep 17 00:00:00 2001 From: Hynek Texl Date: Fri, 17 Jan 2025 21:56:37 +0100 Subject: [PATCH] - Critical bug fixed in setLightSensorGain() which caused invalid Light sensor GAIN settings and light meter stops responding. - Next bug fixed in getProximity() return value must be 11bits. Encoding Of final value was incorrect. --- src/SensorLTR553.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SensorLTR553.hpp b/src/SensorLTR553.hpp index 58c465a..19b39d6 100644 --- a/src/SensorLTR553.hpp +++ b/src/SensorLTR553.hpp @@ -207,7 +207,7 @@ class SensorLTR553 : void setLightSensorGain(LightSensorGain gain) { - writeRegister(LTR553_REG_ALS_CONTR, 0xE3, gain); + writeRegister(LTR553_REG_ALS_CONTR, 0xE3, gain<<2); } int getLightSensor(uint8_t ch) @@ -275,7 +275,8 @@ class SensorLTR553 : if (saturated) { *saturated = buffer[1] & 0x80; } - return buffer[0] | (buffer[1] & 0x03); + int high = buffer[1] & 0x07; + return (high << 8) | buffer[0]; } void setPsLedPulsePeriod(PsLedPeriod period)