mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 09:18:00 +01:00
tcs34725: adjust max lux limit according to glass attenuation factor
- revert quick fix of increasing max lux from 100,000 to 200,000 in PR#7508
This commit is contained in:
parent
b503e8a08d
commit
e76eb3cb1a
1 changed files with 6 additions and 4 deletions
|
@ -115,7 +115,7 @@ void TCS34725Component::calculate_temperature_and_lux_(uint16_t r, uint16_t g, u
|
|||
static const float B_COEF = -0.444f; //
|
||||
static const float CT_COEF = 3810.f; // Color Temperature Coefficient
|
||||
static const float CT_OFFSET = 1391.f; // Color Temperatuer Offset
|
||||
static const float MAX_ILLUMINANCE = 200000.0f; // Cap illuminance at 200,000 lux
|
||||
static const float MAX_ILLUMINANCE = 100000.0f; // Cap illuminance at 100,000 lux
|
||||
static const float MAX_COLOR_TEMPERATURE = 15000.0f; // Maximum expected color temperature in Kelvin
|
||||
static const float MIN_COLOR_TEMPERATURE = 1000.0f; // Maximum reasonable color temperature in Kelvin
|
||||
|
||||
|
@ -184,9 +184,11 @@ void TCS34725Component::calculate_temperature_and_lux_(uint16_t r, uint16_t g, u
|
|||
this->illuminance_ = std::max(g1 / cpl, 0.0f);
|
||||
|
||||
if (this->illuminance_ > MAX_ILLUMINANCE) {
|
||||
ESP_LOGW(TAG, "Calculated illuminance greater than limit (%f), setting to NAN", this->illuminance_);
|
||||
this->illuminance_ = NAN;
|
||||
return;
|
||||
if (ga < 1.1f || this->illuminance_ > MAX_ILLUMINANCE * ga) {
|
||||
ESP_LOGW(TAG, "Calculated illuminance greater than limit (%f), setting to NAN", this->illuminance_);
|
||||
this->illuminance_ = NAN;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (r == 0) {
|
||||
|
|
Loading…
Reference in a new issue