-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Core] Add Pixel Flow RGB matrix effect #15829
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2022 @filterpaper | ||
// SPDX-License-Identifier: GPL-2.0+ | ||
|
||
#ifdef ENABLE_RGB_MATRIX_PIXEL_FLOW | ||
RGB_MATRIX_EFFECT(PIXEL_FLOW) | ||
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
|
||
static bool PIXEL_FLOW(effect_params_t* params) { | ||
// LED state array | ||
static RGB led[DRIVER_LED_TOTAL]; | ||
|
||
static uint32_t wait_timer = 0; | ||
if (wait_timer > g_rgb_timer) { | ||
return false; | ||
} | ||
|
||
inline uint32_t interval(void) { | ||
return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); | ||
} | ||
|
||
if (params->init) { | ||
// Clear LEDs and fill the state array | ||
rgb_matrix_set_color_all(0, 0, 0); | ||
for (uint8_t j = 0; j < DRIVER_LED_TOTAL; ++j) { | ||
led[j] = (random8() & 2) ? (RGB){0,0,0} : hsv_to_rgb((HSV){random8(), qadd8(random8() >> 1, 127), rgb_matrix_config.hsv.v}); | ||
} | ||
} | ||
|
||
RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
// Light LEDs based on state array | ||
for (uint8_t i = led_min; i < led_max; ++i) { | ||
RGB_MATRIX_TEST_LED_FLAGS(); | ||
rgb_matrix_set_color(i, led[i].r, led[i].g, led[i].b); | ||
} | ||
|
||
if (!rgb_matrix_check_finished_leds(led_max)) { | ||
// Shift LED state forward | ||
for (uint8_t j = 0; j < led_max-1; ++j) { | ||
led[j] = led[j+1]; | ||
} | ||
// Fill last LED | ||
led[led_max-1] = (random8() & 2) ? (RGB){0,0,0} : hsv_to_rgb((HSV){random8(), qadd8(random8() >> 1, 127), rgb_matrix_config.hsv.v}); | ||
// Set pulse timer | ||
wait_timer = g_rgb_timer + interval(); | ||
} | ||
|
||
return rgb_matrix_check_finished_leds(led_max); | ||
} | ||
|
||
# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
#endif // ENABLE_RGB_MATRIX_PIXEL_FLOW |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consumption of RAM by this array may be significant (especially if using AVR chips). I wonder whether we should somehow optimize this by making the buffers used by different effects overlap (because at the moment only one effect at a time can run). Note that the
PIXEL_FRACTAL
effect also uses a RAM buffer with a comparable size (that one uses the key matrix size though).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory impact was reviewed with
avr-size
while coding that array table. This PCB uses 58 LEDs and the effect footprint was 178 bytes of data memory:Without PIXEL_FLOW:
WIth PIXEL_FLOW:
Is this a good benchmark for evaluating RAM impact? I can try to rework this to reduce the array at the expense of more code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's revisit a "scratch" buffer for all the effects in a followup PR.