Ok, so I am really beginning to understand this thing better. I have two questions today. I am making a simple clock that lights LED in three different colors for the hours, minutes, and seconds.
(1) When the minutes and second are the same I want to mix the two colors seconds = hsv(0, 1, 1), minutes = hsv(0.333, 1, 1). I mix them by averaging the hue values (0 + 0.333)/2 = 0.167. This looks like it should be the yellow-ish color, but it is not. When I set a pixel directly to that value it looks right. Any ideas here?
(2) I eventually want the LEDs to light smoothly between second, minutes, and hours not like they are now. How do I go about figuring partial seconds in this scenario?
Code is posted below.
Thanks again,
RH
var sec = 0;
var min = 0;
var hour = 0;export function render(index) {
var secColor = 0
minColor = 0.333
var hrColor = 0.666;var pixelSet = false;
sec = clockSecond();
min = clockMinute();
hour = clockHour();// Set the pixel for the hour, minute, and second
if (index == sec){
hsv(secColor, 1, 1);
pixelSet = true;
} else if (index == min){
hsv(minColor, 1, 1);
pixelSet = true;
} else if (index == (5 * hour)){
hsv(hrColor, 1, 1);
pixelSet = true;
}// What to do if two pixels line up.
if ( (index == sec) && (index == min)){
hsv( (secColor + minColor)/2, 0, 1.0);
pixelSet = true;
}if ( (index == sec) && (index == (5 * hour))){
hsv( ((secColor + hrColor) / 2), 0, 1.0);
pixelSet = true;
}if ( (index == min) && (index == (5 * hour))){
hsv( ((minColor + hrColor) / 2), 0, 1.0);
pixelSet = true;
}// Turn the pixel off if it is not supposed to be on
if (!pixelSet)
hsv(1, 1, 0);}