From: Jan "Yenya" Kasprzak Date: Sun, 16 Dec 2012 16:22:26 +0000 (+0100) Subject: pattern.c: off_pattern should not last forever X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=4129018ae076db80b9d5cf6438170c877dd1b3c5;p=bike-lights.git pattern.c: off_pattern should not last forever --- diff --git a/firmware/pattern.c b/firmware/pattern.c index 59692bf..d5720b0 100644 --- a/firmware/pattern.c +++ b/firmware/pattern.c @@ -76,6 +76,11 @@ static pattern_t pattern_invnum[] = { PATTERN_END }; +pattern_t off_pattern[] = { + { 0, 0x1E }, + PATTERN_END +}; + static void led_set_mode(unsigned char n, unsigned char mode) { if (n < N_PWMLEDS) { @@ -87,12 +92,10 @@ static void led_set_mode(unsigned char n, unsigned char mode) void led_set_pattern(unsigned char n, pattern_t *pattern) { - led_patterns[n] = pattern; + if (!pattern) + pattern = off_pattern; - if (!pattern) { - led_set_mode(n, 0); - return; - } + led_patterns[n] = pattern; led_counters[n] = pattern->duration; led_set_mode(n, pattern->mode);