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 <algernon@madhouse-project.org>
pull/365/head
Gergely Nagy 8 years ago
parent 11535dd716
commit 80b8327442

@ -61,19 +61,22 @@ namespace Akela {
if (map[r][c]) if (map[r][c])
led_set_crgb_at (r, c, colorComputer->compute (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) if (map[r][c] >= 0xf0)
map[r][c]--; map[r][c]--;
else if (map[r][c] >= 0x40) else if (map[r][c] >= 0x40)
map[r][c] -= 16; map[r][c] -= 16;
else if (map[r][c] >= 32) else if (map[r][c] >= 32)
map[r][c] -= 32; map[r][c] -= 32;
else { else
map[r][c] = 0; map[r][c] = 0;
if (!wasZero && !map[r][c])
led_set_crgb_at (r, c, (cRGB){0, 0, 0}); led_set_crgb_at (r, c, (cRGB){0, 0, 0});
} }
} }
} }
}
namespace Stalker { namespace Stalker {

Loading…
Cancel
Save