X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=bike-lights.git;a=blobdiff_plain;f=pattern.c;h=0245c3b679cb8e08080b67c1f08f38193cf9b02c;hp=386f9df9938ea959f3ca83a2f3b6e5b6ee46830c;hb=dbbcaf6e61197990ec21a702102c81deb66f2110;hpb=72d28dc3eb9192afbbe48ad46039b70a20c1ff49 diff --git a/pattern.c b/pattern.c index 386f9df..0245c3b 100644 --- a/pattern.c +++ b/pattern.c @@ -1,3 +1,5 @@ +#include + #include "lights.h" typedef struct { @@ -15,8 +17,30 @@ pattern_t off_pattern[] = { }; pattern_t blink_pattern[] = { - { 1, 5 }, - { 0, 5 }, + { 1, 0x4 }, + { 0, 0x8 }, + PATTERN_END +}; + +pattern_t pattern_num[] = { + { 1, 0x1 }, + { 0, 0x4 }, + { 1, 0x1 }, + { 0, 0x4 }, + { 1, 0x1 }, + { 0, 0x4 }, + { 1, 0x1 }, + { 0, 0x4 }, + { 1, 0x1 }, + { 0, 0x4 }, + { 1, 0x1 }, + { 0, 0x4 }, + { 1, 0x1 }, + { 0, 0x4 }, + { 1, 0x1 }, + { 0, 0x4 }, + { 1, 0x1 }, + { 0, 0x1F }, PATTERN_END }; @@ -30,6 +54,27 @@ void pattern_init() } } +static inline pattern_t *pattern_select(unsigned char n) +{ + log_byte(ambient_zone); + 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() { unsigned char i;