MCPcopy Create free account
hub / github.com/ecto/muni / hue_to_rgb

Function hue_to_rgb

mcu/bins/esp32s3/src/main.rs:396–411  ·  view source on GitHub ↗
(hue: u16)

Source from the content-addressed store, hash-verified

394/// Convert hue (0-359) to RGB color (full saturation, full value)
395#[cfg(feature = "addressable-leds")]
396fn hue_to_rgb(hue: u16) -> RGB8 {
397 let h = hue % 360;
398 let sector = h / 60;
399 let offset = (h % 60) as u8;
400 let rising = (offset as u16 * 255 / 60) as u8;
401 let falling = 255 - rising;
402
403 match sector {
404 0 => RGB8::new(255, rising, 0), // Red -> Yellow
405 1 => RGB8::new(falling, 255, 0), // Yellow -> Green
406 2 => RGB8::new(0, 255, rising), // Green -> Cyan
407 3 => RGB8::new(0, falling, 255), // Cyan -> Blue
408 4 => RGB8::new(rising, 0, 255), // Blue -> Magenta
409 _ => RGB8::new(255, 0, falling), // Magenta -> Red
410 }
411}
412
413#[main]
414fn main() -> ! {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected