diff --git a/firmware/src/boards/cynthion_d11/led.c b/firmware/src/boards/cynthion_d11/led.c index 22ab9f5..a8e4fac 100644 --- a/firmware/src/boards/cynthion_d11/led.c +++ b/firmware/src/boards/cynthion_d11/led.c @@ -25,16 +25,6 @@ static blink_pattern_t blink_pattern = BLINK_IDLE; -/** - * Sets the active LED blink pattern. - */ -void led_set_blink_pattern(blink_pattern_t pattern) -{ - blink_pattern = pattern; - leds_off(); -} - - /** * Sets up each of the LEDs for use. */ @@ -125,6 +115,24 @@ static void display_led_number(uint8_t number) } +/** + * Sets the active LED blink pattern. + */ +void led_set_blink_pattern(blink_pattern_t pattern) +{ + blink_pattern = pattern; + leds_off(); + // Values of 0 to 31 should be set immediately as static patterns. + if (blink_pattern < 32) { + for (int i = 0; i < 5; i++) { + if (blink_pattern & (1 << i)) { + display_led_number(i); + } + } + } +} + + /** * Task that handles blinking the heartbeat LED. */ @@ -134,6 +142,11 @@ void heartbeat_task(void) static uint8_t active_led = 0; static bool count_up = true; + // Values of 0 to 31 define static patterns only. + if (blink_pattern < 32) { + return; + } + // Blink every interval ms if ( board_millis() - start_ms < blink_pattern) return; // not enough time start_ms += blink_pattern; diff --git a/firmware/src/boards/cynthion_d21/led.c b/firmware/src/boards/cynthion_d21/led.c index 44e7161..05470c3 100644 --- a/firmware/src/boards/cynthion_d21/led.c +++ b/firmware/src/boards/cynthion_d21/led.c @@ -25,16 +25,6 @@ static blink_pattern_t blink_pattern = BLINK_IDLE; -/** - * Sets the active LED blink pattern. - */ -void led_set_blink_pattern(blink_pattern_t pattern) -{ - blink_pattern = pattern; - leds_off(); -} - - /** * Sets up each of the LEDs for use. */ @@ -112,6 +102,24 @@ static void display_led_number(uint8_t number) } +/** + * Sets the active LED blink pattern. + */ +void led_set_blink_pattern(blink_pattern_t pattern) +{ + blink_pattern = pattern; + leds_off(); + // Values of 0 to 31 should be set immediately as static patterns. + if (blink_pattern < 32) { + for (int i = 0; i < 5; i++) { + if (blink_pattern & (1 << i)) { + display_led_number(i); + } + } + } +} + + /** * Task that handles blinking the heartbeat LED. */ @@ -121,6 +129,11 @@ void heartbeat_task(void) static uint8_t active_led = 0; static bool count_up = true; + // Values of 0 to 31 define static patterns only. + if (blink_pattern < 32) { + return; + } + // Blink every interval ms if ( board_millis() - start_ms < blink_pattern) return; // not enough time start_ms += blink_pattern; diff --git a/firmware/src/led.h b/firmware/src/led.h index 70ed09b..c643089 100644 --- a/firmware/src/led.h +++ b/firmware/src/led.h @@ -13,7 +13,13 @@ #include /** - * Different blink patterns with different semantic meanings. + * LED patterns. + * + * Values 0 to 31 will be interpreted as static bitmasks, and can be used + * to turn on specific combinations of LEDs in a fixed pattern. + * + * Other values as defined in this enum will produce dynamic blink patterns, + * with different semantic meanings. */ typedef enum { BLINK_IDLE = 500, @@ -27,6 +33,8 @@ typedef enum { /** * Sets the active LED blink pattern. + * + * See @ref blink_pattern_t for the meaning of the pattern argument. */ void led_set_blink_pattern(blink_pattern_t pattern);