ColorPAL documentation
© Parallax, Inc. • ColorPAL (2009.06.15) Page 11 of 12
1. If the parameter is even, it is taken as a minimum, to which a random number between 0 and
(deviate – 1) is added. The sum cannot go above FE.
2. If the parameter is odd, it is taken as a maximum, to which a random number between 0 and
(deviate – 1) is subtracted. The sum cannot go below 01.
To turn off randomization, just do a ?00. In the following example, completely random colors blend
together
ad infinitum
:
SEROUT sio, baud, ["= t40 (00 ?FF r000000 ?00 p11) !"]
There are a few things to point out here: 1) the t40 is not randomized, since it occurs before the “?FF”;
2) the loop constant remains at 00 because it’s loaded only once, when the loop begins, and placed on
the stack; and 3) the p11 is not randomized, since it occurs after the ?00.
Because this example produces so many unsaturated (i.e. whitish) colors, it’s pretty boring. Here’s an
example that will produce fully-saturated colors at the end of each transition, since one component is
always held at nearly zero:
SEROUT sio, baud, ["= t10 (00 ?FF (07 r808001) (07 r800180) (07 r018080) )
!"]
v
Get Firmware Version Number Returns:
nn
The version command allows you to get the version number of the ColorPAL’s firmware. Version numbers
are output as two hex digits, begin at 01, and will increment by one with each new version. Version
changes are expected to be infrequent. The following program reads and prints the current version
number:
Version VAR Byte
SEROUT sio, baud, ["= v !"]
SERIN sio, baud, [HEX2 version]
DEBUG "Current version is: ", DEC version, "."
“other”
Echo Miscellaneous Character Returns:
“other”
Any ASCII character not mentioned here will be buffered and simply echoed when the program runs. This
can be handy for synchronizing the BASIC Stamp to a free-running ColorPAL’s output. For example, you
could program the ColorPAL’s EEPROM to sense and output a continuous stream of color data, like so:
SEROUT sio, baud, ["= (00 $ m) #00"]
Then your program can simply sync on the “$” in the data stream to catch the next available sequence of
color data, thus:
SERIN sio, baud, [WAIT("$"), HEX3 red, HEX3 grn, HEX3 blu]
Be sure to read the important note in the “Save Buffered Program to EEPROM” section regarding baud
rates.
Program Limitations
The space available for user programs in the ColorPAL is limited by the onboard micro’s RAM and
EEPROM space. The space available for buffering programs is 40 bytes. The amount of space required in
the buffer for each command is one byte, plus one byte for every two-digit numerical parameter it
requires. The space available in the EEPROM is 64 bytes, including the byte at the end that determines
the unit number. Spaces are not buffered and do not count toward the memory occupied by a program.