Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Allow white value of addressable lights to be controlled independently of brightness #529

Merged
merged 1 commit into from
Feb 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/esphome/light/addressable_light.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ uint8_t ESPColorCorrection::color_correct_blue(uint8_t blue) const {
}

uint8_t ESPColorCorrection::color_correct_white(uint8_t white) const {
uint8_t res = esp_scale8(esp_scale8(white, this->max_brightness_.white), this->local_brightness_);
// do not scale white value with brightness
uint8_t res = esp_scale8(white, this->max_brightness_.white);
return this->gamma_table_[res];
}

Expand Down Expand Up @@ -299,10 +300,10 @@ uint8_t ESPColorCorrection::color_uncorrect_blue(uint8_t blue) const {
}

uint8_t ESPColorCorrection::color_uncorrect_white(uint8_t white) const {
if (this->max_brightness_.white == 0 || this->local_brightness_ == 0)
if (this->max_brightness_.white == 0)
return 0;
uint16_t uncorrected = this->gamma_reverse_table_[white] * 255UL;
uint8_t res = ((uncorrected / this->max_brightness_.white) * 255UL) / this->local_brightness_;
uint8_t res = uncorrected / this->max_brightness_.white;
return res;
}

Expand Down