smartledz-protocol
Smart LEDZ protocol v1 command and state codec library
Loading...
Searching...
No Matches
color_math.h File Reference

Color-temperature and RGB conversion helpers for Smart LEDZ v1. More...

#include <array>
#include <cstdint>
Include dependency graph for color_math.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::array< uint8_t, 3 > smartledz_protocol::v1::lookup_ct_rgb (uint16_t kelvin, float duv)
 Converts correlated color temperature and Duv into RGB.
 
uint16_t smartledz_protocol::v1::estimate_cct_from_rgb (uint8_t target_red, uint8_t target_green, uint8_t target_blue, float duv)
 Estimates correlated color temperature from an RGB sample.
 

Detailed Description

Color-temperature and RGB conversion helpers for Smart LEDZ v1.

Function Documentation

◆ estimate_cct_from_rgb()

uint16_t smartledz_protocol::v1::estimate_cct_from_rgb ( uint8_t  target_red,
uint8_t  target_green,
uint8_t  target_blue,
float  duv 
)

Estimates correlated color temperature from an RGB sample.

Parameters
target_redRed channel of the target sample.
target_greenGreen channel of the target sample.
target_blueBlue channel of the target sample.
duvDuv offset used by the fitted model.
Returns
Estimated kelvin value in the modeled range.
Note
Uses coarse (100K) then fine (1K) search over [1800, 12000].

◆ lookup_ct_rgb()

std::array< uint8_t, 3 > smartledz_protocol::v1::lookup_ct_rgb ( uint16_t  kelvin,
float  duv 
)

Converts correlated color temperature and Duv into RGB.

Parameters
kelvinCorrelated color temperature in kelvin.
duvDuv offset used by the fitted model.
Returns
RGB tuple in 8-bit channels.
Note
kelvin is clamped to [1800, 12000] and duv to [-6.0, 6.0].