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.
This PR rewrites the code to use LED indices and channels rather than the raw pointer. That should solve any strange issues caused by violating strict aliasing (i.e. accessing the LED data via memory pointer rather than via the struct members).
I've also added a "grouping" feature, which will distribute LED data if the received amount is a factor of the number of LEDs in the strip. For example, if there are 80 LEDs in the strip and data for 40 LEDs is received, the data will be copied so that the entire strip is lit, with each virtual LED mapped to groups of 2 physical LEDs. Receiving 20 LEDs will map to groups of 4, 10 LEDs to groups of 8, 5 LEDs to groups of 16, etc. etc.
For setups with a lot of LEDs this allows you to send less data to the device, increasing throughput and therefore framerate at the expense of resolution. This is disabled by default, and can be enabled by uncommenting the relevant define.
This also includes a few minor changes to clean up the code a bit: removing a few global variables, some redundant macros, and more flexible timekeeping definitions.