Add get/set color temperature functions in Kelvin (#5006)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Daniel Kent 2024-04-24 00:18:54 -04:00 committed by GitHub
parent 1775c73e53
commit 41b19504bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -266,6 +266,21 @@ class LightColorValues {
/// Set the color temperature property of these light color values in mired. /// Set the color temperature property of these light color values in mired.
void set_color_temperature(float color_temperature) { this->color_temperature_ = color_temperature; } void set_color_temperature(float color_temperature) { this->color_temperature_ = color_temperature; }
/// Get the color temperature property of these light color values in kelvin.
float get_color_temperature_kelvin() const {
if (this->color_temperature_ <= 0) {
return this->color_temperature_;
}
return 1000000.0 / this->color_temperature_;
}
/// Set the color temperature property of these light color values in kelvin.
void set_color_temperature_kelvin(float color_temperature) {
if (color_temperature <= 0) {
return;
}
this->color_temperature_ = 1000000.0 / color_temperature;
}
/// Get the cold white property of these light color values. In range 0.0 to 1.0. /// Get the cold white property of these light color values. In range 0.0 to 1.0.
float get_cold_white() const { return this->cold_white_; } float get_cold_white() const { return this->cold_white_; }
/// Set the cold white property of these light color values. In range 0.0 to 1.0. /// Set the cold white property of these light color values. In range 0.0 to 1.0.