From 80b832744292e4a2487a165521d4b1ab79ab0143 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Mon, 23 Jan 2017 18:57:39 +0100 Subject: [PATCH] Really, really fix the turn-off-at-the-end code Only turn the LED off if it was on before. Otherwise we will turn off those too that were not in the map yet. Signed-off-by: Gergely Nagy --- src/Akela/LED-Stalker.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Akela/LED-Stalker.cpp b/src/Akela/LED-Stalker.cpp index c39c1b2f..c119c147 100644 --- a/src/Akela/LED-Stalker.cpp +++ b/src/Akela/LED-Stalker.cpp @@ -61,16 +61,19 @@ namespace Akela { if (map[r][c]) led_set_crgb_at (r, c, colorComputer->compute (map[r][c])); + bool wasZero = (map[r][c] == 0); + if (map[r][c] >= 0xf0) map[r][c]--; else if (map[r][c] >= 0x40) map[r][c] -= 16; else if (map[r][c] >= 32) map[r][c] -= 32; - else { + else map[r][c] = 0; + + if (!wasZero && !map[r][c]) led_set_crgb_at (r, c, (cRGB){0, 0, 0}); - } } } }