]> www.fi.muni.cz Git - bike-lights.git/commitdiff
pattern.c: pwmled setting refactorization
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Wed, 26 Jun 2013 19:52:33 +0000 (21:52 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Wed, 26 Jun 2013 20:03:38 +0000 (22:03 +0200)
firmware/pattern.c

index 669225860c4d11583fba63693e653ecc60fe063e..ab63e3482e3516cb69577fcfb1240aa9793afd21 100644 (file)
@@ -85,15 +85,11 @@ pattern_t off_pattern[] = {
        PATTERN_END
 };
 
        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)
 }
 
 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_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()
 }
 
 void init_pattern()