7 unsigned char duration: 5;
10 static unsigned char led_counters[N_LEDS];
11 static pattern_t *led_patterns[N_LEDS];
13 #define PATTERN_END { 0, 0 }
14 pattern_t off_pattern[] = {
19 pattern_t blink_pattern[] = {
25 pattern_t mode1_pattern[] = {
34 pattern_t boot_pattern[] = {
54 pattern_t pattern_num[] = {
78 static unsigned char test_running;
84 for (i = 0; i < N_LEDS; i++) {
86 led_patterns[i] = off_pattern;
88 led_patterns[N_PWMLEDS] = boot_pattern;
89 led_counters[N_PWMLEDS] = boot_pattern->duration;
90 gpio_set(GPIO_LED2, 1);
94 static pattern_t *number_pattern(unsigned char num)
99 return pattern_num + sizeof(pattern_num)/sizeof(pattern_t)
103 static inline pattern_t *pattern_select(unsigned char n)
105 if (n < N_PWMLEDS && !pwmled_enabled(n))
106 return off_pattern; // Don't mess with non-enabled LEDs
116 return mode1_pattern;
119 return number_pattern(1+ambient_zone);
122 static void led_set_mode(unsigned char n, unsigned char mode)
125 pwmled_set_mode(n, mode);
126 } else if (n == N_PWMLEDS) {
127 gpio_set(GPIO_LED2, mode);
132 static void inline led_set_level(unsigned char n, unsigned char level)
134 if (n == N_PWMLEDS) {
135 gpio_set(GPIO_LED2, 1);
139 void patterns_next_tick()
143 for (i = 0; i < N_LEDS; i++) {
144 if (led_counters[i] == 0) {
146 if (led_patterns[i]->duration == 0) { // END
147 led_patterns[i] = pattern_select(i);
149 led_counters[i] = led_patterns[i]->duration;
150 led_set_mode(i, led_patterns[i]->mode);