From bd185825a32c333777843f20300148d5226d6573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Sun, 25 Jun 2023 20:23:41 +0200 Subject: [PATCH] fix: set finished of snake animation on the last step, not after --- src/animations/snake_animation.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/animations/snake_animation.rs b/src/animations/snake_animation.rs index bd3240e..e8e0478 100644 --- a/src/animations/snake_animation.rs +++ b/src/animations/snake_animation.rs @@ -47,12 +47,16 @@ impl Animation for SnakeAnimation { } fn next(&mut self) -> Result { - if self.step == LEDS_COUNT + 100 { - self.finished = true; + let last = LEDS_COUNT + 100; + if self.step == last { return Err(AnimationError::LastStep); } self.step += 1; + if self.step == last { + self.finished = true; + } + Ok(AnimationStep::new(self.step_duration)) } -- 2.48.1