bitfocus / loupedeck-ct

Loupedeck CT Node.js module
29 stars 3 forks source link

Pixel buffer memory layout is 5-6-5, not 5-3-5 #3

Open Corion opened 4 years ago

Corion commented 4 years ago

Hi all,

thanks again for your very helpful Javascript code!

I'm playing around with a Loupedeck CT myself and documented the issue for Lua as well ( https://github.com/CommandPost/CommandPost/issues/2369 ).

The pixel buffer memory layout is 5-6-5 r-g-b , and the bytes are stored little-endian. The code in index.js calculates the number as 5-5-3 r-b-g , big-endian. The upper "unused" three bits of the number belong to green.

I can't run your code, so I have to make vague suggestions here, but I think the two changes should be:

  1. Change the rgb2int() function to return a 5-6-5 number.
  2. Write that number as little-endian byte sequence instead of big-endian byte sequence.
haakonnessjoen commented 4 years ago

Are you sure about this? I am pretty sure we tested every bit, and 3 of them was doing nothing, hence 5,5,3. Are you getting results on all the bits? Wonder how we were seeing something different then. And the colors reproduced by our rgb2col is producing images nicely. I don't have it in front of me to test now though.

Corion commented 4 years ago

The code I have works on my Loupedeck CT, but maybe I have a different firmware version. I have only talked to the device via Websocket (Linux) and never updated it or connected it to the official (Windows) app.

The colours on "your" version lack 3 bits of green, so maybe try setting the high bits too in the final 16-bit numbers, to see if you get more levels of green that way.

latenitefilms commented 4 years ago

FWIW - All Loupedeck CT's are currently all running the same firmware version. I don't believe there's been a firmware update yet - although one is due at some point soon to solve the macOS sleep issue.

latenitefilms commented 4 years ago

Here's the fix we applied to CommandPost which seemed to work:

https://github.com/CommandPost/CommandPost-App/commit/fba903bf3f3685b8998b38b6e4f63d9c14b2ae66