Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
color.hpp File Reference

RGB color types and utilities. More...

Detailed Description

RGB color types and utilities.

Pure math operations on 8-bit RGB colors. No hardware dependencies. Designed for LED feedback on embedded instruments - every function is ISR-safe and branchless where practical.

Rgb: Simple {r, g, b} aggregate. Layout-compatible with RgbLedState. GAMMA8[256]: Perceptual gamma correction LUT (gamma 2.8). gamma_correct(): Apply GAMMA8 to an Rgb color. rgb_lerp(): Linear interpolation between two colors. rgb_scale(): Scale a color by brightness (0-255). gradient(): Evaluate a multi-stop color gradient at a position.

Source: Gamma table from Adafruit LED Tricks guide (gamma 2.8).

Usage:

constexpr Rgb red{255, 0, 0};
Rgb dimmed = rgb_scale(red, 128); // half brightness
Rgb mixed = rgb_lerp(red, {0,0,255}, 128); // purple
Rgb out = gamma_correct(mixed); // perceptually correct PWM
Rgb gamma_correct(const Rgb &c)
Definition color.hpp:69

Definition in file color.hpp.

#include <cstdint>

Go to the source code of this file.

Classes

struct  sbl::control::display::Rgb
 

Namespaces

namespace  sbl
 Root namespace for all Sound Byte Libs code.
 
namespace  sbl::control
 The control stack: scheduler, event queue, merge, CC mapping, calibration.
 
namespace  sbl::control::display
 Indicators: RGB LED state and colors.
 

Functions

Rgb sbl::control::display::gamma_correct (const Rgb &c)
 
Rgb sbl::control::display::rgb_lerp (const Rgb &a, const Rgb &b, uint8_t t)
 
Rgb sbl::control::display::rgb_scale (const Rgb &c, uint8_t brightness)
 
Rgb sbl::control::display::gradient (const Rgb *stops, uint8_t n_stops, uint16_t position)
 Evaluate a multi-stop color gradient at a position.
 

Variables

constexpr uint8_t sbl::control::display::GAMMA8 [256]