Pages: [1]   Go Down
Author Topic: Threaded (non-blocking) RGB LED crossfade - examples?  (Read 1579 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 295
Got Karma?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

HI - I've seen lots of great examples for working with color fades on RGB LEDs but they all use a tight loop with a delay() controlling duration. I need to control a number of LEDs and have each of them transitioning concurrently. I'm looking at using the Penner easing functions as a starting point but I am wondering if this wheel has already been invented (threaded LED control on Arduino)?

I'm using ShiftBrites - so that adds a little.... complexity.

Cheers, and thanks for any tips.




Logged

Montreal
Offline Offline
Edison Member
*
Karma: 23
Posts: 2483
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Look into :  Examples/Digital/BlinkWithoutDelay - not blocking , still one thread.
Logged

Boston, MA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 83
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not sure if "easing" is really that noticeable in LEDs vs simple linear, but give it a try and tell us what you find!
But definitely you'll want to remember that the eye's view of brightness is logarithmic against actual energy and compensate for that.  Otherwise the rate of change of a LED going from dark to bright will seem to slow down as it gets brighter.

Actual threading is going to be a bit hard on an Arduino, I did not think that a thread library existed... but you never know its a big world!  Send me a link if you have actually used threading!

I would use an object that tracks each intensity and destination intensity.  And include a "next" call to update to the next intensity (for speed use Bresenham's line drawing alg, not typical high school algebra).  Then loop over each object calling "next".  Hook this loop into the timer if you want it to happen in the background.

There is code that does a lot of this here http://code.google.com/p/arduino-m5451-current-driver/source/browse/trunk/latest/apps/suntree_nightlight/suntree_nightlight.pde.  Look at the RgbFader class.  You'll have to adapt to shift-brite though.

Cheers!
Andrew
www.toastedcircuits.com: Lightuino LED driver
Logged

http://www.toastedcircuits.com Lightuino LED driver: 16 sources, 70 sinks, remote controlled.  Also high powered LED drivers.

Pages: [1]   Go Up
Jump to: