Skip to content
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

fix(ws2812): Bit order of WS2812 data stream #4400

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

frank26080115
Copy link
Contributor

Fixes #4399

(bit order of data sent to WS2812 was LSB first, which is wrong)

Summary of changes:

Sends MSB first, as per WS2812 datasheet

@pfeerick
Copy link
Member

Indeed it is... as you say, WS2812 is MSB order, not LSB... lol!

@pfeerick
Copy link
Member

btw, can you add the test lua script source? ;)

@pfeerick pfeerick added this to the 2.10 milestone Dec 10, 2023
@pfeerick pfeerick added the bug 🪲 Something isn't working label Dec 10, 2023
@pfeerick pfeerick changed the title fixed bit order of WS2812 data stream fix(ws2812): Bit order of WS2812 data stream Dec 10, 2023
@frank26080115
Copy link
Contributor Author

local function init()
    police_oldtime = getTime()
    police_cycle = 0
    x = 0
    y = 0
end

local function run()
  for i=0, LED_STRIP_LENGTH - 1, 1
  do
    if (y == 0) then
      setRGBLedColor(i, x, 0, 0)
    elseif (y == 1) then
      setRGBLedColor(i, 0, x, 0)
    elseif (y == 2) then
      setRGBLedColor(i, 0, 0, x)
    end
  end
  if ((getTime() - police_oldtime) > 8) then
    police_oldtime = getTime()
    police_cycle = 1 - police_cycle
    x = x + 1
    if (x > 255) then
      x = 0
      y = y + 1
      if (y > 2) then
        y = 0
      end
    end
    applyRGBLedColors()
  end
end

local function background()
  -- Called periodically while the Special Function switch is off
end

return { run=run, background=background, init=init }

@3djc
Copy link
Collaborator

3djc commented Dec 10, 2023

lol, because I did set randomly value at 50 because I was indoor and didn't want it bright, we didn't spot it. Thanks for the fix

@richardclli
Copy link
Collaborator

richardclli commented Dec 11, 2023

I spot strange behavior when I trying to play around the LUA for different brightness, but not dig deep into the problem, nice catch for a fix.

@pfeerick pfeerick merged commit 071193c into EdgeTX:main Dec 11, 2023
39 checks passed
zyren added a commit to zyren/edgetx-sdcard that referenced this pull request Dec 11, 2023
…o make them more splendid.

Regarding EdgeTX/edgetx#4400, it made the brightness and RGB transitions of the lights very smooth, creating an especially splendid and stunning effect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RGB LED strip bit order is wrong
4 participants