diff --git a/hello_gradient/Cargo.lock b/hello_gradient/Cargo.lock index 3e2a959..c6cdbb0 100644 --- a/hello_gradient/Cargo.lock +++ b/hello_gradient/Cargo.lock @@ -108,12 +108,20 @@ dependencies = [ name = "hello_gradient" version = "0.1.0" dependencies = [ + "house 0.1.0", "itsybitsy_m0 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "itsybitsy_m0_lights 0.1.0", "lights 0.1.0", "panic-halt 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "house" +version = "0.1.0" +dependencies = [ + "lights 0.1.0", +] + [[package]] name = "itsybitsy_m0" version = "0.5.0" diff --git a/hello_gradient/Cargo.toml b/hello_gradient/Cargo.toml index 31589ad..1445c62 100644 --- a/hello_gradient/Cargo.toml +++ b/hello_gradient/Cargo.toml @@ -10,6 +10,7 @@ codegen-units = 1 debug = true [dependencies] +house = { path = "../house" } itsybitsy_m0 = "0.5" lights = { path = "../lights" } lights_hal = { path = "../itsybitsy_m0_lights", package = "itsybitsy_m0_lights" } diff --git a/hello_gradient/src/bin/door_light.rs b/hello_gradient/src/bin/door_light.rs new file mode 100644 index 0000000..dbeb2e6 --- /dev/null +++ b/hello_gradient/src/bin/door_light.rs @@ -0,0 +1,37 @@ +#![no_std] +#![no_main] + +use core::iter::repeat; +use house::Harrogate; +use lights::rgb::{linear_gradient, Rgb}; +use lights_hal::{boot, delay, entry}; + +const OFF: Rgb = Rgb(0, 0, 0); +const ON: Rgb = Rgb(255, 255, 255); + +/* + * 20 fade + 25 ON + 20 fade = 65 dots + * 85 OFF + 65 door = 150 dots + */ + +#[entry] +fn main() -> ! { + let mut lights = boot(); + lights.heartbeat(); + + loop { + // blink light to demonstrate loop is still running + lights.heartbeat(); + + let door_highlight = linear_gradient(OFF, ON, 20) + .chain(repeat(ON).take(25)) + .chain(linear_gradient(ON, OFF, 20)); + + Harrogate { + porch_back: repeat(OFF).take(85).chain(door_highlight), + porch_front: repeat(OFF), + }.render_to(&mut lights); + + delay(48_000_000); + } +}