diff --git a/harrogate/Cargo.toml b/harrogate/Cargo.toml index 8ff261b..63d8259 100644 --- a/harrogate/Cargo.toml +++ b/harrogate/Cargo.toml @@ -2,7 +2,7 @@ name = "harrogate" version = "0.1.0" authors = ["Tangent 128 "] -edition = "2018" +edition = "2021" [profile.release] lto = true @@ -18,6 +18,7 @@ december-01-2019 = ["replace-default"] december-21-2019 = ["replace-default"] december-24-2019 = ["replace-default"] december-02-2020 = ["replace-default"] +december-02-2021 = ["replace-default"] valentines-2020 = ["replace-default"] st-patricks-day = ["replace-default"] july-4 = ["replace-default"] diff --git a/harrogate/src/december_02_2021.rs b/harrogate/src/december_02_2021.rs new file mode 100644 index 0000000..1f7778a --- /dev/null +++ b/harrogate/src/december_02_2021.rs @@ -0,0 +1,47 @@ +use super::delay; +use core::iter::repeat; +use house::Harrogate; +use lights::{HardwareRgb, Lights, murmurf}; +use lights::rgb::{linear_gradient, Rgb}; + +const BG: Rgb = Rgb(255, 0, 255); +const DOOR: Rgb = Rgb(255, 255, 255); + +const YELLOW: Rgb = Rgb(200, 200, 0); +const RED: Rgb = Rgb(200, 0, 0); +const GREEN: Rgb = Rgb(0, 200, 0); +const BLUE: Rgb = Rgb(0, 0, 200); +//const PURPLE: Rgb = Rgb(160, 0, 128); + +/* + * 20 fade + 25 ON + 20 fade = 65 dots + * 85 OFF + 65 door = 150 dots + */ + +#[allow(dead_code)] +#[inline(always)] +pub fn run(lights: &mut impl Lights) -> ! { + let door_highlight = linear_gradient(BG, DOOR, 20) + .chain(repeat(DOOR).take(25)) + .chain(linear_gradient(DOOR, BG, 20)); + + let mut rng: u32 = 0xF07; + + loop { + + let mut colors = [RED, YELLOW, GREEN, BLUE, RED, YELLOW, GREEN, BLUE]; + + // shuffle + for i in 2usize..=8 { + let swap_with = murmurf(&mut rng) as usize % i; + (colors[i - 1], colors[swap_with]) = (colors[swap_with], colors[i - 1]); + } + + Harrogate { + porch_back: repeat(BG).take(85).chain(door_highlight.clone()), + porch_front: colors.into_iter().flat_map(|color| repeat(color).take(19)), + }.render_to(lights); + + delay(48_000_000 / 3); + } +} diff --git a/harrogate/src/main.rs b/harrogate/src/main.rs index 7b044c2..d3b0724 100644 --- a/harrogate/src/main.rs +++ b/harrogate/src/main.rs @@ -1,5 +1,6 @@ #![no_std] #![no_main] +#![feature(destructuring_assignment)] use lights_hal::{boot, entry}; @@ -9,6 +10,7 @@ mod december_01_2019; mod december_21_2019; mod december_24_2019; mod december_02_2020; +mod december_02_2021; mod valentines_2020; mod st_patricks_day; mod july_4; @@ -34,6 +36,9 @@ fn main() -> ! { #[cfg(feature = "december-02-2020")] december_02_2020::run(&mut lights); + #[cfg(feature = "december-02-2021")] + december_02_2021::run(&mut lights); + #[cfg(feature = "valentines-2020")] valentines_2020::run(&mut lights);