Skip to content

Fix LedWiz lower half of brightness range emitting no light#57

Draft
dynajoe wants to merge 1 commit into
vpinball:masterfrom
dynajoe:fix/lw-switch-any-nonzero
Draft

Fix LedWiz lower half of brightness range emitting no light#57
dynajoe wants to merge 1 commit into
vpinball:masterfrom
dynajoe:fix/lw-switch-any-nonzero

Conversation

@dynajoe

@dynajoe dynajoe commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Fix

UpdateOutputs set the SBA on/off switch bit only for output values > 127, while the PBA brightness is set for the actual value. So every output value 1–127 gets a brightness but leaves the port switched off — no light. Change the threshold to > 0.

Why it matters

A hard cliff at 128 — the entire lower half of the range emits no light, so every DOF fade loses its bottom half and dim/ramp effects vanish. C# switches on for any nonzero value: byte V = ByteToLedWizValue[Value]; bool S = (V != 0);, and the active table maps [1..255] all to ≥ 1. Affects every LedWiz — the most common DOF controller.

Found by diffing against the DirectOutput C# source.

@dynajoe

dynajoe commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Heads-up for reviewers/testers: this is verified against the DirectOutput C# source — the active ByteToLedWizValue table maps [1..255] all to ≥ 1, so C#'s S = (V != 0) switches the output on for any nonzero value, versus the C++ > 127. But I don't have a LedWiz to bench-test it, so I'd rather not have it merged purely on a code read.

Could a LedWiz owner confirm on hardware? Quick check with this branch:

  • Set an output to a low value (say 1–100) via DOF and verify the LED/output now lights — before this change, anything ≤ 127 stayed dark.
  • A fade/ramp should no longer cut out at the halfway point.

Happy to adjust if it behaves differently than the C# leads me to expect.

@jsm174

jsm174 commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Hello. Thanks for the PR!

Converting this to draft as per the contributing rules. (I was behind in getting them added as was just done in Visual Pinball).

It's going to take time to review these. libdof is currently is use by several users with a variety of devices, and we have yet to receive issues about this.

Also this definitely needs thorough testing with the actual hardware.

@jsm174
jsm174 marked this pull request as draft July 5, 2026 18:09
UpdateOutputs set the SBA on/off switch bit only for output values > 127, while the PBA brightness is set for the actual value -- so every value 1-127 got a brightness but the port stayed switched OFF (no light; a hard cliff at 128, lower half of every fade lost). C# switches on for any nonzero value (ByteToLedWizValue[1]=1, S = V != 0). Use > 0 to match.
@dynajoe
dynajoe force-pushed the fix/lw-switch-any-nonzero branch from e548734 to dfd6578 Compare July 15, 2026 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants