diff --git a/code/espurna/light.ino b/code/espurna/light.ino index 20ee7212..e40bbc99 100644 --- a/code/espurna/light.ino +++ b/code/espurna/light.ino @@ -59,13 +59,13 @@ unsigned char _light_brightness = Light::BRIGHTNESS_MAX; // Default to the Philips Hue value that HA also use. // https://developers.meethue.com/documentation/core-concepts -long _light_mireds_cold = LIGHT_COLDWHITE_MIRED; -long _light_mireds_warm = LIGHT_WARMWHITE_MIRED; +long _light_cold_mireds = LIGHT_COLDWHITE_MIRED; +long _light_warm_mireds = LIGHT_WARMWHITE_MIRED; -long _light_kelvin_cold = (1000000L / _light_mireds_cold); -long _light_kelvin_warm = (1000000L / _light_mireds_warm); +long _light_cold_kelvin = (1000000L / _light_cold_mireds); +long _light_warm_kelvin = (1000000L / _light_warm_mireds); -long _light_mireds = lround((_light_mireds_cold + _light_mireds_warm) / 2L); +long _light_mireds = lround((_light_cold_mireds + _light_warm_mireds) / 2L); using light_brightness_func_t = void(); light_brightness_func_t* _light_brightness_func = nullptr; @@ -163,7 +163,7 @@ void _lightApplyBrightnessColor() { if (_light_use_cct) { // This change the range from 153-500 to 0-347 so we get a value between 0 and 1 in the end. - double miredFactor = ((double) _light_mireds - (double) _light_mireds_cold)/((double) _light_mireds_warm - (double) _light_mireds_cold); + double miredFactor = ((double) _light_mireds - (double) _light_cold_mireds)/((double) _light_warm_mireds - (double) _light_cold_mireds); // set cold white _light_channel[3].inputValue = 0; @@ -329,11 +329,11 @@ void _fromHSV(const char * hsv) { // https://github.com/stelgenhof/AiLight // Color temperature is measured in mireds (kelvin = 1e6/mired) long _toKelvin(const long mireds) { - return constrain(static_cast(1000000L / mireds), _light_kelvin_warm, _light_kelvin_cold); + return constrain(static_cast(1000000L / mireds), _light_warm_kelvin, _light_cold_kelvin); } long _toMireds(const long kelvin) { - return constrain(static_cast(lround(1000000L / kelvin)), _light_mireds_cold, _light_mireds_warm); + return constrain(static_cast(lround(1000000L / kelvin)), _light_cold_mireds, _light_warm_mireds); } void _lightMireds(const long kelvin) { @@ -344,7 +344,7 @@ void _lightMiredsCCT(const long kelvin) { _lightMireds(kelvin); // This change the range from 153-500 to 0-347 so we get a value between 0 and 1 in the end. - const double factor = ((double) _light_mireds - (double) _light_mireds_cold)/((double) _light_mireds_warm - (double) _light_mireds_cold); + const double factor = ((double) _light_mireds - (double) _light_cold_mireds)/((double) _light_warm_mireds - (double) _light_cold_mireds); _setCCTInputValue( lround(factor * Light::VALUE_MAX), lround(((double) 1.0 - factor) * Light::VALUE_MAX) @@ -1014,8 +1014,8 @@ void _lightWebSocketStatus(JsonObject& root) { if (_light_use_cct) { JsonObject& mireds = root.createNestedObject("mireds"); mireds["value"] = _light_mireds; - mireds["cold"] = _light_mireds_cold; - mireds["warm"] = _light_mireds_warm; + mireds["cold"] = _light_cold_mireds; + mireds["warm"] = _light_warm_mireds; root["useCCT"] = _light_use_cct; } JsonArray& channels = root.createNestedArray("channels"); @@ -1283,10 +1283,10 @@ void _lightConfigure() { } if (_light_use_cct) { - _light_mireds_cold = getSetting("lightColdMired", LIGHT_COLDWHITE_MIRED).toInt(); - _light_mireds_warm = getSetting("lightWarmMired", LIGHT_WARMWHITE_MIRED).toInt(); - _light_kelvin_cold = (1000000L / _light_mireds_cold); - _light_kelvin_warm = (1000000L / _light_mireds_warm); + _light_cold_mireds = getSetting("lightColdMired", LIGHT_COLDWHITE_MIRED).toInt(); + _light_warm_mireds = getSetting("lightWarmMired", LIGHT_WARMWHITE_MIRED).toInt(); + _light_cold_kelvin = (1000000L / _light_cold_mireds); + _light_warm_kelvin = (1000000L / _light_warm_mireds); } _light_use_gamma = getSetting("useGamma", LIGHT_USE_GAMMA).toInt() == 1;