ESPHome 2025.5.0
Loading...
Searching...
No Matches
esp_color_correction.cpp
Go to the documentation of this file.
3#include "esphome/core/log.h"
4
5namespace esphome {
6namespace light {
7
9 for (uint16_t i = 0; i < 256; i++) {
10 // corrected = val ^ gamma
11 auto corrected = to_uint8_scale(gamma_correct(i / 255.0f, gamma));
12 this->gamma_table_[i] = corrected;
13 }
14 if (gamma == 0.0f) {
15 for (uint16_t i = 0; i < 256; i++)
16 this->gamma_reverse_table_[i] = i;
17 return;
18 }
19 for (uint16_t i = 0; i < 256; i++) {
20 // val = corrected ^ (1/gamma)
21 auto uncorrected = to_uint8_scale(powf(i / 255.0f, 1.0f / gamma));
22 this->gamma_reverse_table_[i] = uncorrected;
23 }
24}
25
26} // namespace light
27} // namespace esphome
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
float gamma_correct(float value, float gamma)
Applies gamma correction of gamma to value.
Definition helpers.cpp:562