Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
Classes | Enumerations | Functions | Variables
sbl::components::display Namespace Reference

Display output components. More...

Classes

struct  Rgb
 Simple 8-bit RGB color triple. Aggregate — constexpr constructible. More...
 
class  RgbLed
 RGB LED state holder with 8-bit per-channel duty cycle. More...
 
struct  RgbLedState
 

Enumerations

enum class  Color : uint8_t {
  Off = 0 , Blue = 1 , Green = 2 , Cyan = 3 ,
  Red = 4 , Magenta = 5 , Yellow = 6 , White = 7
}
 3-bit color enum — all 8 RGB combinations More...
 

Functions

Rgb gamma_correct (const Rgb &c)
 Apply gamma correction to an RGB color.
 
Rgb rgb_lerp (const Rgb &a, const Rgb &b, uint8_t t)
 Linear interpolation between two colors. t=0 → a, t=255 → b.
 
Rgb rgb_scale (const Rgb &c, uint8_t brightness)
 Scale a color by brightness (0-255). 255 = full, 128 ≈ half, 0 = off.
 
Rgb gradient (const Rgb *stops, uint8_t n_stops, uint16_t position)
 Evaluate a multi-stop color gradient at a position.
 

Variables

constexpr uint8_t GAMMA8 [256]
 

Detailed Description

Display output components.

Enumeration Type Documentation

◆ Color

enum class sbl::components::display::Color : uint8_t
strong

3-bit color enum — all 8 RGB combinations

Bit layout: [R:G:B] where bit 2=R, bit 1=G, bit 0=B. Maps to full brightness (255) per active channel.

Enumerator
Off 
Blue 
Green 
Cyan 
Red 
Magenta 
Yellow 
White 

Definition at line 34 of file rgb_led.hpp.

Function Documentation

◆ gamma_correct()

Rgb sbl::components::display::gamma_correct ( const Rgb c)
inline

Apply gamma correction to an RGB color.

Definition at line 60 of file color.hpp.

References sbl::components::display::Rgb::b, sbl::components::display::Rgb::g, GAMMA8, and sbl::components::display::Rgb::r.

◆ gradient()

Rgb sbl::components::display::gradient ( const Rgb stops,
uint8_t  n_stops,
uint16_t  position 
)
inline

Evaluate a multi-stop color gradient at a position.

Divides the 0-65535 range into (n_stops - 1) equal segments and interpolates between adjacent stops. Endpoints are exact.

Parameters
stopsArray of color stops (at least 2).
n_stopsNumber of stops (2-16).
positionPosition in gradient (0 = first stop, 65535 = last stop).

Example: constexpr Rgb stops[] = {{0,0,255}, {0,255,0}, {255,0,0}}; Rgb c = gradient(stops, 3, 32768); // midpoint → green

Definition at line 95 of file color.hpp.

References rgb_lerp().

Here is the call graph for this function:

◆ rgb_lerp()

Rgb sbl::components::display::rgb_lerp ( const Rgb a,
const Rgb b,
uint8_t  t 
)
inline

Linear interpolation between two colors. t=0 → a, t=255 → b.

Definition at line 65 of file color.hpp.

References sbl::components::display::Rgb::b, sbl::components::display::Rgb::g, and sbl::components::display::Rgb::r.

Referenced by gradient().

Here is the caller graph for this function:

◆ rgb_scale()

Rgb sbl::components::display::rgb_scale ( const Rgb c,
uint8_t  brightness 
)
inline

Scale a color by brightness (0-255). 255 = full, 128 ≈ half, 0 = off.

Definition at line 73 of file color.hpp.

References sbl::components::display::Rgb::b, sbl::components::display::Rgb::g, and sbl::components::display::Rgb::r.

Variable Documentation

◆ GAMMA8

constexpr uint8_t sbl::components::display::GAMMA8[256]
inlineconstexpr
Initial value:
= {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5,
5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114,
115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142,
144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255,
}

Gamma correction LUT (gamma 2.8). Maps perceived-linear 0-255 to PWM duty. Without correction, PWM 128 appears ~78% as bright as 255 (not 50%).

Definition at line 40 of file color.hpp.

Referenced by gamma_correct().