Skip to content

Instantly share code, notes, and snippets.

@CF-Terence
Forked from jarrodbell/gist:2924984
Created June 15, 2012 01:26
Show Gist options
  • Save CF-Terence/2934095 to your computer and use it in GitHub Desktop.
Save CF-Terence/2934095 to your computer and use it in GitHub Desktop.
Delaying color picker commands
// Push the modules into the startup process
CF.modules.push({name: "Color Picker", object: ColorPicker});
var myColorPicker;
function sendCmd(string) {
CF.send("AppleKNX", string);
};
// Only one CF.userMain function in all scripts is allowed!
// If you have one already in your project, consolidate all their contents into one CF.userMain function
CF.userMain = function () {
myColorPicker = new ColorPicker("colorpicker.png", "s1", 750, function(r, g, b, x, y) {
// This code will be run everytime the pixel color is obtained, along with the pixel data as parameters
var pixelR = "\x06\x20\xF0\x80\x00\x15\x04\x00\x00\x00\xF0\x06\x01\x32\x00\x01\x01\x32\x­03\x01" + String.fromCharCode(r);
var pixelG = "\x06\x20\xF0\x80\x00\x15\x04\x00\x00\x00\xF0\x06\x01\x33\x00\x01\x01\x33\x­03\x01" + String.fromCharCode(g);
var pixelB = "\x06\x20\xF0\x80\x00\x15\x04\x00\x00\x00\xF0\x06\x01\x34\x00\x01\x01\x34\x­03\x01" + String.fromCharCode(b);
//Send the commands in sequence
sendCmd(pixelR);
setTimeout(function(){sendCmd(pixelG);}, 250);
setTimeout(function(){sendCmd(pixelB);}, 500);
});
// Setup the colorpicker object after it was created above
myColorPicker.setup();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment