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[] = {
37 pattern_t boot_pattern[] = {
57 pattern_t pattern_num[] = {
81 static unsigned char test_running;
83 static void led_set_mode(unsigned char n, unsigned char mode)
86 pwmled_set_mode(n, mode);
87 } else if (n < N_LEDS) {
88 gpio_set(n - N_PWMLEDS, mode);
92 void led_set_pattern(unsigned char n, pattern_t *pattern)
95 pattern = off_pattern;
97 led_patterns[n] = pattern;
98 led_counters[n] = pattern->duration;
99 led_set_mode(n, pattern->mode);
106 for (i = 0; i < N_LEDS; i++) {
108 led_patterns[i] = off_pattern;
110 led_set_pattern(N_PWMLEDS+1, boot_pattern);
114 static pattern_t *number_pattern(unsigned char num)
119 return pattern_num + sizeof(pattern_num)/sizeof(pattern_t)
123 static inline pattern_t *pattern_select(unsigned char n)
125 if (n < N_PWMLEDS && !pwmled_enabled(n))
126 return off_pattern; // Don't mess with non-enabled LEDs
128 return mode1_pattern;
130 return number_pattern(1+ambient_zone);
134 void patterns_next_tick()
138 for (i = 0; i < N_LEDS; i++) {
139 if (led_counters[i] == 0) {
140 pattern_t *p = led_patterns[i];
142 if (p->duration == 0) { // END
143 p = pattern_select(i);
145 led_set_pattern(i, p);
152 void led_set_status(unsigned char status)
154 led_set_pattern(N_PWMLEDS+1, number_pattern(status));