Andrew, we got the boards and we love them! If you care to follow
along with us, we have a few videos up of our first time hooking
everything up to the lanterns:
http://gardenofmissedconnections.blogspot.com/
// set a lantern color with RGB values, each from 0 to 8192
void setLanternColor(int lantern, int r, int g, int b)
{
pwm.brightness[lantern * 6]= r;
pwm.brightness[lantern * 6 + 1]= g;
pwm.brightness[lantern * 6 + 2]= b;
}
// set a lantern color with a hue (between 0 and 360) and brightness value
void setLanternColor(int lantern, int hue, int brightness)
{
// when hue is between 0 and 60, r = brightness, b = 0.0 and g goes
linearly from
// 0.0 to brightness; similarly, r goes down when 60<hue<120, b
ramps up when 120<hue<180,
// g goes down when 180<hue<240, r ramps up when 240<hue<300 and b -
down when 300<hue<360.
static int r, g, b;
r = (60*(hue<60) + (120-hue)*((hue>=60)&&(hue<120)) + /*
0*((hue>=120)&&(hue<240))/60 + */
(hue-240)*((hue>=240)&&(hue<300)) + 60*(hue>=300))*(brightness/60);
g = (hue*(hue<60) + 60*((hue>=60)&&(hue<180)) +
(240-hue)*((hue>=180)&&(hue<240))
/* + 0*(hue>240) */ )*(brightness/60);
b = (/* 0*(hue<120) + */ (hue-120)*((hue>=120)&&(hue<180)) +
60*((hue>=180)&&(hue<300)) +
(360-hue)*(hue>=300))*(brightness/60);
setLanternColor(lantern, r, g, b);
}
void color_wheel_chase()
{
static int hue=0; // the hue
static int increment=8; // a number by which to increment hue
static int lantern_number=4; // number of lanterns
int h=hue;
for (int i=0; i<lantern_number; i++) {
setLanternColor(i, h, Lightuino_MAX_BRIGHTNESS);
h = (h + (360/lantern_number)) % 360;
}
hue = (hue + increment) % 360;