Fix flashing
This commit is contained in:
parent
56f264ec3e
commit
3aad5f2555
@ -2,7 +2,6 @@ use super::Pattern;
|
|||||||
use crate::color::{self, Rgb};
|
use crate::color::{self, Rgb};
|
||||||
use std::{
|
use std::{
|
||||||
collections::{vec_deque, VecDeque},
|
collections::{vec_deque, VecDeque},
|
||||||
convert::TryFrom,
|
|
||||||
iter,
|
iter,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -29,12 +28,10 @@ impl Pattern for Flashing {
|
|||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
fn init(&mut self, num_lights: u16) -> Result<(), ()> {
|
fn init(&mut self, num_lights: u16) -> Result<(), ()> {
|
||||||
if self.lights_buf.len() == 0 {
|
if num_lights == 0 {
|
||||||
return Err(());
|
return Err(());
|
||||||
}
|
}
|
||||||
let length_factor = u16::try_from(self.lights_buf.len())
|
let length_factor = num_lights.saturating_mul(u16::from(self.width));
|
||||||
.or(Err(()))?
|
|
||||||
.saturating_mul(u16::from(self.width));
|
|
||||||
|
|
||||||
let buf_length = color::min_with_factor(num_lights, length_factor)?;
|
let buf_length = color::min_with_factor(num_lights, length_factor)?;
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ impl LedStrip {
|
|||||||
self.pattern = pat;
|
self.pattern = pat;
|
||||||
} else {
|
} else {
|
||||||
let _ = message_tx.send(errors::Message::String(format!(
|
let _ = message_tx.send(errors::Message::String(format!(
|
||||||
"Error with pattern: {:?}",
|
"Error initializing pattern: {:?}",
|
||||||
pat
|
pat
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user