]> www.fi.muni.cz Git - bike-lights.git/commitdiff
number pattern
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Wed, 29 Aug 2012 22:41:52 +0000 (00:41 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Fri, 31 Aug 2012 21:08:11 +0000 (23:08 +0200)
pattern.c

index 06911707d059b5a05def1268c280df4a7238665b..c2942e59c9bdbda3c7693e526b31238d82b5f7f0 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -91,6 +91,15 @@ void pattern_init()
        test_running = 0;
 }
 
+static pattern_t *number_pattern(unsigned char num)
+{
+       if (num >= 9)
+               num = 9;
+
+       return pattern_num + sizeof(pattern_num)/sizeof(pattern_t)
+               - 1 - 2*num;
+}
+
 static inline pattern_t *pattern_select(unsigned char n)
 {
        if (n < N_PWMLEDS && !pwmled_enabled(n))
@@ -107,8 +116,7 @@ static inline pattern_t *pattern_select(unsigned char n)
                        return mode1_pattern;
                }
        }
-       return pattern_num + sizeof(pattern_num)/sizeof(pattern_t)
-               - 1 - 2*(1+ambient_zone);
+       return number_pattern(1+ambient_zone);
 }
 
 static void led_set_mode(unsigned char n, unsigned char mode)