diff --git a/harrogate/Cargo.toml b/harrogate/Cargo.toml index 454301b..906327f 100644 --- a/harrogate/Cargo.toml +++ b/harrogate/Cargo.toml @@ -17,6 +17,7 @@ replace-default = [] december-01-2019 = ["replace-default"] december-21-2019 = ["replace-default"] december-24-2019 = ["replace-default"] +valentines-2020 = ["replace-default"] [dependencies] house = { path = "../house" } diff --git a/harrogate/src/main.rs b/harrogate/src/main.rs index 0e7d901..e168ca8 100644 --- a/harrogate/src/main.rs +++ b/harrogate/src/main.rs @@ -8,6 +8,7 @@ pub use lights_hal::delay; mod december_01_2019; mod december_21_2019; mod december_24_2019; +mod valentines_2020; mod door_light; #[entry] @@ -23,6 +24,9 @@ fn main() -> ! { #[cfg(feature = "december-24-2019")] december_24_2019::run(&mut lights); + #[cfg(feature = "valentines-2020")] + valentines_2020::run(&mut lights); + #[cfg(not(feature = "replace-default"))] door_light::run(&mut lights); } diff --git a/harrogate/src/valentines_2020.rs b/harrogate/src/valentines_2020.rs new file mode 100644 index 0000000..35f18bf --- /dev/null +++ b/harrogate/src/valentines_2020.rs @@ -0,0 +1,36 @@ +use super::delay; +use core::iter::repeat; +use house::Harrogate; +use lights::rgb::{linear_gradient, Rgb}; +use lights::{HardwareRgb, Lights}; + +const OFF: Rgb = Rgb(0, 0, 0); +const ON: Rgb = Rgb(255, 255, 255); +const RED: Rgb = Rgb(255, 0, 0); +const PURPLE: Rgb = Rgb(255, 0, 255); + +/* + * 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(OFF, ON, 20) + .chain(repeat(ON).take(25)) + .chain(linear_gradient(ON, OFF, 20)) + .enumerate() + .map(|(i, pixel)| pixel * if i % 2 == 0 { RED } else { PURPLE }); + + let pattern = Harrogate { + porch_back: repeat(OFF).take(85).chain(door_highlight), + porch_front: repeat(OFF), + }; + + loop { + pattern.clone().render_to(lights); + + delay(48_000_000); + } +}