Skip to content

Commit

Permalink
Support static bitmasks as LED patterns.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinling committed Sep 7, 2023
1 parent 799b3a2 commit 300f083
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
29 changes: 19 additions & 10 deletions firmware/src/boards/luna_d11/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -125,6 +115,21 @@ 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();
if (blink_pattern < 32) {
for (int i = 0; i < 5; i++) {
display_led_number(i);
}
}
}


/**
* Task that handles blinking the heartbeat LED.
*/
Expand All @@ -134,6 +139,10 @@ void heartbeat_task(void)
static uint8_t active_led = 0;
static bool count_up = true;

if (blink_pattern < 32) {
return;
}

// Blink every interval ms
if ( board_millis() - start_ms < blink_pattern) return; // not enough time
start_ms += blink_pattern;
Expand Down
29 changes: 19 additions & 10 deletions firmware/src/boards/luna_d21/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -112,6 +102,21 @@ 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();
if (blink_pattern < 32) {
for (int i = 0; i < 5; i++) {
display_led_number(i);
}
}
}


/**
* Task that handles blinking the heartbeat LED.
*/
Expand All @@ -121,6 +126,10 @@ void heartbeat_task(void)
static uint8_t active_led = 0;
static bool count_up = true;

if (blink_pattern < 32) {
return;
}

// Blink every interval ms
if ( board_millis() - start_ms < blink_pattern) return; // not enough time
start_ms += blink_pattern;
Expand Down

0 comments on commit 300f083

Please sign in to comment.