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

Feature remap mapper #1478

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

ledvinap
Copy link
Contributor

@ledvinap ledvinap commented Nov 1, 2022

(for discussion, needs some polishing, needs testing)

This PR implements universal mapper - each segment is mapped to arbitrary position and orientation on canvas

My use case is two separate displays connected as chains, each with different geometry. But it shall handle almost all possible panel configuration

Syntax is:

--led-pixel-mapper='Remap:<new_width>,<new_height>|<panel0_x>,<panel0_y><panel0_orientation>|<panel1_x>,<panel1_y><panel1_orientation>'

new_width, new_height - size of created canvas. It can be both larger and smaller than old canvas.
panel0_x, panel0_y - upper-left corner of remapped panel
panel0_orientation - n,s,e,w for panel orientation, x to discard panel

Exactly one entry must be specified for each LED panel (chain * parallel entries).
Mapping may be partially outside new canvas (maybe useful for something?)
Unused positions must be discarded (0,0x) - useful if chains are of different length
It is possible let some canvas space unused (no panel mapped to it). Writes to this area will be ignored.

For example:

 --led-cols=16 --led-rows=8 --led-chain=5 --led-parallel=2 --led-pixel-mapper='Remap:40,32|0,0e|8,0e|16,0e|24,0e|32,0e|0,16n|16,16n|0,24n|16,24n|0,0x'

First chain is 5 panels in line, top of the panel is pointing right, 40x16 pixels
Second chain is 2x2 square, panels pointing up, 32x16 pixels, top-left is 0,16 in canvas
Last panel on second chain is not used

1 2 3 4 5
1 2 3 4 5
6 6 7 7 
8 8 9 9

I'll add some documentation if there is interest in this feature

@ledvinap
Copy link
Contributor Author

ledvinap commented Nov 4, 2022

Fixed panel ordering, panels are now counted from Raspberry (as in example above)

@iamlegio
Copy link

dear ledvinap,

I got the mapper to register and now I am in the process of understanding how to map it properly:

I have 6x8 modules, standing 16 width 32 height. So that would be like this?
MatrixRemap

Thank you for your help!
Thomas

@ledvinap
Copy link
Contributor Author

Yes, that's how it should work. You need to map all panels (end of chain 3), so you must discard last 6 panels

 --led-pixel-mapper='Remap:192,128|0,0s|0,32s|...|112,32n|112,0n|0,0x|0,0x|0,0x|0,0x|0,0x|0,0x'

@iamlegio
Copy link

iamlegio commented Mar 29, 2023

thank you, yes I discarded the last panels, was a little sloppy and did not write it out :)

0,0 is in top left Corner but is it seen from the front or the back?

You wrote ‘Remap:192,128’ should it not be 128 width and 192 height. Remap:<new_width>,<new_height>| Or should I flip it with ;Rotate after the mapping?

My screen is built to have 0,0 in lower left corner seen from the back. So it is a little confusing to map it correctly, hence all the questions.

41D99876-F023-473D-883D-920E8A89401E

@ledvinap
Copy link
Contributor Author

Sorry, was answering too late in the evening yesterday.

The mapping uses rgbmatrix coordinates - top-left corner is (0,0), x increasing to the right, y is increasing down, looking on leds (front side). Display coordinates are used in mapping, panel (and chain) is implicit - |<chain1, panel 1>|<chain1, panel2|...|<chain 2, panel 1>|...

Size will be 128,192

If I understand it correctly, first panel on chain 1 in your case in bottom right corner when looking on leds? In that case, first entry would be |112,160n|

@iamlegio
Copy link

iamlegio commented Mar 29, 2023

It Works!

my panels are oriented like this:

PanelOrientation

So instead of north and south I had to use east and west:

Remap:192,128|112,160e|...|0,160w|0,0x|0,0x|0,0x|0,0x|0,0x|0,0x

Thank you so much for your help and excellent work in writing this mapper!
Thomas

@ledvinap
Copy link
Contributor Author

Great!

Direction should be where top of module (4 arrows on PCB) are pointing.

BTW: It is possible to rearrange panels so that all chains are 16 panels (you will gain ~11% refresh increase).
And you get shorter cables from PI as bonus ;-)

RGB

@iamlegio
Copy link

iamlegio commented Mar 29, 2023

Again Thank You,

yes I could definitely rearrange the modules. Will try it now, great idea!

@AlexRoidl
Copy link

+1

@hzeller
Copy link
Owner

hzeller commented May 5, 2023

Nice! This is the kind of universal mapper that I was looking forward for someone to implement!

Sorry for the delay in the review, I was busy around November and might not have noticed the pull request.

I still have to look at the details of the code, and will probably have time on Sunday for that.

In the meantime: to be most useful to users, can you add a description in the mapper section of the README in examples-api-use/ ?
https://github.com/hzeller/rpi-rgb-led-matrix/tree/master/examples-api-use#remapping-coordinates

@ledvinap
Copy link
Contributor Author

ledvinap commented May 5, 2023

@hzeller :

  • Can you look at parametr syntax? It is still time to improve it, it will be more complicated later.
  • I'll fix some minor problems before merge (typos + whtespace)
  • I hate writing documentation ;-). But I'll try, most of it is in this PR anyway

@hzeller
Copy link
Owner

hzeller commented May 29, 2023

How is the working coming along with the documentation ?

@AlexRoidl
Copy link

@hzeller Is it possible to use this in the python binding somehow? Even if it is only a hot-fix?

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.

4 participants