July 4 pattern test, buffering for less glitching
This commit is contained in:
parent
2aab355fff
commit
e06017e7c3
1 changed files with 45 additions and 0 deletions
45
hello_gradient/src/bin/july4.rs
Normal file
45
hello_gradient/src/bin/july4.rs
Normal file
|
@ -0,0 +1,45 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use core::iter::repeat;
|
||||
use lights::{
|
||||
gamma::GammaCorrector,
|
||||
PixelIterator,
|
||||
rgb::{
|
||||
Rgb
|
||||
}
|
||||
};
|
||||
use lights_hal::{boot, delay, entry};
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
let mut lights = GammaCorrector(boot());
|
||||
|
||||
let pattern =
|
||||
repeat(&Rgb(255,0,0)).take(5)
|
||||
.chain(
|
||||
repeat(&Rgb(255,255,255)).take(5)
|
||||
).cycle().take(60)
|
||||
.chain(
|
||||
repeat(&Rgb(255,0,0)).take(5)
|
||||
)
|
||||
.chain(
|
||||
[
|
||||
Rgb(0,0,255),
|
||||
Rgb(255,255,255),
|
||||
Rgb(0,0,255),
|
||||
].iter().cycle().take(85)
|
||||
);
|
||||
|
||||
let mut buffer = [Rgb(255,0,255); 150];
|
||||
loop {
|
||||
for (i, pixel) in pattern.clone().take(150).enumerate() {
|
||||
buffer[i] = *pixel;
|
||||
}
|
||||
|
||||
buffer.iter().render_to(&mut lights);
|
||||
|
||||
//pattern.next();
|
||||
delay(1_000_000);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue