Commit 3eee1dd5 authored by Astro's avatar Astro

Merge branch 'leds' into 'master'

leds: add support for the rocket LEDs

See merge request !21
parents 673ef495 e51772d7
Pipeline #4013 failed with stage
in 13 minutes and 58 seconds
...@@ -30,3 +30,26 @@ where ...@@ -30,3 +30,26 @@ where
} }
} }
} }
/// Set powersave mode for the RGB leds
///
/// Setting powersave mode disables the LEDs, saving
/// ~15 mA
pub fn set_rgb_leds_powersave(v: bool) {
unsafe { epic_leds_set_powersave(v); }
}
#[repr(i32)]
pub enum Rocket {
Blue = 0,
Yellow = 1,
Green = 2,
}
/// Set one of the rocket LEDs to the desired brightness.
///
/// Brightness should be 0 - 31; larger values will be clamped.
pub fn set_rocket(r: Rocket, brightness: u8) {
let v = if brightness > 31{31} else {brightness}; // clamp
unsafe { epic_leds_set_rocket(r as i32, v) }
}
...@@ -25,6 +25,10 @@ fn run() -> Result<(), Error> { ...@@ -25,6 +25,10 @@ fn run() -> Result<(), Error> {
let g = BHI160::<Gyroscope>::start()?; let g = BHI160::<Gyroscope>::start()?;
let o = BHI160::<Orientation>::start()?; let o = BHI160::<Orientation>::start()?;
set_rocket(Rocket::Blue, 20);
set_rocket(Rocket::Yellow, 20);
set_rocket(Rocket::Green, 10);
let display = Display::open(); let display = Display::open();
let light = LightSensor::start(); let light = LightSensor::start();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment