From 41210d756cc3e271b92533747fa14eb8ce233c9d Mon Sep 17 00:00:00 2001 From: Andre Henriques Date: Mon, 10 Jul 2023 21:23:22 +0100 Subject: [PATCH] chore: fix outof bounds problem --- src/render.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/render.rs b/src/render.rs index ea71a7a..5583638 100644 --- a/src/render.rs +++ b/src/render.rs @@ -175,7 +175,7 @@ impl Render { ); self.local_led_config = local_led_config; - self.ws = Some(Ws2812Rpi::new(current_pos as i32, PIN).unwrap()); + self.ws = Some(Ws2812Rpi::new(self.num_leds as i32, PIN).unwrap()); Ok(()) } @@ -248,7 +248,11 @@ impl Render { local_led_config.push(LocalLedConfiguration { tag, start, end }); } - self.num_leds = current_pos; + if (self.num_leds != current_pos + 1) { + return self.load_config(); + } + + self.num_leds = current_pos + 1; println!( "Loaded: {} leds, with config: {:?}", self.num_leds, local_led_config