July 4
This commit is contained in:
parent
3ee29b41f9
commit
b31c7beaa0
3 changed files with 47 additions and 0 deletions
|
@ -19,6 +19,7 @@ december-21-2019 = ["replace-default"]
|
||||||
december-24-2019 = ["replace-default"]
|
december-24-2019 = ["replace-default"]
|
||||||
valentines-2020 = ["replace-default"]
|
valentines-2020 = ["replace-default"]
|
||||||
st-patricks-day = ["replace-default"]
|
st-patricks-day = ["replace-default"]
|
||||||
|
july-4 = ["replace-default"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
house = { path = "../house" }
|
house = { path = "../house" }
|
||||||
|
|
42
harrogate/src/july_4.rs
Normal file
42
harrogate/src/july_4.rs
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
//! 50-star USA Flag, stars on front, stripes on back.
|
||||||
|
use super::delay;
|
||||||
|
use core::iter::repeat;
|
||||||
|
use house::Harrogate;
|
||||||
|
use lights::rgb::Rgb;
|
||||||
|
use lights::{HardwareRgb, Lights};
|
||||||
|
|
||||||
|
const OFF: Rgb = Rgb(0, 0, 0);
|
||||||
|
const RED: Rgb = Rgb(255, 0, 0);
|
||||||
|
const WHITE: Rgb = Rgb(255, 255, 255);
|
||||||
|
const BLUE: Rgb = Rgb(0, 0, 200);
|
||||||
|
|
||||||
|
const FULL_PORCH: usize = 150;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn run(lights: &mut impl Lights<Pixel = HardwareRgb>) -> ! {
|
||||||
|
let stars = [BLUE, WHITE, BLUE]
|
||||||
|
.iter()
|
||||||
|
.cycle()
|
||||||
|
.take(FULL_PORCH)
|
||||||
|
.cloned();
|
||||||
|
let stripes = repeat(RED)
|
||||||
|
.take(11)
|
||||||
|
.chain(repeat(WHITE).take(11))
|
||||||
|
.cycle()
|
||||||
|
.take(11 * 12)
|
||||||
|
.chain(repeat(RED).take(11))
|
||||||
|
.chain(repeat(OFF))
|
||||||
|
.take(FULL_PORCH);
|
||||||
|
|
||||||
|
let pattern = Harrogate {
|
||||||
|
porch_back: stripes,
|
||||||
|
porch_front: stars,
|
||||||
|
};
|
||||||
|
|
||||||
|
loop {
|
||||||
|
pattern.clone().render_to(lights);
|
||||||
|
|
||||||
|
delay(1_000_000);
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ mod december_21_2019;
|
||||||
mod december_24_2019;
|
mod december_24_2019;
|
||||||
mod valentines_2020;
|
mod valentines_2020;
|
||||||
mod st_patricks_day;
|
mod st_patricks_day;
|
||||||
|
mod july_4;
|
||||||
mod door_light;
|
mod door_light;
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
|
@ -31,6 +32,9 @@ fn main() -> ! {
|
||||||
#[cfg(feature = "st-patricks-day")]
|
#[cfg(feature = "st-patricks-day")]
|
||||||
st_patricks_day::run(&mut lights);
|
st_patricks_day::run(&mut lights);
|
||||||
|
|
||||||
|
#[cfg(feature = "july-4")]
|
||||||
|
july_4::run(&mut lights);
|
||||||
|
|
||||||
#[cfg(not(feature = "replace-default"))]
|
#[cfg(not(feature = "replace-default"))]
|
||||||
door_light::run(&mut lights);
|
door_light::run(&mut lights);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue