holiday_lights/hello_gradient/src/main.rs

33 lines
604 B
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 red = Wrapping(0u8);
loop {
red += Wrapping(1);
let start = Rgb(red.0, 0, 0);
let end = Rgb(0, 100, 100u8.saturating_sub(red.0));
(0..20u8).map(
|x| blend(start, end, gray(x.saturating_mul(15)))
).render_to(&mut lights);
delay(500_000);
}
}