From f6264e3bc6bd936788178892f8148c3f545e14a8 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Wed, 26 Jun 2013 21:52:33 +0200 Subject: [PATCH] pattern.c: pwmled setting refactorization --- firmware/pattern.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/firmware/pattern.c b/firmware/pattern.c index 6692258..ab63e34 100644 --- a/firmware/pattern.c +++ b/firmware/pattern.c @@ -85,15 +85,11 @@ pattern_t off_pattern[] = { PATTERN_END }; -static void led_set_mode(unsigned char n, unsigned char mode) +static void inline pwmleds_set_mode(unsigned char mode) { - if (n == 0) { - pwmled_set_mode(0, mode & 3); - pwmled_set_mode(1, (mode >> 2) & 1); - pwmled_set_mode(2, (mode >> 3) & 3); - } else if (n < N_LEDS) { - gpio_set(n - 1, mode); - } + pwmled_set_mode(0, mode & 3); + pwmled_set_mode(1, (mode >> 2) & 1); + pwmled_set_mode(2, (mode >> 3) & 3); } void led_set_pattern(unsigned char n, pattern_t *pattern) @@ -105,7 +101,11 @@ void led_set_pattern(unsigned char n, pattern_t *pattern) led_counters[n] = fibonacci[pattern->duration_fib]; - led_set_mode(n, pattern->mode); + if (n == 0) { + pwmleds_set_mode(pattern->mode); + } else if (n < N_LEDS) { + gpio_set(n - 1, pattern->mode); + } } void init_pattern() -- 2.43.5