Make Mardi Gras code use Harrogate helper

This commit is contained in:
Tangent 128 2019-11-06 19:49:08 -05:00
parent 1ad2db3960
commit 6cf0ea27e9

View file

@ -1,19 +1,17 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
use lights::{ use core::iter::repeat;
gamma::correct, use house::Harrogate;
rgb::{linear_gradient, Rgb}, use lights::rgb::{linear_gradient, Rgb};
HardwareRgb, PixelIterator,
};
use lights_hal::{boot, delay, entry}; use lights_hal::{boot, delay, entry};
const OFF: Rgb = Rgb(0, 0, 0);
const YELLOW: Rgb = Rgb(255, 255, 0); const YELLOW: Rgb = Rgb(255, 255, 0);
const GREEN: Rgb = Rgb(100, 255, 0); const GREEN: Rgb = Rgb(100, 255, 0);
const PURPLE: Rgb = Rgb(196, 0, 255); const PURPLE: Rgb = Rgb(196, 0, 255);
const SEGMENT_LEN: usize = 50; const SEGMENT_LEN: usize = 50;
const BUFFER_LEN: usize = 300;
#[entry] #[entry]
fn main() -> ! { fn main() -> ! {
@ -25,16 +23,14 @@ fn main() -> ! {
.chain(linear_gradient(PURPLE, YELLOW, SEGMENT_LEN)) .chain(linear_gradient(PURPLE, YELLOW, SEGMENT_LEN))
.cycle(); .cycle();
let mut buffer = [HardwareRgb(255, 255, 0); BUFFER_LEN];
loop { loop {
// blink light to demonstrate loop is still running // blink light to demonstrate loop is still running
lights.heartbeat(); lights.heartbeat();
for (i, pixel) in gradient.clone().take(BUFFER_LEN).enumerate() { Harrogate {
buffer[i] = correct(&pixel); porch_back: gradient.clone(),
} porch_front: repeat(OFF),
}.render_to(&mut lights);
buffer.iter().render_to(&mut lights);
gradient.next(); gradient.next();
delay(500_000); delay(500_000);