X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=tinyboard.git;a=blobdiff_plain;f=projects%2Fstep-up%2Fpattern.c;h=261db2c31be4562fb04794d39099005ef48488df;hp=693df1df9565664a21f3b370da636027411b7449;hb=8b54d4bdf1305a636d6c1d03e6a725061f47c612;hpb=655d773afa02e2589680fa9cefd4302efa2fd2b3 diff --git a/projects/step-up/pattern.c b/projects/step-up/pattern.c index 693df1d..261db2c 100644 --- a/projects/step-up/pattern.c +++ b/projects/step-up/pattern.c @@ -3,7 +3,7 @@ #include "lights.h" -#define N_LEDS 1 +#define N_LEDS 2 static unsigned char led_counters[N_LEDS]; static pattern_t *led_patterns[N_LEDS]; @@ -74,8 +74,9 @@ pattern_t on1_pattern[] = { static void led_set_mode(unsigned char n, unsigned char mode) { - if (n == 0) { - pwmled_on_off(mode); + switch (n) { + case 0: pwmled_on_off(mode); break; + case 1: status_led_on_off(mode); break; } } @@ -116,21 +117,9 @@ pattern_t *number_pattern(unsigned char num, unsigned char inv) static pattern_t *pattern_select(unsigned char n) { - static unsigned char count; - static unsigned char mode; switch(n) { - case 0: - if (++count > 2) { - count = 0; - if (mode == 0) { - mode = 3; - } else { - mode = 0; - } - - pwmled_set_target(mode); - } - return number_pattern(mode ? 2 : 3, 0); + case 0: return pwmled_pattern_select(); + case 1: return status_led_pattern_select(); default: return NULL; } } @@ -148,21 +137,7 @@ static void inline pattern_finished(unsigned char n) unsigned char i; led_patterns[n] = NULL; - - if (n == 0) { - led_set_pattern(0, pattern_select(0)); - } -#if 0 - } else if (n == 3) { - if (!led_patterns[4]) - led_set_pattern(4, pattern_select(4)); - } else if (n == 4) { - if (!led_patterns[3]) - led_set_pattern(3, pattern_select(3)); - } else { - led_set_pattern(n, pattern_select(n)); - } -#endif + led_set_pattern(n, pattern_select(n)); } void patterns_next_tick()