From f051321c81d5f49f516a1a2ff0679bc042dd7db8 Mon Sep 17 00:00:00 2001 From: Fisch Date: Sat, 26 Dec 2020 12:40:53 +0100 Subject: [PATCH] do not use tcs values if saturated --- src/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index dda796b..21ce707 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -896,7 +896,10 @@ void loop_TCS34725_lux() } } //value_tcs_lux = tcs.calculateLux(value_tcs_r, value_tcs_g, value_tcs_b); - value_tcs_lux = tcs.lux*TCS34725_LUXFACTOR; + uint16_t _value_tcs_lux = tcs.lux*TCS34725_LUXFACTOR; + if (!tcs.isSaturated){ //sometimes false high reading accur around 65535 sometimes less. + value_tcs_lux = _value_tcs_lux; + } if (abs((int)d.lastsentvalue-value_tcs_lux)>=d.minchange){ //int abs _changed=true; @@ -937,7 +940,10 @@ void loop_TCS34725_colortemp() } // colorTemp = tcs.calculateColorTemperature(r, g, b); //value_colortemp = tcs.calculateColorTemperature_dn40(value_tcs_r, value_tcs_g, value_tcs_b, value_tcs_c); - value_colortemp = tcs.ct; //with agc + if (!tcs.isSaturated){ + value_colortemp = tcs.ct; //with agc + } + if (abs((int)d.lastsentvalue-value_colortemp)>=d.minchange){ //int abs