LED pattern and sequence definition
A chain or matrix of serial LEDs supports more complex LED feedback options. This is best managed using a text file called leds.ini which will:
-
define the colours of LEDs that make up named patterns, and
-
define timed sequences of these patterns.
Any pattern or sequence defined in the leds.ini text file can then be called from config.txt when needed.
-
Create an LED pattern section to define the colour of one or more serial LEDs. It starts with a section name in square brackets, such as [leds.xxxxx] where xxxxx is your own name for this pattern. The section sets a colour output value in hexadecimal, and gives the specific address of the LED or LEDs in the chain which should show that colour when this pattern is called.
Example: 10 red LEDs pattern definition in a text file called leds.ini
Copy[leds.red]
FF0000=1-10Serially connected LEDs 1 to 10 are required to show colour #FF0000 (red) when this pattern is called.
For sequences you may need to define several different patterns in this way.
-
Create a sequence by calling different pattern sections (such as the one above) as a sequence of frames. It starts with a section name in square brackets, such as [seq.yyyyy] where yyyyy is your own name for this sequence. Each frame will specify a duration in milliseconds to display a particular LED pattern. The frames run in the order they are listed. If a pattern section called does not exist in the file, the LEDs will be switched off for the duration of that frame. The number of frames is only limited by the available RAM.
Each sequence can repeat 1 to 255 times. If a repeat is not specified, the sequence is only shown once. If a repeat is set to forever or 0, then sequence will run continuously until another sequence or individual pattern is called, which can be done using dynamic commands.
Example: Red-Green-Blue sequence definition in a text file called leds.ini
Copy[leds.red]
FF0000=1-10
[leds.green]
00FF00=1-10
[leds.blue]
0000FF=1-10
[seq.rgb]
repeat=forever
frame=400,leds.red
frame=500,leds.green
frame=600,leds.blueThe sequence section [seq.rgb] requires a repeat 'forever' loop which first calls the [leds.red] pattern for 400ms, then the [leds.green] pattern for 500ms, then the [leds.blue] pattern for 600ms.
You can define several different sequences in the same file.
-
After saving a text file called leds.ini with the above example lines, open the config.txt file and add the following setting to make this the default LED sequence.
Example: Setting in config.txt which requires default LEDs to follow the [seq.rgb] sequence defined in the text file leds.ini
CopyLEDDefaultRGB=FFFFFF:seq.rgb@leds.ini
When you save the config.txt file the new LED default setting will take effect immediately.