rpi-rgb-led-matrix icon indicating copy to clipboard operation
rpi-rgb-led-matrix copied to clipboard

Feature remap mapper

Open ledvinap opened this issue 2 years ago • 13 comments

(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 avatar Nov 01 '22 21:11 ledvinap

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

ledvinap avatar Nov 04 '22 09:11 ledvinap

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

iamlegio avatar Mar 28 '23 20:03 iamlegio

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'

ledvinap avatar Mar 28 '23 22:03 ledvinap

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

iamlegio avatar Mar 29 '23 05:03 iamlegio

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|

ledvinap avatar Mar 29 '23 10:03 ledvinap

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

iamlegio avatar Mar 29 '23 14:03 iamlegio

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

ledvinap avatar Mar 29 '23 15:03 ledvinap

Again Thank You,

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

iamlegio avatar Mar 29 '23 17:03 iamlegio

+1

AlexRoidl avatar Apr 17 '23 11:04 AlexRoidl

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

hzeller avatar May 05 '23 15:05 hzeller

@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

ledvinap avatar May 05 '23 16:05 ledvinap

How is the working coming along with the documentation ?

hzeller avatar May 29 '23 22:05 hzeller

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

AlexRoidl avatar Jul 10 '23 16:07 AlexRoidl