From 5cb3c49ed84c15abf3164910308ca7efea4a008f Mon Sep 17 00:00:00 2001 From: Tangent 128 Date: Mon, 28 Oct 2019 20:36:55 -0400 Subject: [PATCH] Revise Halloween pattern --- hello_gradient/src/bin/halloween2019.rs | 22 ++++++++++++++++++---- hello_gradient/src/bin/mardi_gras.rs | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/hello_gradient/src/bin/halloween2019.rs b/hello_gradient/src/bin/halloween2019.rs index 63827b3..2a9cb11 100644 --- a/hello_gradient/src/bin/halloween2019.rs +++ b/hello_gradient/src/bin/halloween2019.rs @@ -12,23 +12,37 @@ use lights::{ }; use lights_hal::{boot, delay, entry}; +const ORANGE: Rgb = Rgb(255,150,0); +const PURPLE: Rgb = Rgb(200,0,255); + +const BUFFER_LEN: usize = 300; + #[entry] fn main() -> ! { let mut lights = boot(); lights.heartbeat(); + let front_pattern = [ + PURPLE, + PURPLE, + ORANGE, + PURPLE, + PURPLE, + ].iter().cycle(); + let back_pattern = repeat(&ORANGE); + let pattern = - repeat(&Rgb(255,0,255)).take(150) + back_pattern.take(150) .chain( - repeat(&Rgb(255,128,0)).take(150) + front_pattern.take(150) ).cycle(); - let mut buffer = [HardwareRgb(255,255,0); 200]; + let mut buffer = [HardwareRgb(255,255,0); BUFFER_LEN]; loop { // blink light to demonstrate loop is still running lights.heartbeat(); - for (i, pixel) in pattern.clone().take(200).enumerate() { + for (i, pixel) in pattern.clone().take(BUFFER_LEN).enumerate() { buffer[i] = correct(pixel); } diff --git a/hello_gradient/src/bin/mardi_gras.rs b/hello_gradient/src/bin/mardi_gras.rs index 6841330..60cbf2f 100644 --- a/hello_gradient/src/bin/mardi_gras.rs +++ b/hello_gradient/src/bin/mardi_gras.rs @@ -13,7 +13,7 @@ const GREEN: Rgb = Rgb(100, 255, 0); const PURPLE: Rgb = Rgb(196, 0, 255); const SEGMENT_LEN: usize = 50; -const BUFFER_LEN: usize = 200; +const BUFFER_LEN: usize = 300; #[entry] fn main() -> ! {