| 394 | /// Convert hue (0-359) to RGB color (full saturation, full value) |
| 395 | #[cfg(feature = "addressable-leds")] |
| 396 | fn 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] |
| 414 | fn main() -> ! { |