Start second light display
This commit is contained in:
parent
5059c5d0d1
commit
b6b53c4dbc
3 changed files with 66 additions and 0 deletions
|
@ -14,6 +14,7 @@ debug = true
|
||||||
replace-default = []
|
replace-default = []
|
||||||
|
|
||||||
december-01-2019 = ["replace-default"]
|
december-01-2019 = ["replace-default"]
|
||||||
|
december-21-2019 = ["replace-default"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
house = { path = "../house" }
|
house = { path = "../house" }
|
||||||
|
|
61
harrogate/src/december_21_2019.rs
Normal file
61
harrogate/src/december_21_2019.rs
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
//! Golden background with twinkling lights
|
||||||
|
use super::delay;
|
||||||
|
use house::Harrogate;
|
||||||
|
use lights::rgb::Rgb;
|
||||||
|
use lights::{HardwareRgb, Lights, murmurf};
|
||||||
|
|
||||||
|
const GOLD: Rgb = Rgb(200, 200, 0);
|
||||||
|
const RED: Rgb = Rgb(0, 200, 0);
|
||||||
|
const GREEN: Rgb = Rgb(0, 200, 0);
|
||||||
|
const BLUE: Rgb = Rgb(0, 0, 200);
|
||||||
|
const PURPLE: Rgb = Rgb(160, 0, 128);
|
||||||
|
const WHITE: Rgb = Rgb(255, 255, 255);
|
||||||
|
|
||||||
|
const FULL_PORCH: usize = 150;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
struct Pixel {
|
||||||
|
color: Rgb,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Pixel {
|
||||||
|
const fn new() -> Pixel {
|
||||||
|
Pixel {
|
||||||
|
color: GOLD
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tick(&mut self, mut rng: u32) {
|
||||||
|
self.color = match murmurf(&mut rng) % 8 {
|
||||||
|
0..=1 => RED,
|
||||||
|
2..=3 => GREEN,
|
||||||
|
4..=5 => BLUE,
|
||||||
|
6 => PURPLE,
|
||||||
|
7 => WHITE,
|
||||||
|
_ => GOLD,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn run(lights: &mut impl Lights<Pixel = HardwareRgb>) -> ! {
|
||||||
|
|
||||||
|
let mut rng = 1;
|
||||||
|
let mut pixels = [Pixel::new(); FULL_PORCH];
|
||||||
|
|
||||||
|
for pixel in pixels.iter_mut() {
|
||||||
|
pixel.tick(murmurf(&mut rng));
|
||||||
|
}
|
||||||
|
|
||||||
|
loop {
|
||||||
|
|
||||||
|
Harrogate {
|
||||||
|
porch_back: (0..FULL_PORCH).map(|_| GOLD),
|
||||||
|
porch_front: pixels.iter().map(|p| p.color)
|
||||||
|
}
|
||||||
|
.render_to(lights);
|
||||||
|
|
||||||
|
delay(300_000);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ use lights_hal::{boot, entry};
|
||||||
pub use lights_hal::delay;
|
pub use lights_hal::delay;
|
||||||
|
|
||||||
mod december_01_2019;
|
mod december_01_2019;
|
||||||
|
mod december_21_2019;
|
||||||
mod door_light;
|
mod door_light;
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
|
@ -15,6 +16,9 @@ fn main() -> ! {
|
||||||
#[cfg(feature = "december-01-2019")]
|
#[cfg(feature = "december-01-2019")]
|
||||||
december_01_2019::run(&mut lights);
|
december_01_2019::run(&mut lights);
|
||||||
|
|
||||||
|
#[cfg(feature = "december-21-2019")]
|
||||||
|
december_21_2019::run(&mut lights);
|
||||||
|
|
||||||
#[cfg(not(feature = "replace-default"))]
|
#[cfg(not(feature = "replace-default"))]
|
||||||
door_light::run(&mut lights);
|
door_light::run(&mut lights);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue