leds.rs 556 Bytes
Newer Older
Astro's avatar
Astro committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
use card10_sys::*;

#[derive(Clone, Copy)]
pub enum LEDColor {
    RGB(u8, u8, u8),
    HSV(f32, f32, f32),
}

pub fn update_rgb_leds<F>(f: F)
where
    F: Fn(i32) -> LEDColor,
{
    for index in 0..=10 {
        let color = f(index);
        match color {
            LEDColor::RGB(r, g, b) => unsafe {
                epic_leds_prep(index, r, g, b);
            }
            LEDColor::HSV(h, s, v) => unsafe {
                epic_leds_prep_hsv(index, h, s, v);
            }
        }
        unsafe {
            epic_leds_update();
        }
    }
}