Make a basic front-back color Halloween display
This commit is contained in:
parent
a6bacb391b
commit
0687f2086a
1 changed files with 45 additions and 0 deletions
45
hello_gradient/src/bin/halloween2019.rs
Normal file
45
hello_gradient/src/bin/halloween2019.rs
Normal file
|
@ -0,0 +1,45 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use core::iter::repeat;
|
||||
use lights::{
|
||||
gamma::correct,
|
||||
HardwareRgb,
|
||||
PixelIterator,
|
||||
rgb::{
|
||||
Rgb
|
||||
}
|
||||
};
|
||||
use lights_hal::{boot, delay, entry, OutputPin};
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
let mut lights = boot();
|
||||
lights.red_led.set_high().unwrap();
|
||||
|
||||
let pattern =
|
||||
repeat(&Rgb(255,0,128)).take(150)
|
||||
.chain(
|
||||
repeat(&Rgb(255,128,0)).take(150)
|
||||
).cycle();
|
||||
|
||||
let mut buffer = [HardwareRgb(255,255,0); 200];
|
||||
let mut light = false;
|
||||
loop {
|
||||
// blink light to demonstrate loop is still running
|
||||
if light {
|
||||
lights.red_led.set_high().unwrap();
|
||||
} else {
|
||||
lights.red_led.set_low().unwrap();
|
||||
}
|
||||
light = !light;
|
||||
|
||||
for (i, pixel) in pattern.clone().take(200).enumerate() {
|
||||
buffer[i] = correct(pixel);
|
||||
}
|
||||
|
||||
buffer.iter().render_to(&mut lights);
|
||||
|
||||
delay(12_000_000);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue