Valentine's pattern

This commit is contained in:
Tangent Wantwight 2020-02-13 18:55:33 -05:00
parent 0cae424628
commit 262c45a668
3 changed files with 41 additions and 0 deletions

View file

@ -17,6 +17,7 @@ replace-default = []
december-01-2019 = ["replace-default"] december-01-2019 = ["replace-default"]
december-21-2019 = ["replace-default"] december-21-2019 = ["replace-default"]
december-24-2019 = ["replace-default"] december-24-2019 = ["replace-default"]
valentines-2020 = ["replace-default"]
[dependencies] [dependencies]
house = { path = "../house" } house = { path = "../house" }

View file

@ -8,6 +8,7 @@ pub use lights_hal::delay;
mod december_01_2019; mod december_01_2019;
mod december_21_2019; mod december_21_2019;
mod december_24_2019; mod december_24_2019;
mod valentines_2020;
mod door_light; mod door_light;
#[entry] #[entry]
@ -23,6 +24,9 @@ fn main() -> ! {
#[cfg(feature = "december-24-2019")] #[cfg(feature = "december-24-2019")]
december_24_2019::run(&mut lights); december_24_2019::run(&mut lights);
#[cfg(feature = "valentines-2020")]
valentines_2020::run(&mut lights);
#[cfg(not(feature = "replace-default"))] #[cfg(not(feature = "replace-default"))]
door_light::run(&mut lights); door_light::run(&mut lights);
} }

View file

@ -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<Pixel = HardwareRgb>) -> ! {
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);
}
}