Commit 02d06b8f authored by Astro's avatar Astro
Browse files

add card10::leds

parent c12f426a
#[link(name = "card10")]
extern {
fn leds_init();
fn leds_update();
fn leds_set_dim(led: u8,dim: u8);
fn leds_set(led: u8,r: u8,g: u8,b: u8);
fn leds_set_hsv(led: u8, h: f32, s: f32, v: f32);
}
pub const LEDS: u8 = 15;
pub fn init() {
unsafe { leds_init(); }
}
pub fn update() {
unsafe { leds_update(); }
}
pub fn set_dim(led: u8,dim: u8) {
unsafe { leds_set_dim(led, dim); }
}
pub fn set(led: u8,r: u8,g: u8,b: u8) {
unsafe { leds_set(led, r, g, b); }
}
pub fn set_hsv(led: u8, h: f32, s: f32, v: f32) {
unsafe { leds_set_hsv(led, h, s, v); }
}
......@@ -5,6 +5,7 @@ pub use cortex_m_rt as _;
pub use cortex_m_rt::entry;
pub mod lcd;
pub mod leds;
#[link(name = "card10")]
extern {
......
......@@ -2,12 +2,13 @@
#![no_main]
use panic_abort as _;
use card10::{entry, lcd};
use card10::{entry, lcd, leds};
#[entry]
fn main() -> ! {
card10::init();
leds::init();
lcd::set_backlight(1000);
let mut t = 0;
......@@ -23,6 +24,11 @@ fn main() -> ! {
}
lcd::update();
for led in 0..leds::LEDS {
leds::set(led, ((t << 2) & 0xFF) as u8, ((t << 1) & 0xFF) as u8, ((t >> 2) & 0xFF) as u8);
}
leds::update();
t += 1;
}
}
Supports Markdown
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