static unsigned char test_running;
+static void led_set_mode(unsigned char n, unsigned char mode)
+{
+ if (n < N_PWMLEDS) {
+ pwmled_set_mode(n, mode);
+ } else if (n < N_LEDS) {
+ gpio_set(n - N_PWMLEDS, mode);
+ }
+}
+
+void led_set_pattern(unsigned char n, pattern_t *pattern)
+{
+ if (!pattern)
+ pattern = off_pattern;
+
+ led_patterns[n] = pattern;
+ led_counters[n] = pattern->duration;
+ led_set_mode(n, pattern->mode);
+}
+
void pattern_init()
{
unsigned char i;
led_counters[i] = 0;
led_patterns[i] = off_pattern;
}
- led_patterns[N_PWMLEDS+1] = boot_pattern;
- led_counters[N_PWMLEDS+1] = boot_pattern->duration;
- gpio_set(GPIO_LED2, 1);
+ led_set_pattern(N_PWMLEDS+1, boot_pattern);
test_running = 0;
}
return number_pattern(1+ambient_zone);
}
-static void led_set_mode(unsigned char n, unsigned char mode)
-{
- if (n < N_PWMLEDS) {
- pwmled_set_mode(n, mode);
- } else if (n < N_LEDS) {
- gpio_set(n - N_PWMLEDS, mode);
- }
-}
-
void patterns_next_tick()
{
unsigned char i;
for (i = 0; i < N_LEDS; i++) {
if (led_counters[i] == 0) {
- led_patterns[i]++;
- if (led_patterns[i]->duration == 0) { // END
- led_patterns[i] = pattern_select(i);
+ pattern_t *p = led_patterns[i];
+ p++;
+ if (p->duration == 0) { // END
+ p = pattern_select(i);
}
- led_counters[i] = led_patterns[i]->duration;
- led_set_mode(i, led_patterns[i]->mode);
+ led_set_pattern(i, p);
}
led_counters[i]--;