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 boot_pattern[] = {
45 pattern_t pattern_num[] = {
71 for (i = 0; i < N_LEDS; i++) {
73 led_patterns[i] = off_pattern;
75 led_patterns[N_PWMLEDS] = boot_pattern;
76 led_counters[N_PWMLEDS] = boot_pattern->duration;
77 gpio_set(GPIO_LED2, 1);
80 static inline pattern_t *pattern_select(unsigned char n)
82 return pattern_num + sizeof(pattern_num)/sizeof(pattern_t)
83 - 1 - 2*(1+ambient_zone);;
86 static void inline led_off(unsigned char n)
89 gpio_set(GPIO_LED2, 0);
93 static void inline led_set_level(unsigned char n, unsigned char level)
96 gpio_set(GPIO_LED2, 1);
100 void patterns_next_tick()
104 for (i = 0; i < N_LEDS; i++) {
105 if (led_counters[i] == 0) {
107 if (led_patterns[i]->duration == 0) { // END
108 led_patterns[i] = pattern_select(i);
110 led_counters[i] = led_patterns[i]->duration;
111 if (led_patterns[i]->mode == 0) {
114 led_set_level(i, led_patterns[i]->mode - 1);