From 66c431f20c0adeaa8c7fe884c91545a6168118b0 Mon Sep 17 00:00:00 2001 From: Tobias Ollive Date: Fri, 18 Mar 2022 14:41:16 +0100 Subject: [PATCH] improve time management --- src/patterns/stars_random.rs | 6 +++--- src/runner.rs | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/patterns/stars_random.rs b/src/patterns/stars_random.rs index 75c77f9..a022a9b 100644 --- a/src/patterns/stars_random.rs +++ b/src/patterns/stars_random.rs @@ -27,9 +27,9 @@ impl Pattern for StarsRandom { fn init(&mut self) -> Option { if let Some(color) = self.background_color { self.strip = Strip::::new(color); - let red = (self.color.red as i16 - color.red as i16); - let green = (color.green as i16 - self.color.green as i16); - let blue = (self.color.blue as i16 - color.blue as i16); + let red = self.color.red as i16 - color.red as i16; + let green = color.green as i16 - self.color.green as i16; + let blue = self.color.blue as i16 - color.blue as i16; self.step = ( -(red / self.steps as i16) as i8, -(green / self.steps as i16) as i8, diff --git a/src/runner.rs b/src/runner.rs index 386c826..f877110 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -9,6 +9,7 @@ use std::future::Future; use std::str::FromStr; use std::time::Duration; use tokio::sync::watch::{Receiver, Sender}; +use tokio::time::Instant; pub(crate) mod period { use serde::{de::Error as _, Deserialize, Deserializer}; @@ -56,17 +57,19 @@ async fn runner_loop(runner: DeviceSequence, tx: Sender(previous_strip: Strip, strip: Strip<{ N }>) -> Strip {