Add mardi_gras pattern

This commit is contained in:
Tangent 128 2019-10-28 00:03:49 -04:00
parent 67c94749f8
commit 5a741d870b
1 changed files with 42 additions and 0 deletions

View File

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