From f307f448e3f81cd9700ee3ca3125026417146541 Mon Sep 17 00:00:00 2001 From: Tangent Wantwight Date: Wed, 5 Oct 2022 19:57:17 -0400 Subject: [PATCH] Halloween 2022 --- harrogate/Cargo.toml | 1 + harrogate/src/halloween_2022.rs | 37 +++++++++++++++++++++++++++++++++ harrogate/src/main.rs | 4 ++++ 3 files changed, 42 insertions(+) create mode 100644 harrogate/src/halloween_2022.rs diff --git a/harrogate/Cargo.toml b/harrogate/Cargo.toml index 63d8259..01807bd 100644 --- a/harrogate/Cargo.toml +++ b/harrogate/Cargo.toml @@ -24,6 +24,7 @@ st-patricks-day = ["replace-default"] july-4 = ["replace-default"] halloween-2020 = ["replace-default"] halloween-2021 = ["replace-default"] +halloween-2022 = ["replace-default"] new-years-eve-2020 = ["replace-default"] november-2020 = ["replace-default"] diff --git a/harrogate/src/halloween_2022.rs b/harrogate/src/halloween_2022.rs new file mode 100644 index 0000000..d8cabfe --- /dev/null +++ b/harrogate/src/halloween_2022.rs @@ -0,0 +1,37 @@ +//! purple-and-green with "lightning" flashes +use core::iter::repeat; + +use super::delay; +use house::{Harrogate, PORCH_BACK_LEN, PORCH_FRONT_LEN}; +use lights::{rgb::Rgb, HardwareRgb, Lights}; + +const ORANGE: Rgb = Rgb(255, 150, 0); +const PURPLE: Rgb = Rgb(100, 0, 128); + +// tenth of a second +const TIC: u32 = 4_800_000; + +#[allow(dead_code)] +#[inline(always)] +pub fn run(lights: &mut impl Lights) -> ! { + let mut ring = repeat(PURPLE) + .take(PORCH_BACK_LEN) + .chain(repeat(ORANGE).take(PORCH_FRONT_LEN)) + .cycle(); + + loop { + let back = ring.clone(); + let front = back.clone().skip(PORCH_BACK_LEN); + + // render + Harrogate { + porch_back: back, + porch_front: front, + } + .render_to(lights); + + ring.next(); + + delay(TIC * 2); + } +} diff --git a/harrogate/src/main.rs b/harrogate/src/main.rs index 1ce3068..90f8dbe 100644 --- a/harrogate/src/main.rs +++ b/harrogate/src/main.rs @@ -15,6 +15,7 @@ mod st_patricks_day; mod july_4; mod halloween_2020; mod halloween_2021; +mod halloween_2022; mod november_2020; mod new_years_eve_2020; mod door_light; @@ -53,6 +54,9 @@ fn main() -> ! { #[cfg(feature = "halloween-2021")] halloween_2021::run(&mut lights); + #[cfg(feature = "halloween-2022")] + halloween_2022::run(&mut lights); + #[cfg(feature = "new-years-eve-2020")] new_years_eve_2020::run(&mut lights);