Personal tools
Namespaces

Variants
Actions

Example tutorial

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

After everything is installed, a good start could be a small example using the dummy plugin.


configuration

Let's assume our dummy LED setup is a simple matrix of 2x2 sequentially arranged RGB LEDs and looks like this:

.---------------------.
|          |          |
| 0  1  2  | 3  4  5  |
|          |          |
|----------+----------|
|          |          |
| 6  7  8  | 9  10 11 |
|          |          |
'---------------------'


niftyconf

Niftyconf-2x2-dummy.png

We'll use niftyconf to create a LED-setup XML file 2x2.xml. (For details on niftyconf check the niftyconf documentation)


<?xml version="1.0" encoding="UTF-8"?>
<niftyled>
  <hardware name="dummy01" plugin="dummy" id="/dev/dummy" stride="0">
   <!-- hardware controls chain of 12 pixels that are connected as RGBRGBRGB ...
        brightness values go from 0 to 255 -->
    <chain ledcount="12" pixel_format="RGB u8"/>
    <!-- tile within our input graphic -->
    <tile>
      <!-- input will be 2x2 RGB u8 format -->
      <chain ledcount="12" pixel_format="RGB u8">
        <!-- red LED at 0,0 -->
        <led x="0" y="0" component="0"/>
       <!-- green LED at 0,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="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"/>
      </chain>
    </tile>
  </hardware>
</niftyled>

First tests

At first we can try ledset to light indiviual LEDs:

# ledset --config 2x2.xml --loglevel debug --pos 0 --value 255
# ledset --config 2x2.xml --loglevel debug --pos 1 --value 255
# ledset --config 2x2.xml --loglevel debug --pos 2 --value 255

The dummy plugin does nothing but print out the raw chain buffer of each LEDs brightness in the "debug" loglevel. So this would show us the brightness of each of the 12 LEDs as hex value:

chain.c:601 led_chain_print_buffer() debug: RAW Buffer:
chain.c:638 led_chain_print_buffer() debug: 0xff 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
chain.c:672 led_chain_print_buffer() debug: 0x00 0x00
chain.c:601 led_chain_print_buffer() debug: RAW Buffer:
chain.c:638 led_chain_print_buffer() debug: 0x00 0xff 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
chain.c:672 led_chain_print_buffer() debug: 0x00 0x00
chain.c:601 led_chain_print_buffer() debug: RAW Buffer:
chain.c:638 led_chain_print_buffer() debug: 0x00 0x00 0xff 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
chain.c:672 led_chain_print_buffer() debug: 0x00 0x00


raw data

We can create random noise by feeding /dev/urandom as raw data to our dummy hardware:

# ledcat --config 2x2.xml --raw --loglevel debug - < /dev/urandom 2>&1 | grep print_buff
chain.c:601 led_chain_print_buffer() debug: RAW Buffer:
chain.c:638 led_chain_print_buffer() debug: 0xc7 0xc2 0xe8 0x86 0x61 0x18 0x9e 0x1e 0xb0 0xa3 
chain.c:672 led_chain_print_buffer() debug: 0xec 0x5a 
chain.c:601 led_chain_print_buffer() debug: RAW Buffer:
chain.c:638 led_chain_print_buffer() debug: 0x5f 0x75 0x50 0x28 0xca 0xfc 0x55 0xca 0x94 0x1d 
chain.c:672 led_chain_print_buffer() debug: 0xfc 0xd4 
chain.c:601 led_chain_print_buffer() debug: RAW Buffer:
chain.c:638 led_chain_print_buffer() debug: 0xbd 0x57 0x59 0xb7 0x59 0x29 0xa9 0x01 0xd3 0xbf 
chain.c:672 led_chain_print_buffer() debug: 0xb4 0x63 


images

we can also display 2x2 image files:

# ledcat --config 2x2.xml image.png

or image sequences:

# ledcat --config 2x2.xml --fps 30 images/image*.png


further reading

s. ledcat examples