Make a basic front-back color Halloween display

This commit is contained in:
Tangent 128 2019-10-27 01:49:03 -04:00
parent a6bacb391b
commit 0687f2086a

View 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);
}
}