Staacks / there.oughta.be

Projects featured on my blog at https://there.oughta.be
https://there.oughta.be
GNU General Public License v3.0
99 stars 33 forks source link

using "regular" led hat rather than adafruit? #10

Closed spants closed 3 years ago

spants commented 3 years ago

I get a bit of flicker on the adafruit version so I am trying the https://www.electrodragon.com/product/rgb-matrix-panel-drive-board-raspberry-pi/

It works great with hzeller examples: ie "sudo ./demo -D7 --led-parallel=3 --led-chain=1 --led-gpio-mapping=regular --led-cols=64 --led-rows=64"

But only uses one panel on ledcube. These are the settings that I am using.

//LED Matrix settings
RGBMatrix::Options defaults;
rgb_matrix::RuntimeOptions runtime;
defaults.hardware_mapping = "regular";
defaults.led_rgb_sequence = "RGB";
defaults.pwm_bits = 11;
defaults.pwm_lsb_nanoseconds = 75;
defaults.panel_type = "";
defaults.rows = 64;
defaults.cols = 64;
defaults.chain_length = 1;
defaults.parallel = 3;
runtime.drop_privileges = 0;
runtime.gpio_slowdown = 3;

(I tried default.cols at 192 as well) It works ok in chain mode, just having trouble with parallel mode

Staacks commented 3 years ago

I cannot help much as I do not have that board and I seem to have different panels (as you seem to not need the panel type setting). However, if I understand correctly how parallel panels are set up by the matrix library (haven't tried it), your coordinate system changes as the panels are not aligned "horizontally" (i.e. 192x64) but "vertically" (i.e. 64x192). This needs to be reflected in the OpenGL code, otherwise it still renders to 192x64 and I assume that you get to see only the first 64x64 pixels on the first panel.

I am not entirely sure about how you oriented each panel and how to properly align everything, but if you can still rotate your panels in the cube (not even sure if necessary) the quick and dirty fix would be swapping x and y when mapping the render result to your panel. Simply swap x and y in this line: https://github.com/Staacks/there.oughta.be/blob/f059ae8e6ce0c6703b7a9309f099e71ef8458d63/led-cube/led-cube/cpu-stats-gl.cpp#L574

This only transposes the image (mirrors along the diagonal), so there are small differences like the first thread creating a bulge on the top panel than on the side panel, but those are all differences you would only notice when compared to my video - and you could still change the order of the panels. The "proper" solution would be setting the code to 64x192 and changing the vertex coordinates of the triangles that represent each side to divide the canvas vertically into three parts instead of horizontally. At the moment it simply splits it into thirds along the x coordinate: https://github.com/Staacks/there.oughta.be/blob/f059ae8e6ce0c6703b7a9309f099e71ef8458d63/led-cube/led-cube/cpu-stats-gl.cpp#L82-L124 However, that is mostly just a cleaner way to code it.

spants commented 3 years ago

Thanks for the info. I think that as it works ok now in chain mode, I should keep it that way to avoid moving too much away from your code!.