X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=tinyboard.git;a=blobdiff_plain;f=projects%2Fstep-up%2Fcontrol.c;h=4ffb71cf631310b98de786e785b9e02dccf7092c;hp=97a23cbb7d3e8b2033098cc5081690b42d11e6a9;hb=HEAD;hpb=678dd60ed95c50064bf8266f71ecf1b026dc3877 diff --git a/projects/step-up/control.c b/projects/step-up/control.c index 97a23cb..4ffb71c 100644 --- a/projects/step-up/control.c +++ b/projects/step-up/control.c @@ -3,25 +3,62 @@ #include "lights.h" -static pattern_t on_pattern [] = { - { 1, 0x10 }, - PATTERN_END +static unsigned char on_pattern[] = { + /* 8 bits */ + 0b11111111, }; -static pattern_t blink_pattern[] = { - { 1, 0x1 }, - { 0, 0x2 }, - { 1, 0x1 }, - { 0, 0x8 }, - { 1, 0x1 }, - { 0, 0x8 }, - PATTERN_END +#define IVA + +static unsigned char blink_pattern[] = { +#ifdef IVA + /* ../...-/..-/.../-.-/.-// */ + /* 137 bits, 19.7% on */ + 0b10000100, + 0b00000000, + 0b10000100, + 0b00100001, + 0b11000000, + 0b00001000, + 0b01000011, + 0b10000000, + 0b00010000, + 0b10000100, + 0b00000000, + 0b11100001, + 0b00001110, + 0b00000000, + 0b01000011, + 0b10000000, + 0b00000000, + 0b00000000, +#else /* FILIP */ + /* ..-./../.-../../.--.// */ + /* 124 bits, 19.4% on */ + 0b10000100, + 0b00111000, + 0b01000000, + 0b00001000, + 0b01000000, + 0b00001000, + 0b01110000, + 0b10000100, + 0b00000000, + 0b10000100, + 0b00000000, + 0b10000111, + 0b00001110, + 0b00010000, + 0b00000000, + 0b00000000, +#endif }; -static pattern_t slow_pattern[] = { - { 1, 0x1 }, - { 0, 0x10 }, - PATTERN_END +static unsigned char slow_pattern[] = { + /* 24 bits */ + 0b00010000, + 0b00000000, + 0b00000000, }; static unsigned char light_mode; @@ -80,35 +117,36 @@ void long_press() power_down(); } -pattern_t *pwmled_pattern_select() +void pwmled_pattern_select(unsigned char led) { - if (e.shutdown_in_progress) - return NULL; - - if (e.battery_low) - return slow_pattern; - - if (light_mode == 0) { - return slow_pattern; + if (e.shutdown_in_progress) { + led_set_pattern(led, 0, 0, NULL); + } else if (e.battery_low) { + led_set_pattern(led, 24, 0, slow_pattern); + } else if (light_mode == 0) { + led_set_pattern(led, 24, 0, slow_pattern); } else if (light_mode < N_PWMLED_MODES) { - return blink_pattern; +#ifdef IVA + led_set_pattern(led, 137, 0, blink_pattern); +#else /* FILIP */ + led_set_pattern(led, 124, 0, blink_pattern); +#endif } else { - return on_pattern; + led_set_pattern(led, 8, 0, on_pattern); } } -pattern_t *status_led_pattern_select() +void status_led_pattern_select(unsigned char led) { - if (e.shutdown_in_progress) - return on_pattern; - - if (e.pwmled_error) - return number_pattern(3, 1); - - if (e.battery_low) - return number_pattern(1, 1); - - return number_pattern(battery_gauge(), 0); + if (e.shutdown_in_progress) { + led_set_pattern(led, 8, 0, on_pattern); + } else if (e.pwmled_error) { + led_set_number_pattern(led, 1, 1); + } else if (e.battery_low) { + led_set_number_pattern(led, 1, 1); + } else { + led_set_number_pattern(led, battery_gauge(), 0); + } } #if 0