define [colour |
color]
colour_name = Rvalue,
Gvalue, Bvalue
colour names can be
defined anywhere in the command file but they must be defined before
they are used by another command. You specify the Red, Green and
Blue PWM components where 0 = 0% PWM for the channel and 255 = 100%
PWM. (%PWM / 100) * 255 = value
The command supports
both British and American spellings of the word colour | color :-)
define colour red
= 255,0,0
define colour myFavouriteColour, 240,126,182
define color forUSofA = 50,0,0
you can use a
subroutine to put all your colour definitions at the end of the
command file and use a call at the start of the file to keep the
command script tidy.
sub colourDefs
define colour
someColour = 45,55,125
define colour anotherColour = 120, 240,9
define colour veryPurple = 200,0,255
return
The following colour names are pre-defined:
black = 0,0,0
white = 255,255,255
red = 255,0,0
green = 0,255,0
blue = 0,0,255
magenta = 255,0,255
cyan = 0,255,255
yellow = 255,255,0
colour names can
be redefined at any time, including the predefined names above.
define position
position_name
= Servo1_pos, Servo2_pos,
Servo3_pos
servo position names
can be defined anywhere in the command file but they must be defined
before they are used by another command. You specify the
position for each of the three servo channels with a value anywhere
between 0 and 255.
0 = -45o
(1mS pulse), 255 = +45o (2mS pulse), 128 = 0o
(1.5mS pulse)
define position home_hccw_hcw = 128, 64, 192
define position somePos = 50, 200, 138
The following servo
position names are predefined
home = 128,128,128
|
move all servos to
centre |
ccw = 0,0,0 |
move all servos fully
counter clock-wise |
cw = 255,255,255 |
move all servos fully
clock-wise |
servo position names
can be redefined at any time including the predefined names above
define address addr_name
= addr_value, addr_value, ....
The define address
command will take a single address value, or a comma separated
list. This can be used to create a single name that group
a number of addresses to represent some physical arrangement of the SADs. Address value must be in the range 0 to 255.
address names can
be defined anywhere in the command file but they must be defined
before they are used by another command
define address bigLED1 = 5
define address allDrivers = 255
define address
LEDsquare = 1, 2, 3, 4, 16, 19, 32, 35, 48, 49, 50, 51
you can redefine
an address name at any time, including the pre-defined addresses,
though you probably don't want to do that.
pre-defined
address names are:
gr[0-7] = 128-135
gc[0-15] = 144-159
all, broadcast = 255
the gr and gc
names are used with the SADs group row and group column
addressing modes. (see
packet protocol)
[ colour | color ] colour_name
[nofade | fade fade_rate]
to [ address | address_name]
the named colour
is sent to all addressed SADs. The colour will not appear
at the PWM output until a 'transfer to' command is received
The command
supports both British and American spellings of the word colour
| color :-)
colour red
fade 7 to bigLED1
colour blue nofade to 48
colour cyan fade 2 to LEDsquare
color forUSofA
nofade to USA
position
position_name
[noslew | slew slew_rate]
to [ address |
address_name ]
values in the the
named servo position are sent to all addressed SADs. The servo
channels will not be updated with the new values until a 'move
to' command is received.
position home
noslew to myServos
position somePos slew 5 to otherServos
transfer to
[ address | address_name ]
the transfer
command instructs RGB SADs to move the values received in the colour command to
the PWM output.
transfer to allDrives
transfer to 1
Once an SAD has
transferred colour data to the PWM output it marks that data as
'old' and will ignore further transfer commands until it has
received new colour data. Therefore, if you send a
transfer command to the broadcast address only SADs' with
'fresh' colour data will update their PWM output.
Important
With the addition of support for an RC
Servo driver, the Colour and Servo drivers use a common data packet.
To help avoid accidentally sending colour data to a servo or vice-versa two
different commands are used. To further avoid problems, if a
Colour driver receives a Servo move command it will assume any 'new'
data it has may not have been intended for it and discard it.
To summarise:
If a colour driver receives a Servo move command it will:
1. Discard any new data it may have received.
2. Ignore the move command.
move to [
address | address_name ]
the move command instructs
servo SADs to move the values received in a servo position
command to the servo channel outputs
move to
myServos
move to 50
Once an SAD has moved servo
data to the servo channel outputs it marks that data as 'old'
and will ignore further move commands until it has received new
servo position data. Therefore, if you send a move command
to the broadcast address only SADs' with
'fresh' servo position data will update their servo channel outputs.
Important
With the addition of support for an RC
Servo driver, the Colour and Servo drivers use a common data packet.
To help avoid accidentally sending colour data to a servo or vice-versa two
different commands are used. To further avoid problems, if a
Servo driver receives a Colour transfer command it will assume any 'new'
data it has may not have been intended for it and discard it.
To summarise:
If a servo driver receives a Colour transfer command it will:
1. Discard any new data it may have received.
2. Ignore the transfer command.
servo
channel position position
to [ address |
address_name ]
Moves servo on channel to
specified position. This is a direct command, the
new position data being sent to the servo output channel
immediately. There is no 'move to' command required. Valid
channel numbers are 1,2,3. Position range is 0 - 255
move servo on channel 1 to
position 128 at address 5
servo 1
position 128 to 5
move servo on channel 2
to position 60 at named address someServo
servo 2
position 60 to someServo
If a servo slew operation is in
progress when this command is sent to a servo channel, the
specified servo is immediately moved to the new position.
The other servos continue with the original slew operation.
Any servo data received through
a 'position' command is unaffected by the 'servo' command. In
the example below the first command would load the servo channel
latches with 0, 0, 0 (fully counter clockwise). The second
line would immediately set servo channel 2 to position 128
(home). Finally the last line would move all three servo
channels back to position 0
position
ccw noslew to 0
servo 2 position 128 to 0
move to 0
pause [ n_seconds
| rand [ range_secs | base_secs
range_secs ]]
pauses for 10 seconds
pause 10
pauses for a random
time between 1 and 10 seconds
pause rand 10
pauses for a random
time between 2 and 8 seconds
pause rand 2 8
The pause command
will automatically send a 'keepalive' packet to the broadcast
address every 120 seconds if the pause length is greater than
120 seconds.
fastpause [ n_10ths/secs
| rand [ range_10ths/secs |
base_10ths/secs range_10ths/secs ]]
fastpause operates
in the same way as the pause command but all values are in 10ths
/ second
pauses for 1/10th
second
fastpause 1
pauses for 1.5
seconds
fastpause 15
repeat n |
next
repeats the
section between the repeat and the next commands n times.
repeat 3
colour
blue nofade to 0
colour red nofade to 1
transfer to gr0
pause 5
next
repeat / next
blocks can be nested as shown below
repeat 2
colour red
fade 2 to gr0
pause 5
repeat 4
colour
blue fade 2 to gr0
pause 5
colour green fade 2 to gr0
pause 5
next
next
sub sub_name |
return
the section of
code between the sub and return commands are defined as a
subroutine and can be executed using the call command.
Subroutines can be defined anywhere in the command file.
sub
redFadeRows
colour red
fade 3 to all
transfer to gr0
pause 2
transfer to gr1
pause 2
transfer to gr2
pause 2
transfer to gr3
pause 2
return
call sub_name
calls the named
sub routine
call
redFadeRows
subroutines can be
called from within another subroutine.
sub group2subs
call
firstSub
call secondSub
return
Important.
Subroutines are not re-entrant so you shouldn't call a sub from
within itself.
Don't do this:
sub someFunc
pause 2
call someFunc
return
select from
[subname1, subname2, .....]
randomly selects
one subroutine from the list and calls that subroutine
select from
redFade, greenFade, blueFade, cyanSlow, magentaSlow,
yellowSlow
use within a
repeat next loop to run random effects
repeat 10
select from fastRainbow, slowRainbow, warmRedFade
next
pwm [
enable | disable ]
to [ address | named_address ]
enables or
disables the PWM output on the SAD. This command shuts
down the PWM output hardware but does not affect the operation
of the SAD. It will continue to receive and process
packets and can update with new colour and fade data while the
PWM output is shutdown. When an enable command is
received, the PWM output will be driven with the current PWM
data.
pwm enable to
5
pwm disable to
all
print
" text "
the print command
sends text to the screen. You can use this command to help
see what the script is doing.
print "Running
subroutine 1"
screen shows
Running subroutine 1
print "Running
"redFading" subroutine"
screen shows
Running "redFading" subroutine
keepalive
sends a keepalive
packet to the broadcast address
restart
restarts execution
of commands from the beginning of the command file
stop
stops and exits,
returning to the windows command line.