Go Down

Topic: TLC5940 library oddity (Read 670 times) previous topic - next topic

al3ph

In my TLC5940 adventures I`ve come across an oddity, when setting an animation array structure using the GS_DUO macro I`ve found that values above 1024 start lighting up the second LED, from the documentation it should have a range of 0-4095.

Has anyone else seen this effect ?

ta

al

Grumpy_Mike

No not seen that at all. As the control range is 12 bits a byte and a half are used for each LED. If you get the algorithm wrong you could be putting the data into the wrong place.

al3ph

yeah that`s what I thought, but in this case I`m using the macro from the example, so I shouldn`t be able to mess that up, maybe his macro is buggy.

 /** Arranges 2 grayscale values (0 - 4095) in the packed array format (3 bytes).
   This is for array initializers only: the output is three comma seperated
   8-bit values. */
#define GS_DUO(a, b)    ((a) >> 4), ((a) << 4) | ((b) >> 8), (b)

al3ph

hmmm thinking about it his macro doesn`t do any casting, wonder if that might be the problem.

Grumpy_Mike

Yes if the values going in as a & b are bigger than 255 then it will give trouble. Not sure a cast would help be certainly a val &= 0xff to limit the value to 255 might no go amiss.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy