From 0a721463629132b97080ba39ad2add5340f0cfcc Mon Sep 17 00:00:00 2001 From: Andre Henriques Date: Wed, 15 Mar 2023 22:55:56 +0000 Subject: [PATCH] update render --- src/render.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/render.rs b/src/render.rs index ed9b330..c205acb 100644 --- a/src/render.rs +++ b/src/render.rs @@ -232,8 +232,6 @@ impl Render { pub fn render(&mut self) { - println!("render"); - if self.ws.is_none() { return; } let mut data: Vec> = vec![RGB::default(); self.num_leds.try_into().unwrap()]; @@ -292,8 +290,6 @@ impl Render { to_clean.iter().for_each(|i| self.remove_animation(i.to_string())); - println!("pre-push"); - if self.last.is_empty() || !self.last.clone().iter().eq(data.clone().iter()) { if self.last.len() == 0 { @@ -303,7 +299,7 @@ impl Render { let lerp_data: Vec> = data.iter().zip(&self.last).map(|(d, l)| d.lerp(l, delta as f64)).collect(); - println!("d:{:?}\n l:{:?}", data, lerp_data); + //println!("d:{:?}\n l:{:?}", data, lerp_data); let to_set_data: Vec> = rgbs_f64_to_u8(&lerp_data); @@ -336,7 +332,13 @@ pub trait Lerp { impl Lerp for f64 { fn lerp(self, other: &Self, diff: f64) -> Self { let delta = diff / 1_000_000.0; - self + ((*other - self) * 0.5 * delta) + let lerped = self + ((*other - self) * 0.5 * delta); + + if *other != self { + println!("c: {} target:{} lerp: {}", self, other, lerped); + } + + lerped } }