diff --git a/house/Cargo.lock b/house/Cargo.lock new file mode 100644 index 0000000..d51c6a8 --- /dev/null +++ b/house/Cargo.lock @@ -0,0 +1,13 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "house" +version = "0.1.0" +dependencies = [ + "lights 0.1.0", +] + +[[package]] +name = "lights" +version = "0.1.0" + diff --git a/house/Cargo.toml b/house/Cargo.toml new file mode 100644 index 0000000..019c2fb --- /dev/null +++ b/house/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "house" +version = "0.1.0" +authors = ["Tangent 128 "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +lights = { path = "../lights" } diff --git a/house/src/lib.rs b/house/src/lib.rs new file mode 100644 index 0000000..0c033b0 --- /dev/null +++ b/house/src/lib.rs @@ -0,0 +1,40 @@ +#![no_std] + +use lights::HardwareRgb; +use lights::gamma::correct; +use lights::Lights; +use lights::PixelIterator; +use lights::rgb::Rgb; + +const PORCH_BACK_LEN: usize = 150; +const PORCH_FRONT_LEN: usize = 150; + + +pub struct Harrogate { + pub porch_back: PB, + pub porch_front: PF, +} + +impl Harrogate +where + PB: IntoIterator, + PF: IntoIterator, +{ + pub fn render_to>(self, lights: &mut L) { + let mut buffer = [HardwareRgb(255,0,255); PORCH_BACK_LEN + PORCH_FRONT_LEN]; + + for (i, pixel) in self.porch_back.into_iter().take(PORCH_BACK_LEN).enumerate() { + buffer[PORCH_BACK_LEN - i] = correct(&pixel); + } + for (i, pixel) in self.porch_front.into_iter().take(PORCH_FRONT_LEN).enumerate() { + buffer[PORCH_BACK_LEN + i] = correct(&pixel); + } + + buffer.iter().render_to(lights); + } +} + +#[cfg(test)] +mod tests { + // #[test] +}