tcs34725: fix color/clear channel percentage calculations on long exposures (#7493)

This commit is contained in:
@RubenKelevra 2024-09-25 04:27:14 +02:00 committed by GitHub
parent fcce70d416
commit fa9df32979
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -211,7 +211,7 @@ void TCS34725Component::update() {
if (raw_c == 0) { if (raw_c == 0) {
channel_c = channel_r = channel_g = channel_b = 0.0f; channel_c = channel_r = channel_g = channel_b = 0.0f;
} else { } else {
float max_count = this->integration_time_ * 1024.0f / 2.4; float max_count = this->integration_time_ <= 153.6f ? this->integration_time_ * 1024.0f / 2.4f : 65535.0f;
float sum = raw_c; float sum = raw_c;
channel_r = raw_r / sum * 100.0f; channel_r = raw_r / sum * 100.0f;
channel_g = raw_g / sum * 100.0f; channel_g = raw_g / sum * 100.0f;