From 8648d9b93d839b83048e08f789b16dc5de6a66fa Mon Sep 17 00:00:00 2001 From: Maxim Baz Date: Wed, 1 Jan 2025 12:10:07 +0100 Subject: [PATCH] brightness: consume prediction values even if they are not used --- src/brightness/controller.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/brightness/controller.rs b/src/brightness/controller.rs index 6aa6b76..5ef2af9 100644 --- a/src/brightness/controller.rs +++ b/src/brightness/controller.rs @@ -51,13 +51,15 @@ impl Controller { fn step(&mut self) { match self.brightness.get() { Ok(new_brightness) => { + let predicted_value = self.prediction_rx.try_iter().last(); + // 1. check if user wants to learn a new value - this overrides any ongoing activity if Some(new_brightness) != self.current { return self.update_current(new_brightness); } // 2. check if predictor wants to set a new value - if let Some(desired) = self.prediction_rx.try_iter().last() { + if let Some(desired) = predicted_value { self.update_target(desired); }