WIP Halloween 2024 pattern

This commit is contained in:
Tangent Wantwight 2024-10-02 21:10:32 -04:00
parent d873e3482e
commit e745c55b51
3 changed files with 79 additions and 0 deletions

View file

@ -26,6 +26,7 @@ halloween-2020 = ["replace-default"]
halloween-2021 = ["replace-default"] halloween-2021 = ["replace-default"]
halloween-2022 = ["replace-default"] halloween-2022 = ["replace-default"]
halloween-2023 = ["replace-default"] halloween-2023 = ["replace-default"]
halloween-2024 = ["replace-default"]
new-years-eve-2020 = ["replace-default"] new-years-eve-2020 = ["replace-default"]
november-2020 = ["replace-default"] november-2020 = ["replace-default"]

View file

@ -0,0 +1,74 @@
//! purple-and-orange with chaotically-varying background
use super::delay;
use house::{Harrogate, PORCH_BACK_LEN, PORCH_FRONT_LEN};
use lights::{murmurf, rgb::Rgb, HardwareRgb, Lights};
const BLACK: Rgb = Rgb(0, 0, 0);
const ORANGE: Rgb = Rgb(255, 150, 0);
const PURPLE: Rgb = Rgb(100, 0, 128);
const COLORS: &[Rgb] = &[
Rgb(255, 0, 0),
Rgb(0, 1, 0),
Rgb(150, 150, 150),
Rgb(0, 1, 0),
Rgb(255, 150, 0),
Rgb(0, 1, 0),
Rgb(150, 0, 255),
Rgb(0, 1, 0),
];
/*const RAINBOW: &[Rgb] = &[
Rgb(255, 0, 0),
Rgb(255, 150, 0),
Rgb(255, 255, 0),
Rgb(150, 255, 0),
Rgb(0, 255, 0),
Rgb(0, 255, 255),
Rgb(0, 0, 255),
Rgb(150, 0, 255),
Rgb(255, 0, 150),
];*/
// a hundredth of a second
const TIC: u32 = 48_000_0;
#[allow(dead_code)]
#[inline(always)]
pub fn run(lights: &mut impl Lights<Pixel = HardwareRgb>) -> ! {
let mut rng = 0x642u32;
let mut bar = 0;
let mut color_index: usize = 0;
let mut back_buffer = [BLACK; PORCH_BACK_LEN];
let mut draw = |back_buffer: &[Rgb]| {
let front_pattern = [PURPLE, ORANGE].iter().cycle().cloned();
Harrogate {
porch_front: front_pattern.take(PORCH_FRONT_LEN),
porch_back: back_buffer.iter().cloned(),
}
.render_to(lights);
};
loop {
// animate rainbow bars
if bar == 0 {
color_index = (color_index + 1 + (murmurf(&mut rng) as usize % 6)) % COLORS.len();
bar = 10;
}
bar -= 1;
// push into buffer
back_buffer.rotate_right(1);
back_buffer[0] = COLORS[color_index];
back_buffer[PORCH_BACK_LEN - 1].1 = 255;
// render
draw(&back_buffer);
delay(TIC);
}
}

View file

@ -17,6 +17,7 @@ mod halloween_2020;
mod halloween_2021; mod halloween_2021;
mod halloween_2022; mod halloween_2022;
mod halloween_2023; mod halloween_2023;
mod halloween_2024;
mod november_2020; mod november_2020;
mod new_years_eve_2020; mod new_years_eve_2020;
mod door_light; mod door_light;
@ -62,6 +63,9 @@ fn main() -> ! {
#[cfg(feature = "halloween-2023")] #[cfg(feature = "halloween-2023")]
halloween_2023::run(&mut lights); halloween_2023::run(&mut lights);
#[cfg(feature = "halloween-2024")]
halloween_2024::run(&mut lights);
#[cfg(feature = "new-years-eve-2020")] #[cfg(feature = "new-years-eve-2020")]
new_years_eve_2020::run(&mut lights); new_years_eve_2020::run(&mut lights);