User Tools

Site Tools


wio:wio-ledscript-en

Deutsche VersionEnglish VersionFrench Version

LEDScript

Introduction

LEDScript runs in WIO context, and can be activated by Rocrail commands.
Its a simple plain ASCII file, which must be uploaded to the WIO.


Format

Only Unix linefeeds are allowed.

The text format has some restrictions:

  • A blank line will stop the LEDScript parser the same as with 'end'.
  • Comment lines are prefixed with the '#' sign, and are restricted to 64 characters incl. linefeed.
  • Only linefeeds are allowed without extra carriage return. (Unix format)
  • Max. 32 sequences are allowed.


File naming

The filename must be formatted like this:

<freetext><nr>.led

The number, <nr> ranges from 01 to 99.
Example:

disco04.led

Zero, *00.led, cannot be addressed.


Instructions

The header just contains one line:

s<iterations> The max. number iterations is 255, and zero will cause an endless loop.
o<report> Report end of script in case set to 1. (Default 1, set to 0 for disable reporting.)


LED Definition

l<nr> Starting LED address, and triggers a new record
c<count> Number of LEDs starting from l address
C<count> random LED from range l address to C
+ or -<count> to increase step by step (instead of c or C) *1
r<red> RGB red value
g<green> RGB green value
b<blue> RGB blue value
i<brightness> LED brightness
< or ><brightness> to decrease/increase LED brightness step by step (instead of i or I) (Ver 380+)
p<pause> Pause in units of 10ms
R<red> RGB red randomised with the given max. value or range* (musn't be 0)
G<green> RGB green randomised with the given max. value or range* (musn't be 0)
B<blue> RGB blue randomised with the given max. value or range* (musn't be 0)
I<brightness> LED brightness randomised with the given max. value
P<pause> Randomised pause in units of 10ms with the given max. value
a Randomise this definition, RGB, brightness and pause values with the given max. values

The rgbip values can be left out, and in this case the last parsed values are used.

*range: A 16bit RGB value range. Example: Range from 150 to 220. Value = 220+(150*256)=38620 (Ver 374+)

*1: for increase until the next l command. With + the LEDs stays on, with - not. See example below (Ver 377+)


LED Reset

If t > 0 this is used at the end of the script to reset LEDs.

d<nr> Starting LED address
t<count> Number of LEDs starting from d address

LED OFF

At a LED(output) off command, the following fields are used to reset LEDs, if the LEDs are still on after the script has finished.

D<nr> Starting LED address
T<count> Number of LEDs starting from D address


e End of the LEDScript.


Upload

ledscript-upload-en.jpg Uploading LEDScript files can be done with a WEB Browser as explained here:
Upload by WEB Browser


Activating

Output

Set the address value, <nr>, between 1 and 99 and set port type to LEDScript.

Car Function

Set the LED address value greater then 100, and <nr> is address - 100.


Examples

# start 0=endless loop, 1...255=iterations
s2 
# led 0 to 5
l0
c6
r255
g0
b0
i50
p1000
# led 0 to 2
l0
c3
r255
g255
b0
i50
p1000
# end
e
# Disco
# start 0=endless loop, 1...255=iterations
s0 
# led 0 to 19
l0
c20
# random
a
r255
g100
b100
i80
p20
e
Increase LED nr. (V377+):
# warning lights
s0 	//Script declared endless
l0 	
-6	//starting increase with LEDs off after p
r255
g115
b0
i150
p10     //end increase
l0 	
c6	
r255
g115
b0
i150
p5
l0 	
c6	
i0
p100
l0 	
+6	//starting increase with LEDs staying on after p
r255
g115
b0
i150
p10     //end increase
l0 	
c6	
i0
p100
#LED-reset, all LED off
d0
t6
e
increase/decrease brightness (V380+):
#brightinc
s0
l0 	
+1    
r255
g80
b0
>150  //increase brightness
l1 	
+1   
r255
g80
b0
<150  //decrease brightness
p3
#LED-reset, LED ausschalten.
d0
t2
e


WIO LEDScript Parser

The WIO parser is very simple, and reads the file line by line.
After reading a line, the first character is checked as listed in the Instructions paragraph.
If a number is expected, the C function atoi() is used with the line pointer + 1. A none numeric character should follow the number.
Because of the simple nature of this parser, it is also allowed to add some text to make the LEDScript more readable:

i80 // brightness 80 of 255
p20 // pause 20 * 10ms
end

But the total line length, incl. linefeed, should not exceed the 64 byte boundary.

LEDSkript Examples in the forum

wio/wio-ledscript-en.txt · Last modified: 2024/04/01 09:30 by rjversluis