Personal tools
Namespaces

Variants
Actions

LED mapping

From NiftyWiki
Jump to: navigation, search
Home Documentation Download Support Showroom Links


LED mapping basically means "use a channel of a certain pixel as brightness for a certain LED". To control each LED (or any other light-fixture) individually, each LED has it's own "address". These normally don't match the order of pixels of a frame. To freely feed light-setups with pixel-frames, it is defined which pixel relates to which light fixture. To keep it simple, we'll use rectangular tiles.


A simplified example

Let's use a 3x3 Multi-color LED Matrix as an example:

Example0.png


...and some image which is made up from pixels (here 7x7 pixels):

Example1.png


Now we can assign an led to a specific pixel/region:

Example2.png


niftyled will then take the color of the defined pixel/region and send it to the appropriate light fixture:

Example3.png


In practice you don't just have a "color" but different channels that, when combined, make a certain color. Channels can be any additive color-model like RGB, greyscale etc...


Detailed example

Input pixel frame

A pixel frame can come from any source. A video-capture device, a screen-capture, a custom software etc. For this example, we'll use a small 7x7 RGB pixel frame:

Example1.png


which, in R,G,B consists of these brightness-values:


Example2 nomap r.png Example2 nomap g.png Example2 nomap b.png


One tile

We'll use 3x3 RGB-Pixels (27 LEDs):

Tile 3x3 RGB.png

We can map this any way we want, but we start simple:

Example4.png

As LED-setup XML it would look like this:

<tile width="3" height="3">
  <chain ledcount="27" pixel_format="RGB u8">
    <led x="0" y="0" component="0"/>
    <led x="0" y="0" component="1"/>
    <led x="0" y="0" component="2"/>
    <led x="1" y="0" component="0"/>
    <led x="1" y="0" component="1"/>
    <led x="1" y="0" component="2"/>
    <led x="2" y="0" component="0"/>
    <led x="2" y="0" component="1"/>
    <led x="2" y="0" component="2"/>
    <led x="0" y="1" component="0"/>
    <led x="0" y="1" component="1"/>
    <led x="0" y="1" component="2"/>
    <led x="1" y="1" component="0"/>
    <led x="1" y="1" component="1"/>
    <led x="1" y="1" component="2"/>
    <led x="2" y="1" component="0"/>
    <led x="2" y="1" component="1"/>
    <led x="2" y="1" component="2"/>
    <led x="0" y="2" component="0"/>
    <led x="0" y="2" component="1"/>
    <led x="0" y="2" component="2"/>
    <led x="1" y="2" component="0"/>
    <led x="1" y="2" component="1"/>
    <led x="1" y="2" component="2"/>
    <led x="2" y="2" component="0"/>
    <led x="2" y="2" component="1"/>
    <led x="2" y="2" component="2"/>
  </chain>
</tile>

Here, component 0 is red, 1 is green and 2 is blue.


Offset

If we have two 3x3 tiles we can build a 6x3 matrix:

Example5a.png


We could define this like above using a <chain> with twice as much LEDs. But for convenience we use exactly the same tile again, just with an x-offset of 3 pixels:

<!-- First tile -->
<tile x="0" y="0" width="3" height="3">
  <chain ledcount="27" pixel_format="RGB u8">
    <led x="0" y="0" component="0"/>
    <led x="0" y="0" component="1"/>
    <led x="0" y="0" component="2"/>
    <led x="1" y="0" component="0"/>
    <led x="1" y="0" component="1"/>
    <led x="1" y="0" component="2"/>
    <led x="2" y="0" component="0"/>
    <led x="2" y="0" component="1"/>
    <led x="2" y="0" component="2"/>
    <led x="0" y="1" component="0"/>
    <led x="0" y="1" component="1"/>
    <led x="0" y="1" component="2"/>
    <led x="1" y="1" component="0"/>
    <led x="1" y="1" component="1"/>
    <led x="1" y="1" component="2"/>
    <led x="2" y="1" component="0"/>
    <led x="2" y="1" component="1"/>
    <led x="2" y="1" component="2"/>
    <led x="0" y="2" component="0"/>
    <led x="0" y="2" component="1"/>
    <led x="0" y="2" component="2"/>
    <led x="1" y="2" component="0"/>
    <led x="1" y="2" component="1"/>
    <led x="1" y="2" component="2"/>
    <led x="2" y="2" component="0"/>
    <led x="2" y="2" component="1"/>
    <led x="2" y="2" component="2"/>
  </chain>
</tile>
<!-- Second tile -->
<tile x="3" y="0" width="3" height="3">
  <chain ledcount="27" pixel_format="RGB u8">
    <led x="0" y="0" component="0"/>
    <led x="0" y="0" component="1"/>
    <led x="0" y="0" component="2"/>
    <led x="1" y="0" component="0"/>
    <led x="1" y="0" component="1"/>
    <led x="1" y="0" component="2"/>
    <led x="2" y="0" component="0"/>
    <led x="2" y="0" component="1"/>
    <led x="2" y="0" component="2"/>
    <led x="0" y="1" component="0"/>
    <led x="0" y="1" component="1"/>
    <led x="0" y="1" component="2"/>
    <led x="1" y="1" component="0"/>
    <led x="1" y="1" component="1"/>
    <led x="1" y="1" component="2"/>
    <led x="2" y="1" component="0"/>
    <led x="2" y="1" component="1"/>
    <led x="2" y="1" component="2"/>
    <led x="0" y="2" component="0"/>
    <led x="0" y="2" component="1"/>
    <led x="0" y="2" component="2"/>
    <led x="1" y="2" component="0"/>
    <led x="1" y="2" component="1"/>
    <led x="1" y="2" component="2"/>
    <led x="2" y="2" component="0"/>
    <led x="2" y="2" component="1"/>
    <led x="2" y="2" component="2"/>
  </chain>
</tile>

since both tiles use the same <chain>, we can put it into a seperate file and include it using XInclude (s. LED-setup: XInclude


Rotation

You can define a pivot-point (pixel x,y) and a rotation parameter (degrees) to have niftyled rotate the tile on-the-fly relative to its parent-tile. In this example we'll use the center of the tile as pivot point:

Example5b.png


<tile x="0" y="0" width="3" height="3" pivot_x="1.5" pivot_y="1.5" rotation="0">
 ...
</tile>
<tile x="3" y="0" width="3" height="3" pivot_x="1.5" pivot_y="1.5" rotation="90">
  ...
</tile>
<tile x="3" y="3" width="3" height="3" pivot_x="1.5" pivot_y="1.5" rotation="180">
  ...
</tile>
<tile x="0" y="3" width="3" height="3" pivot_x="1.5" pivot_y="1.5" rotation="270">
  ...
</tile>


Another example:

Example5c.png


<tile x="2" y="2" width="3" height="3" pivot_x="1.5" pivot_y="1.5" rotation="45">
 ...
</tile>
<tile x="4" y="4" width="3" height="3" pivot_x="1.5" pivot_y="1.5" rotation="315">
  ...
</tile>


Children

We can group tiles simply by wrapping them into another tile. This way we can re-use it with different offsets or rotations:

<tile>
  <tile>
    ...
  </tile>
  <tile>
    <tile>
      ...
    </tile>
    <tile>
      ...
    </tile>
  </tile>
</tile>


Further reading

...read the niftyled XML configuration file documentation to learn all ways to describe a LED setup.