From: Jan "Yenya" Kasprzak Date: Wed, 21 Nov 2012 15:30:08 +0000 (+0100) Subject: patterns: PATTERN_FOREVER X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=63d8caf3a232630160a7af8c371b98351cd534bc;p=bike-lights.git patterns: PATTERN_FOREVER --- diff --git a/firmware/lights.h b/firmware/lights.h index d0eddd7..eede4d1 100644 --- a/firmware/lights.h +++ b/firmware/lights.h @@ -64,6 +64,7 @@ typedef struct { unsigned char duration: 5; } pattern_t; +#define PATTERN_FOREVER 0x1F #define PATTERN_END { 0, 0 } extern pattern_t off_pattern[]; extern pattern_t on_pattern[]; @@ -72,6 +73,7 @@ void pattern_init(); void patterns_next_tick(); void led_set_status(unsigned char status); void led_set_pattern(unsigned char led, pattern_t *pattern); +pattern_t *number_pattern(unsigned char num); /* buttons.c */ #define MAX_USER_PARAMS 3 diff --git a/firmware/pattern.c b/firmware/pattern.c index 2e06b67..a11999d 100644 --- a/firmware/pattern.c +++ b/firmware/pattern.c @@ -6,13 +6,11 @@ static unsigned char led_counters[N_LEDS]; static pattern_t *led_patterns[N_LEDS]; pattern_t off_pattern[] = { - { 0, 0x1F }, - PATTERN_END + { 0, PATTERN_FOREVER }, }; pattern_t on_pattern[] = { - { 1, 0x1F }, - PATTERN_END + { 1, PATTERN_FOREVER }, }; pattern_t blink_pattern[] = { @@ -74,7 +72,7 @@ pattern_t pattern_num[] = { { 1, 0x1 }, /* 2 */ { 0, 0x5 }, { 1, 0x1 }, /* 1 */ - { 0, 0x1F }, + { 0, 0x1E }, PATTERN_END }; @@ -103,10 +101,9 @@ void pattern_init() { unsigned char i; - for (i = 0; i < N_LEDS; i++) { - led_counters[i] = 0; - led_patterns[i] = off_pattern; - } + for (i = 0; i < N_LEDS; i++) + led_set_pattern(i, off_pattern); + led_set_pattern(N_PWMLEDS+1, boot_pattern); test_running = 0; } @@ -145,7 +142,8 @@ void patterns_next_tick() led_set_pattern(i, p); } - led_counters[i]--; + if (led_counters[i] < PATTERN_FOREVER) + led_counters[i]--; } }