forked from wled/WLED
-
-
Notifications
You must be signed in to change notification settings - Fork 112
change effect IDs from 8bit to 16bit #270
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
Open
softhack007
wants to merge
15
commits into
mdev
Choose a base branch
from
16bit_effect_IDs
base: mdev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5ed7b44
WIP: change effect IDs from 8bit to 16bit
softhack007 82910a6
small bugfix in addEffect
softhack007 894052f
bugfix for parseNumber
softhack007 68aad22
parseNumber 8bit "r" (random) improvement
softhack007 e7831a4
addEffect: protect legacy "auto" slot 255
softhack007 8cad7aa
extractModeName safety code when mode>255
softhack007 03bb24b
better workaround for UDP
softhack007 733c798
more changes for 16bit mode number compatibility
softhack007 1bf6be4
addEffect improvements
softhack007 ea1b97f
fix for "Upper bound off by one when parsing FX"
softhack007 0ecd460
oopsie
softhack007 b4e900c
effectID: a few more 16bit fixes
softhack007 9bedbd2
comments (ToDo)
softhack007 e0c0bb5
preserve legacy behavior of getVal()
softhack007 16c05d6
four-line-display+rotary: avoid infinite loops
softhack007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -231,7 +231,7 @@ void handleDMXData(uint16_t uni, uint16_t dmxChannels, uint8_t* e131_data, uint8 | |
| return; | ||
|
|
||
| if (e131_data[dataOffset+1] < strip.getModeCount()) | ||
| if (e131_data[dataOffset+1] != seg.mode) seg.setMode( e131_data[dataOffset+1]); | ||
| if (e131_data[dataOffset+1] != seg.mode) seg.setMode( e131_data[dataOffset+1]); // WLEDMM Only one byte for mode, so DMX cannot control effects with id>255 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Todo: update for the dual channel approach |
||
| if (e131_data[dataOffset+2] != seg.speed) seg.speed = e131_data[dataOffset+2]; | ||
| if (e131_data[dataOffset+3] != seg.intensity) seg.intensity = e131_data[dataOffset+3]; | ||
| if (e131_data[dataOffset+4] != seg.palette) seg.setPalette(e131_data[dataOffset+4]); | ||
|
|
||
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
Not 16‑bit safe: byte index arrays and uint8_t loops will break >255 modes.
Apply this minimal refactor to make the UI 16‑bit safe:
Also update re_qstringCmp to read uint16_t indices:
This prevents overflow and enables selecting effects beyond 255.
🏁 Script executed:
Length of output: 3045
🏁 Script executed:
Length of output: 4375
🏁 Script executed:
Length of output: 6357
Make mode/palette indices and related loops 16-bit safe
byte *modes_alpha_indexes/byte *palettes_alpha_indexestouint16_t *.byte *re_initIndexArray(int numModes)→uint16_t *re_initIndexArray(uint16_t numModes)void re_sortModes(const char **modeNames, byte *indexes, int count, int numSkip)→void re_sortModes(const char **modeNames, uint16_t *indexes, uint16_t count, uint16_t numSkip)re_sortModes, useqsort(..., sizeof(uint16_t), re_qstringCmp)and cast inre_qstringCmpfrombyte*toconst uint16_t*.for (uint8_t i = 0; i < strip.getModeCount(); i++)and similar palette loops withfor (uint16_t i = 0; i < strip.getModeCount(); i++)to avoid overflow when counts exceed 255.This ensures arrays, loops, and sorting handle >255 modes/palettes without truncation or wrap-around.
🤖 Prompt for AI Agents
Uh oh!
There was an error while loading. Please reload this page.
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.
@coderabbitai sorry, this is unrelated. Mode IDs are now 16bit, but palette ID (and preset IDs, too) remain as 8bit.
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.
@softhack007 You’re right—thanks for the correction. Let’s scope the change strictly to modes and leave palettes 8-bit. Here’s a minimal patch that makes only the mode-side 16-bit safe while keeping palette indices and arrays as byte.
Result:
If you prefer, I can split the new 16-bit helpers into a small .cpp to keep the header slimmer.
✏️ Learnings added