X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=firmware%2Fpattern.c;h=2e06b67e476fca2c35dad4fe0ef7e39648bff413;hb=47e678a90062fa2dbc6cb8f9e5efc81072f5dcc5;hp=a39be3657c579a4e4cf8d5a5a65ebb61c729f7f8;hpb=b475975f99700f3e887df281130a3b9de62368c5;p=bike-lights.git diff --git a/firmware/pattern.c b/firmware/pattern.c index a39be36..2e06b67 100644 --- a/firmware/pattern.c +++ b/firmware/pattern.c @@ -2,20 +2,19 @@ #include "lights.h" -typedef struct { - unsigned char mode: 3; - unsigned char duration: 5; -} pattern_t; - static unsigned char led_counters[N_LEDS]; static pattern_t *led_patterns[N_LEDS]; -#define PATTERN_END { 0, 0 } pattern_t off_pattern[] = { { 0, 0x1F }, PATTERN_END }; +pattern_t on_pattern[] = { + { 1, 0x1F }, + PATTERN_END +}; + pattern_t blink_pattern[] = { { 1, 0x4 }, { 0, 0x8 }, @@ -23,9 +22,9 @@ pattern_t blink_pattern[] = { }; pattern_t mode1_pattern[] = { - { 3, 0x1 }, + { 4, 0x1 }, { 0, 0x1 }, - { 3, 0x1 }, + { 4, 0x1 }, { 0, 0x8 }, { 1, 0x1 }, { 0, 0x1 }, @@ -55,24 +54,25 @@ pattern_t boot_pattern[] = { }; pattern_t pattern_num[] = { + { 0, 0x5 }, { 1, 0x1 }, /* 10 */ - { 0, 0x4 }, + { 0, 0x5 }, { 1, 0x1 }, /* 9 */ - { 0, 0x4 }, + { 0, 0x5 }, { 1, 0x1 }, /* 8 */ - { 0, 0x4 }, + { 0, 0x5 }, { 1, 0x1 }, /* 7 */ - { 0, 0x4 }, + { 0, 0x5 }, { 1, 0x1 }, /* 6 */ - { 0, 0x4 }, + { 0, 0x5 }, { 1, 0x1 }, /* 5 */ - { 0, 0x4 }, + { 0, 0x5 }, { 1, 0x1 }, /* 4 */ - { 0, 0x4 }, + { 0, 0x5 }, { 1, 0x1 }, /* 3 */ - { 0, 0x4 }, + { 0, 0x5 }, { 1, 0x1 }, /* 2 */ - { 0, 0x4 }, + { 0, 0x5 }, { 1, 0x1 }, /* 1 */ { 0, 0x1F }, PATTERN_END @@ -117,19 +117,18 @@ static pattern_t *number_pattern(unsigned char num) num = 9; return pattern_num + sizeof(pattern_num)/sizeof(pattern_t) - - 1 - 2*num; + - 2 - 2*num; } static inline pattern_t *pattern_select(unsigned char n) { if (n < N_PWMLEDS && !pwmled_enabled(n)) return off_pattern; // Don't mess with non-enabled LEDs - - if (n == 2) { + else if (n == 2) return mode1_pattern; - } - return number_pattern(1+ambient_zone); - // return off_pattern; + else if (n == 3) + return number_pattern(1+ambient_zone); + return off_pattern; } void patterns_next_tick()