-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Support custom DMX output value #4876
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
base: main
Are you sure you want to change the base?
Changes from all commits
5940087
708c76c
b4d976d
a0ed79b
a6963f0
316ef24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
|
||
//eeprom Version code, enables default settings instead of 0 init on update | ||
#define EEPVER 22 | ||
#define EEPSIZE 2560 //Maximum is 4096 | ||
#define EEPSIZE 2570 //Maximum is 4096 | ||
//0 -> old version, default | ||
//1 -> 0.4p 1711272 and up | ||
//2 -> 0.4p 1711302 and up | ||
|
@@ -343,20 +343,23 @@ void loadSettingsFromEEPROM() | |
//1024-2047 reserved | ||
|
||
#ifdef WLED_ENABLE_DMX | ||
// DMX (2530 - 2549)2535 | ||
// DMX (2530 - 2566)2535,2552 | ||
DMXChannels = EEPROM.read(2530); | ||
DMXGap = EEPROM.read(2531) + ((EEPROM.read(2532) << 8) & 0xFF00); | ||
DMXStart = EEPROM.read(2533) + ((EEPROM.read(2534) << 8) & 0xFF00); | ||
|
||
for (int i=0;i<15;i++) { | ||
for (int i=0;i<MAX_CHANNELS_PER_FIXTURE;i++) { | ||
DMXFixtureMap[i] = EEPROM.read(2535+i); | ||
} //last used: 2549 | ||
DMXStartLED = EEPROM.read(2550); | ||
DMXStartLED = EEPROM.read(2550) + ((EEPROM.read(2551) << 8) & 0xFF00); | ||
for (int i=0;i<MAX_CHANNELS_PER_FIXTURE;i++) { | ||
DMXChannelsValue[i] = EEPROM.read(2552+i); | ||
} //last used: 2566 | ||
Comment on lines
+351
to
+357
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. 💡 Verification agent 🧩 Analysis chainFix legacy DMX EEPROM overlap and DV back-compat (clamp to 15; don’t read DV from EEPROM). Reading Apply: - for (int i=0;i<MAX_CHANNELS_PER_FIXTURE;i++) {
- DMXFixtureMap[i] = EEPROM.read(2535+i);
- } //last used: 2549
- DMXStartLED = EEPROM.read(2550) + ((EEPROM.read(2551) << 8) & 0xFF00);
- for (int i=0;i<MAX_CHANNELS_PER_FIXTURE;i++) {
- DMXChannelsValue[i] = EEPROM.read(2552+i);
- } //last used: 2566
+ // Legacy EEPROM stores exactly 15 fixture-map bytes at 2535..2549
+ constexpr uint8_t LEGACY_DMX_CHANS = 15;
+ const uint8_t n = (MAX_CHANNELS_PER_FIXTURE < LEGACY_DMX_CHANS) ? MAX_CHANNELS_PER_FIXTURE : LEGACY_DMX_CHANS;
+ for (uint8_t i = 0; i < n; i++) {
+ DMXFixtureMap[i] = EEPROM.read(2535 + i);
+ } // last used: 2549
+ for (uint8_t i = n; i < MAX_CHANNELS_PER_FIXTURE; i++) {
+ DMXFixtureMap[i] = 0; // init extras
+ }
+
+ // DMXStartLED: legacy is 8-bit at 2550; optional high byte at 2551 for newer layouts
+ uint16_t dmxStartLo = EEPROM.read(2550);
+ uint16_t dmxStartHi = (lastEEPROMversion > 21) ? EEPROM.read(2551) : 0;
+ DMXStartLED = (dmxStartHi << 8) | dmxStartLo;
+ if (DMXStartLED >= MAX_LEDS) DMXStartLED = (MAX_LEDS ? (MAX_LEDS - 1) : 0);
+
+ // Legacy has no DV bytes. Initialize and migrate legacy "Set to 255" (code 6) -> DV=255
+ for (uint8_t i = 0; i < MAX_CHANNELS_PER_FIXTURE; i++) {
+ if (DMXFixtureMap[i] == 6) {
+ DMXFixtureMap[i] = 0; // "Set to"
+ DMXChannelsValue[i]= 255; // DV
+ } else {
+ DMXChannelsValue[i]= 0; // default DV
+ }
+ } To verify clamping and no overlap: 🏁 Script executed: #!/bin/bash
# MAX_CHANNELS_PER_FIXTURE actual value
rg -nP 'MAX_CHANNELS_PER_FIXTURE' -C2 wled00/const.h
# Ensure no other code assumes DV bytes exist in legacy EEPROM space
rg -nP 'EEPROM\.read\((255[0-9]|256[0-9])\)' -C2 Length of output: 563 🏁 Script executed: head -n 100 wled00/wled_eeprom.cpp Length of output: 2696 🏁 Script executed: #!/bin/bash
sed -n '340,430p' wled00/wled_eeprom.cpp Length of output: 3156 Refactor DMXStartLED back-compat and bounds checking
🤖 Prompt for AI Agents
|
||
#endif | ||
|
||
//Usermod memory | ||
//2551 - 2559 reserved for Usermods, usable by default | ||
//2560 - 2943 usable, NOT reserved (need to increase EEPSIZE accordingly, new WLED core features may override this section) | ||
//2571 - 2579 reserved for Usermods, usable by default | ||
//2580 - 2943 usable, NOT reserved (need to increase EEPSIZE accordingly, new WLED core features may override this section) | ||
//2944 - 3071 reserved for Usermods (need to increase EEPSIZE to 3072 in const.h) | ||
} | ||
|
||
|
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.
What happens to people's existing config that were using case 6 - can we be backwards compatible?
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.
Already pointed out by coderabbitai. Should I implement the solution suggested by it?
Another possibility may be to add a
default
behaviour in the switch-case statement which could write 255 to DMX or something else.Let me know your favorite option.
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.
This should be the last open point (included coderabbitai actionables). Let me know how to proceed.