VaRGB (“var-gee-bee“) is an RGB illumination programming library. You tell it how you want your lighting to behave, and it handles all the details of updating red/green/blue values at the right time for you.
Intro and Demo Video
Have a look at this short video for an overview and a few neat demonstrations.
- Runs on pretty much anything (AVR, Arduino, PIC, desktops, Raspberry Pi… anything that works with C++)
- Can be used with any RGB lighting hardware
- Is easy to start using but flexible enough to handle all kinds of situations and behaviour
With VaRGB you’ll specify how you want the RGB values to fluctuate, using “transition curves“. One of the most basic of these is the linear curve, with which you could create lighting conditions as pictured here, on the right.
In a scenario such as this–say a plant illumination system–the RGB LEDs would start bringing up the red value slowly, between times t0 and t1. Then, as red continues to increase, the blue would come online at a different rate. When both red and blue top off, green peaks for a little while and then the reverse would occur slowly fading out all the colors.
To get this working with VaRGB, you’d simply specify the 6 points of interests by adding linear curves to a schedule (more on the actual coding later). Each linear curve would indicate where in RGB-space it is going to, and over how much time to do so by creating the objects using Linear(R,G,B, seconds), e.g.
- Linear(512, 0, 0, 3600) –go to 512 red, in one hour
- Linear(1023, 0, 900, 1800) — up the red and blue during 30 minutes
- Linear(1023, 700, 900, 1800) — add some green for the next 30 minutes
- Linear(1023, 0, 900, 1800) — reduce the green over 30 mins
- Linear(512, 0, 0, 3600) — reduce red, turn off blue over 1 hour
- Linear(0,0,0, 3600) — fade out red and go to black, during 1 hour
And that’s it: VaRGB will inform your code whenever you need to adjust any of the red, green or blue values and all you need to do is talk to your hardware to make it happen from within a callback function.
Most of VaRGB’s power lies in how you use, and combine, the various transition curves. There are a number of basic curve types available, and you can combine and transform them using “logical curves”.
Fundamental curve types include:
- Constant — stays at a certain RGB value for a determined period
- Linear — goes from current position to target RGB values linearly, over the duration
- Sine — fluctuates from 0 to configured value following a sine wave
- Flasher — alternates between two RGB positions
Then you can operate on these using other curves:
- AND — a bitwise AND (intersection)
- OR — a bitwise OR (union)
- NOT — a bitwise inversion
- Threshold — sets a lower, or upper, value
- Shift — left or right shift the values of a curve
Used together, you can configure a very wide range of behaviours for your RGB value–check out the video above to see it in action. To get started using VaRGB, check out Using VaRGB and let me know if you have any questions!
Related Pages: [subpages]