PDA

View Full Version : has anyone ever used mega-brites



TinkersALotV2
- 15th January 2013, 18:17
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.






' 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/

Jerson
- 16th January 2013, 00:35
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? ).

The while loops in Sb_SendPacket wait for the SPI engine to complete the transmission. That is when the SPIF bit gets set in the SPSR register.

TinkersALotV2
- 16th January 2013, 00:49
The while loops in Sb_SendPacket wait for the SPI engine to complete the transmission. That is when the SPIF bit gets set in the SPSR register.

Okay. Thanks for that. I will refer to their sample again with that new information in mind -- particularly what kicks off the SPI -- as I recall maybe it is the assignment of their mixed bits into another "special variable"