X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=firmware%2Fcontrol.c;h=7a8d4473c9cf52da0640e3e3870f88cd2de69711;hb=9ae181a57836e6a6e133400f4d88e61feb6481fc;hp=0b842a74dc794f980d0dc2ced63792cb7e009cb0;hpb=647f353f4d8c87c5cf18cae905e9d600cd0e6bcb;p=bike-lights.git diff --git a/firmware/control.c b/firmware/control.c index 0b842a7..7a8d447 100644 --- a/firmware/control.c +++ b/firmware/control.c @@ -30,15 +30,18 @@ static pattern_t panic_pattern[] = { }; pattern_t on1_pattern [] = { - { 1, PATTERN_FOREVER } + { 1, 0x10 }, + PATTERN_END }; static pattern_t on2_pattern [] = { - { 2, PATTERN_FOREVER } + { 2, 0x10 }, + PATTERN_END }; static pattern_t on3_pattern [] = { - { 3, PATTERN_FOREVER } + { 3, 0x10 }, + PATTERN_END }; static pattern_t normal2_pattern[] = { @@ -54,9 +57,9 @@ static pattern_t normal2_pattern[] = { }; static pattern_t normal3_pattern[] = { - { 2, 0x1 }, + { 3, 0x1 }, { 0, 0x1 }, - { 2, 0x1 }, + { 3, 0x1 }, { 0, 0x8 }, { 1, 0x1 }, { 0, 0x1 }, @@ -66,9 +69,9 @@ static pattern_t normal3_pattern[] = { }; static pattern_t normal4_pattern[] = { - { 2, 0x1 }, + { 4, 0x1 }, { 0, 0x1 }, - { 2, 0x1 }, + { 4, 0x1 }, { 0, 0x8 }, { 1, 0x1 }, { 0, 0x1 }, @@ -121,15 +124,16 @@ void set_panic_mode() pattern_t *pwmled0_pattern_select() { - // TODO: battery critical + if (battery_critical) + return on1_pattern; if (towbar_mode) return NULL; switch (ambient_zone) { - case 0: return dim_mode ? NULL : on1_pattern; - case 1: return dim_mode ? NULL : slow2_pattern; - case 2: return dim_mode ? slow3_pattern : slow2_pattern; + case 0: return dim_mode ? NULL : on3_pattern; + case 1: return dim_mode ? NULL : normal3_pattern; + case 2: return dim_mode ? slow3_pattern : normal3_pattern; case 3: default: return dim_mode ? slow3_pattern : normal4_pattern; } @@ -137,7 +141,12 @@ pattern_t *pwmled0_pattern_select() pattern_t *pwmled1_pattern_select() { - // TODO: battery critical +#ifndef TESTING_FW + return NULL; +#else + if (battery_critical) + return on1_pattern; +#endif if (towbar_mode) { switch (ambient_zone) { @@ -161,7 +170,10 @@ pattern_t *pwmled1_pattern_select() pattern_t *pwmled2_pattern_select() { - // TODO: battery critical +#ifndef TESTING_FW + if (battery_critical) + return on1_pattern; +#endif switch (ambient_zone) { case 0: return dim_mode ? on2_pattern : on3_pattern; @@ -179,12 +191,13 @@ pattern_t *status_led_pattern_select() return buttons_setup_status0_pattern_select(); // FIXME: do something sane - return number_pattern(1 + ambient_zone, 1); + return number_pattern(battery_gauge(), 0); } pattern_t *illumination_led_pattern_select() { - // todo: battery critical + if (battery_critical) + return NULL; switch (ambient_zone) { case 0: return dim_mode @@ -194,12 +207,19 @@ pattern_t *illumination_led_pattern_select() ? number_pattern(2, 1) : number_pattern(3, 1); case 2: return dim_mode - ? number_pattern(3, 0) - : number_pattern(4, 0); + ? number_pattern(1, 0) + : number_pattern(2, 0); case 3: default: return dim_mode - ? number_pattern(5, 0) - : number_pattern(6, 0); + ? number_pattern(3, 0) + : number_pattern(4, 0); } } +pattern_t *laser_pattern_select() +{ + if (!dim_mode && ambient_zone <= 1) + return number_pattern(2, 1); + else + return NULL; +}