update render

This commit is contained in:
Andre Henriques 2023-03-15 22:55:56 +00:00
parent 16ea28557e
commit 0a72146362

View File

@ -232,8 +232,6 @@ impl Render {
pub fn render(&mut self) {
println!("render");
if self.ws.is_none() { return; }
let mut data: Vec<RGB<f64>> = 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<RGB<f64>> = 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<RGB<u8>> = 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
}
}