WLED icon indicating copy to clipboard operation
WLED copied to clipboard

Refactored DMX effect mode + new segment controls

Open mxklb opened this issue 2 years ago • 11 comments

Abstract

This enables WLED to control segments via DMX with Effect modes ++ introduces some additional refactoring.

  1. Added missing third color RGBW channels.
  2. Added missing effect option channel (mirror and reverse).
  3. Existing Effect mode is clearly divided into 15|18 DMX channel modes (+ whites).
  4. New Effect Segment modes are introduced to control segments by 15|18 DMX channels.
  5. Hidden "feature" Presets is no longer hidden & less restrictive according to its DMX start address.

For documentation

  • Existing Effect mode now controls 15 channels (including third color RGB, without whites):

    [bri,effectCurrent,effectSpeed,effectIntensity,effectPalette,effectOption,R,G,B,R2,G2,B2,R3,G3,B3]

  • A new Effect + White mode controls 18 channels (same as above + including white channels [..,W,W2,W3]).

  • Effect Segment is the same as Effect with 15 channels per segment; expect channel 1 = "Segment Dimmer".

  • Effect Segment + White is the same as Effect Segment incl whites, so it uses 18 DMX channels per segment.

  • Preset mode triggers presets by sending preset numbers and controls brightness = 2 DMX channel.

The effectOption channel is divided into 4 macro parts to control mirror and reverse states as follows:

value mirror reverse
0..63 false false none
64..127 false true reverse
128..191 true false mirror
192..255 true true mirror & reverse

Segment modes introduce an additional DMX segment spacing. If spacing is s = 0 subsequent DMX addresses for all segments are created. When s > 0 a gap of s DMX addresses between segments is used. This feature is good to place segments (= DMX fixtures) inside DMX universe more efficient.

Segment DMX Start Address (i) = DMXAddress + i * (dmxEffectChannels + DMXSegmentSpacing)

Where DMXAddress = start address as configured in UI, dmxEffectChannels = 15|18 depending on selected segment mode, DMXSegmentSpacing = address gap as configured in UI and i is the index of each segment as existing.

As existing Effect mode, these modes are not realtime, and only support 1 universe as configured in UI.

Note: 1 DMX universe = max 512 DMX addresses. So max number of segments depends on selected segment mode and configured DMX segment spacing. To calculate how many segments can be controlled via DMX:

Max segments = floor[ (512 - DMXAddress) / (dmxEffectChannels + DMXSegmentSpacing) ]

PR notes

I tested everything expect Preset. Everything shall work as written here. Please test and provide some feedback!

According to #2325 there will be some more DMX changes to come in future. I decided to provide this PR as is, because it does not interfere with the changes made for the other DMX modes mentioned. Maybe we merge this first, because it's finished from my point of view. We may provide further DMX changes in another PR. Alternate I could pull changes from #2325 into here to provide a more feature rich DMX advancement in a whole, if I find time to .. TBD

IMO separating this from the other DMX changes discussed in #2325 does no harm, it shall be merged anyhow.

mxklb avatar Nov 19 '22 14:11 mxklb

@blazoncek thank you for the review. I pushed changes that shall resolve your comments as suggested (hopefully).

mxklb avatar Nov 23 '22 22:11 mxklb

Question: There is also a 3rd color for segments. Maybe 3rd RGBW would also be good to add to these Effect control modes, what do you think? I already missed it while using some effects .. This would need additional 3|4 DMX channels per mode, so 11+3=14 or 13+4=17 (per segment). I also was thinking about enabling Reverse Direction and Mirror Effect within another +1 DMX channel (often DMX lights have such kind of mode switch channels). I think this would make this refactoring even more complete. If you think this would add value to these modes & users, let me know ..

mxklb avatar Nov 23 '22 22:11 mxklb

  • The code now uses setter methods as @blazoncek mentioned (except effect speed & intensity - I couldn't find).
  • Added missing effect option DMX channel (mirror & reverse)
  • Added missing third color RGBW channels.

I tested most of it and it's working as proposed. Finally I don't know if there still should be a 'Legacy Effect Mode', to handle down compatibility using old Effect implementation with '11'|13 DMX channels? Maybe this may gain some value for DMX setups based on old Effect mode. What do you think, shall these old mode still exist to not break some user setups when released? Anyway users should be informed to migrate to refactored modes in release notes. It maybe a good idea to remove the old 'Legacy Effect Mode' within a future release upon .. TBD

It would be nice if someone finds time to test these new modes implemented here and provide some feedback.

mxklb avatar Nov 26 '22 14:11 mxklb

Good job. There are no setters for speed & intensity (and new custom parameters). Please post request for testing in Discord beta-testing channel.

blazoncek avatar Nov 26 '22 15:11 blazoncek

Beta test request: https://wled.discourse.group/t/dmx-effect-mode-refactoring-beta-testing/6498

mxklb avatar Nov 28 '22 23:11 mxklb

Hi there!

Is this pull where also segment RGB should be implemented? Did not fint it after upload. Because of rekordbox I can test just that out. No effect possibiliti for me.

lorandnagy avatar Dec 06 '22 17:12 lorandnagy

No, there is no realtime RGB segment control in this PR. Only Effect mode refactoring as in description.

mxklb avatar Dec 07 '22 16:12 mxklb

Hi, nice to see you are very busy in the DMX part of WLED:-)

I have a side-question, slightly off-topic but I need a DMX expert so I thought I'd ask here:

the SparkFun DMX output driver does some weird things on non-existing pins, including installation of a timer interrupt that is not needed but may cause trouble. When building WLED for new MCUs like -S3, these parts of the driver causes a watchdog reset, see issue #2928 .

I'm thinking of removing the DMX receive code from the driver, as currently it's unneeded code that seems to cause strange side-effects.This will only affect DMX receive from physical connections; DMX output and DMX over network will not change.

Can you confirm that the DMX receiver code from the sparkfun driver is not needed, and will not be needed for the changes you are working on?

softhack007 avatar Dec 09 '22 21:12 softhack007

Can you confirm that the DMX receiver code from the sparkfun driver is not needed, and will not be needed for the changes you are working on?

As you see in diff to upstream, changes only act on e131/artnet package data. Changes to DMX receiver code shall not impact any changes made in this PR. But keep in mind, with MAX485 DMX hardware plugged, wired DMX cable input would (if implemented) of caues use the same processing code for DMX signals as e131/artnet implementation. So if in near future someone want to enable DMX cable input it will use changes of this PR as well.

mxklb avatar Dec 10 '22 14:12 mxklb

Beta tested successful: https://wled.discourse.group/t/dmx-effect-mode-refactoring-beta-testing/6498/29?u=mxklb

mxklb avatar Dec 23 '22 20:12 mxklb

I agree with the merge. @Aircoookie @softhack007 will you do the honours?

blazoncek avatar Dec 23 '22 20:12 blazoncek

Is there anything missing or I can do?

mxklb avatar Jan 15 '23 15:01 mxklb

Is there anything missing or I can do?

Sorry, this PR got a bit out-of-sight for me over xmas/new year. I'll cross-read the code - and in case nothing critical pops up, i'll agree to merge.

softhack007 avatar Jan 15 '23 16:01 softhack007

I lack any DMX HW so can't test this but code looks ok to me. No objections, approved.

blazoncek avatar Jan 15 '23 16:01 blazoncek

It's tested by myself && in https://wled.discourse.group/t/dmx-effect-mode-refactoring-beta-testing

As far as we haven't missed something, it's working exactly as described above. IMO it's save to merge ..

mxklb avatar Jan 16 '23 21:01 mxklb

https://kno.wled.ge/interfaces/e1.31-dmx > 0.14.0-b1 has to be updated, check docs above to describe the new modes ..

mxklb avatar Jan 16 '23 23:01 mxklb

@mxklb please make a PR with updated content to WLED-docs

blazoncek avatar Jan 17 '23 06:01 blazoncek

check out https://github.com/Aircoookie/WLED-Docs/pull/106

mxklb avatar Jan 17 '23 22:01 mxklb