]> www.fi.muni.cz Git - bike-lights.git/blobdiff - pattern.c
patterns modified
[bike-lights.git] / pattern.c
index 386f9df9938ea959f3ca83a2f3b6e5b6ee46830c..8552240d304165b2dd0378f4b88ea6b2cc083a32 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -1,3 +1,5 @@
+#include <avr/io.h>
+
 #include "lights.h"
 
 typedef struct {
@@ -10,13 +12,62 @@ static pattern_t *led_patterns[N_LEDS];
 
 #define PATTERN_END { 0, 0 }
 pattern_t off_pattern[] = {
-       { 0, 5 },
+       { 0, 0x1F },
        PATTERN_END
 };
 
 pattern_t blink_pattern[] = {
-       { 1, 5 },
-       { 0, 5 },
+       { 1, 0x4 },
+       { 0, 0x8 },
+       PATTERN_END
+};
+
+pattern_t mode1_pattern[] = {
+       { 1, 0x1F },
+       PATTERN_END
+};
+
+pattern_t boot_pattern[] = {
+       { 1, 0x6 },
+       { 0, 0x6 },
+       { 1, 0x3 },
+       { 0, 0x3 },
+       { 1, 0x2 },
+       { 0, 0x2 },
+       { 1, 0x1 },
+       { 0, 0x1 },
+       { 1, 0x1 },
+       { 0, 0x1 },
+       { 1, 0x1 },
+       { 0, 0x1 },
+       { 1, 0x1 },
+       { 0, 0x1 },
+       { 1, 0x10 },
+       { 0, 0x10 },
+       PATTERN_END
+};
+
+pattern_t pattern_num[] = {
+       { 1, 0x1 }, /* 10 */
+       { 0, 0x4 },
+       { 1, 0x1 }, /*  9 */
+       { 0, 0x4 },
+       { 1, 0x1 }, /*  8 */
+       { 0, 0x4 },
+       { 1, 0x1 }, /*  7 */
+       { 0, 0x4 },
+       { 1, 0x1 }, /*  6 */
+       { 0, 0x4 },
+       { 1, 0x1 }, /*  5 */
+       { 0, 0x4 },
+       { 1, 0x1 }, /*  4 */
+       { 0, 0x4 },
+       { 1, 0x1 }, /*  3 */
+       { 0, 0x4 },
+       { 1, 0x1 }, /*  2 */
+       { 0, 0x4 },
+       { 1, 0x1 }, /*  1 */
+       { 0, 0x1F },
        PATTERN_END
 };
 
@@ -28,6 +79,29 @@ void pattern_init()
                led_counters[i] = 0;
                led_patterns[i] = off_pattern;
        }
+       led_patterns[N_PWMLEDS] = boot_pattern;
+       led_counters[N_PWMLEDS] = boot_pattern->duration;
+       gpio_set(GPIO_LED2, 1);
+}
+
+static inline pattern_t *pattern_select(unsigned char n)
+{
+       return pattern_num + sizeof(pattern_num)/sizeof(pattern_t)
+               - 1 - 2*(1+ambient_zone);;
+}
+
+static void inline led_off(unsigned char n)
+{
+       if (n == N_PWMLEDS) {
+               gpio_set(GPIO_LED2, 0);
+       }
+}
+
+static void inline led_set_level(unsigned char n, unsigned char level)
+{
+       if (n == N_PWMLEDS) {
+               gpio_set(GPIO_LED2, 1);
+       }
 }
 
 void patterns_next_tick()