From 88236f5966579c0c84f7236896333c3ae225d2bb Mon Sep 17 00:00:00 2001 From: Tangent 128 Date: Sun, 27 Oct 2019 01:04:05 -0400 Subject: [PATCH] Make a mess while debugging the light signals. This code still turns every pixel white. --- hello_gradient/src/bin/july4.rs | 42 ++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/hello_gradient/src/bin/july4.rs b/hello_gradient/src/bin/july4.rs index 57e1299..af4156b 100644 --- a/hello_gradient/src/bin/july4.rs +++ b/hello_gradient/src/bin/july4.rs @@ -2,20 +2,26 @@ #![no_main] use core::iter::repeat; +use core::sync::atomic::{ + compiler_fence, + Ordering::SeqCst +}; use lights::{ - gamma::GammaCorrector, + gamma::correct, + HardwareRgb, PixelIterator, rgb::{ Rgb } }; -use lights_hal::{boot, delay, entry}; +use lights_hal::{boot, delay, entry, OutputPin}; #[entry] fn main() -> ! { - let mut lights = GammaCorrector(boot()); + let mut lights = boot(); + lights.red_led.set_high().unwrap(); - let pattern = + let mut pattern = repeat(&Rgb(255,0,0)).take(5) .chain( repeat(&Rgb(255,255,255)).take(5) @@ -29,17 +35,35 @@ fn main() -> ! { Rgb(255,255,255), Rgb(0,0,255), ].iter().cycle().take(85) - ); + ).cycle(); - let mut buffer = [Rgb(255,0,255); 150]; + let mut buffer = [HardwareRgb(255,255,0); 150]; + let mut light = false; + //delay(48_000_000 * 3); loop { + if light { + lights.red_led.set_high().unwrap(); + } else { + lights.red_led.set_low().unwrap(); + } + light = !light; + for (i, pixel) in pattern.clone().take(150).enumerate() { - buffer[i] = *pixel; + buffer[i] = correct(pixel); + // buffer[i] = HardwareRgb(0,0,0); } buffer.iter().render_to(&mut lights); + // compiler_fence(SeqCst); + // buffer.iter().render_to(&mut lights); + // lights.out.set_high(); + // lights.high_out.set_low(); + // compiler_fence(SeqCst); + // lights.byte(0); + // lights.byte(0); + // lights.byte(255); - //pattern.next(); - delay(1_000_000); + pattern.next(); + delay(12_000_000); } }