Skip to content

Commit

Permalink
Merge pull request #71 from qmsk/leds-test-chase-count
Browse files Browse the repository at this point in the history
leds: set chase test mode framerate by total pixel count
  • Loading branch information
SpComb authored Feb 8, 2024
2 parents 1de02f0 + 65a2033 commit acf0654
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions components/leds/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
#define TEST_FRAME_TICKS (1000 / TEST_FRAME_RATE / portTICK_RATE_MS)

#define TEST_MODE_COLOR_FRAMES 25
#define TEST_MODE_CHASE_FRAMES 2
#define TEST_MODE_CHASE_TICKS_TOTAL (10 * 1000 / portTICK_RATE_MS) // 10s for all pixels, minimum 1 tick per pixel
#define TEST_MODE_RAINBOW_FADEIN_FRAMES 25

int leds_test_chase_frame(struct leds *leds, unsigned frame, struct leds_color color)
{
unsigned count = leds->options.count;
unsigned ticks = TEST_MODE_CHASE_TICKS_TOTAL / count;
int err;

switch (leds_parameter_type(leds)) {
Expand All @@ -37,15 +39,11 @@ int leds_test_chase_frame(struct leds *leds, unsigned frame, struct leds_color c
return err;
}

if (frame >= leds->options.count) {
return 0; // end
}

if ((err = leds_set(leds, frame, color))) {
if ((err = leds_set(leds, frame % count, color))) {
return err;
}

return TEST_FRAME_TICKS * TEST_MODE_CHASE_FRAMES;
return ticks > 0 ? ticks : 1;
}

int leds_test_color_frame(struct leds *leds, unsigned frame, struct leds_color color)
Expand Down

0 comments on commit acf0654

Please sign in to comment.