holiday_lights/hello_gradient/src/main.rs

47 lines
1.0 KiB
Rust

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