Fix glitch from wrapping.

This commit is contained in:
Tangent 128 2019-03-16 00:26:42 -04:00
parent c13a77d3d1
commit 491109885d

View file

@ -1,7 +1,6 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
use core::num::Wrapping;
use lights::{ use lights::{
gamma::GammaCorrector, gamma::GammaCorrector,
PixelIterator, PixelIterator,
@ -17,17 +16,13 @@ use lights_hal::{boot, delay, entry};
fn main() -> ! { fn main() -> ! {
let mut lights = GammaCorrector(boot()); let mut lights = GammaCorrector(boot());
let mut t = Wrapping(0u8);
loop {
t += Wrapping(1);
let red = Rgb(150, 0, 0); let red = Rgb(150, 0, 0);
let yellow = Rgb(150, 150, 0); let yellow = Rgb(150, 150, 0);
let green = Rgb(0, 150, 0); let green = Rgb(0, 150, 0);
let teal = Rgb(0, 75, 150); let teal = Rgb(0, 75, 150);
let purple = Rgb(75, 0, 150); let purple = Rgb(75, 0, 150);
(0..16u8).map( let mut gradient = (0..16u8).map(
|x| blend(red, yellow, gray(x * 16)) |x| blend(red, yellow, gray(x * 16))
).chain((0..16u8).map( ).chain((0..16u8).map(
|x| blend(yellow, green, gray(x * 16)) |x| blend(yellow, green, gray(x * 16))
@ -37,10 +32,12 @@ fn main() -> ! {
|x| blend(teal, purple, gray(x * 16)) |x| blend(teal, purple, gray(x * 16))
)).chain((0..16u8).map( )).chain((0..16u8).map(
|x| blend(purple, red, gray(x * 16)) |x| blend(purple, red, gray(x * 16))
)) )).cycle();
.cycle().skip(t.0 as usize).take(20)
.render_to(&mut lights);
loop {
gradient.clone().take(20).render_to(&mut lights);
gradient.next();
delay(1_000_000); delay(1_000_000);
} }
} }