mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 17:27:59 +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
59b9448b42
commit
d349a67364
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 B_COEF = -0.444f; //
|
||||||
static const float CT_COEF = 3810.f; // Color Temperature Coefficient
|
static const float CT_COEF = 3810.f; // Color Temperature Coefficient
|
||||||
static const float CT_OFFSET = 1391.f; // Color Temperatuer Offset
|
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 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
|
static const float MIN_COLOR_TEMPERATURE = 1000.0f; // Maximum reasonable color temperature in Kelvin
|
||||||
|
|
||||||
|
@ -184,10 +184,12 @@ void TCS34725Component::calculate_temperature_and_lux_(uint16_t r, uint16_t g, u
|
||||||
this->illuminance_ = std::max(g1 / cpl, 0.0f);
|
this->illuminance_ = std::max(g1 / cpl, 0.0f);
|
||||||
|
|
||||||
if (this->illuminance_ > MAX_ILLUMINANCE) {
|
if (this->illuminance_ > MAX_ILLUMINANCE) {
|
||||||
|
if (ga < 1.1f || this->illuminance_ > MAX_ILLUMINANCE * ga) {
|
||||||
ESP_LOGW(TAG, "Calculated illuminance greater than limit (%f), setting to NAN", this->illuminance_);
|
ESP_LOGW(TAG, "Calculated illuminance greater than limit (%f), setting to NAN", this->illuminance_);
|
||||||
this->illuminance_ = NAN;
|
this->illuminance_ = NAN;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
ESP_LOGW(TAG, "Red channel is zero, cannot compute color temperature");
|
ESP_LOGW(TAG, "Red channel is zero, cannot compute color temperature");
|
||||||
|
|
Loading…
Reference in a new issue