Here is what I am trying to drive:

http://docs.macetech.com/doku.php/megabrite

I can't say that I completely get their arduino code snip in their sample ( for example, what the heck is going on in the while loops in the SB_SendPacket() function? ).

Anyhow, the code below "seems to work" but I am not completely convinced that I have the bit mixing correct. So on the chance that somebody had tried these devices before I thought I would post this for some other eyes to look it over.


Code:

' simple looping driver

Main:
  DO
    FOR RLED = 1 TO 1000 STEP 30
      FOR BLED = 1 TO 1000 STEP 20
        FOR GLED = 1 TO 1000 STEP 10
          GOSUB RGB_LED
          PAUSE 1
        NEXT
      NEXT
    NEXT

    FOR GLED = 1000 TO 1 STEP -10
      FOR BLED = 1000 TO 1 STEP -20
        FOR RLED = 1000 TO 1 STEP -30
          GOSUB RGB_LED
          PAUSE 1
        NEXT
      NEXT
    NEXT

  LOOP
END

' my attempt at bit mixing

RGB_LED:
  LO_WORD = 0
  HI_WORD = 0

  ' 10bits G  10bits R  10bits B then two zeros
  '
  HI_WORD = ( ( BLED << 2 ) & $FFFC ) | ( ( RLED << 10 ) & $FC00 )
  LO_WORD =  RLED >> 6 | ( ( GLED << 6 ) & $FFC0 )

  SHIFTOUT DataPin, ClockPin, LSBFIRST, [HI_WORD]  ' send the bits
  SHIFTOUT DataPin, ClockPin, LSBFIRST, [LO_WORD]  ' send the bits

  HIGH  LatchPin
  PAUSE 1
  LOW   LatchPin
RETURN
Thanks, in advance, to anyone that may have some help for me here.

For more ideas on what can be done with these things, see:

http://mbed.org/users/4180_1/notebook/shiftbrite1/