■ FIGURE 6. DMX Channel Switch. ■ FIGURE 7. Channel Output.
order is reversed because the LSB (0) is in the MSB
position within the brackets. Another bonus that the
switch could have used any set of I/O pins; so long as
the group was contiguous. The only pins read are those
defined within the brackets, and the result bits are flipped
and shifted (to zero-align) if required. We can use this
technique to read any parallel inputs and get a value that
is immediately usable.
If the channel switch is valid (not zero) and the DMX
Start byte is valid (zero),
then we read the channel
values from the DMX
array and move them to
the outputs using BAM to
handle the brightness
modulation. You can see
that Spin borrows heavily
from C in that we can use
the post-increment operator (++) on chan; this lets us read
the current channel and then update that variable before
Visually, LEDs can seem a little harsh when using
straight linear values as we’d get from the DMX stream.
■ FIGURE 8.