From 3aad5f2555dbe3704db61486aeafd95cee198f22 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sun, 15 Aug 2021 18:55:50 -0400 Subject: [PATCH] Fix flashing --- src/pattern/flashing.rs | 7 ++----- src/strip.rs | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pattern/flashing.rs b/src/pattern/flashing.rs index 592bfa5..0ad6b09 100644 --- a/src/pattern/flashing.rs +++ b/src/pattern/flashing.rs @@ -2,7 +2,6 @@ use super::Pattern; use crate::color::{self, Rgb}; use std::{ collections::{vec_deque, VecDeque}, - convert::TryFrom, iter, }; @@ -29,12 +28,10 @@ impl Pattern for Flashing { Ok(true) } fn init(&mut self, num_lights: u16) -> Result<(), ()> { - if self.lights_buf.len() == 0 { + if num_lights == 0 { return Err(()); } - let length_factor = u16::try_from(self.lights_buf.len()) - .or(Err(()))? - .saturating_mul(u16::from(self.width)); + let length_factor = num_lights.saturating_mul(u16::from(self.width)); let buf_length = color::min_with_factor(num_lights, length_factor)?; diff --git a/src/strip.rs b/src/strip.rs index 9972730..6a61039 100644 --- a/src/strip.rs +++ b/src/strip.rs @@ -128,7 +128,7 @@ impl LedStrip { self.pattern = pat; } else { let _ = message_tx.send(errors::Message::String(format!( - "Error with pattern: {:?}", + "Error initializing pattern: {:?}", pat ))); }