-
-
Save D-Touch/2935540 to your computer and use it in GitHub Desktop.
Delaying color picker commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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\x03\x01" + String.fromCharCode(r); | |
var pixelG = "\x06\x20\xF0\x80\x00\x15\x04\x00\x00\x00\xF0\x06\x01\x33\x00\x01\x01\x33\x03\x01" + String.fromCharCode(g); | |
var pixelB = "\x06\x20\xF0\x80\x00\x15\x04\x00\x00\x00\xF0\x06\x01\x34\x00\x01\x01\x34\x03\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
/* Color Picker module for CommandFusion
AUTHOR: Sergey Klenov, Jarrod Bell, Florent Pillet, CommandFusion
CONTACT: support@commandfusion.com
URL: https://github.com/CommandFusion/
VERSION: v1.0.2
LAST MOD: Thursday, 17 November 2011
HELP:
REQUIRES iViewer v4.0.6
Note: Safari security is very strict, to debug this code you need to use Google Chrome
*/
// ======================================================================
// Color Picker Object - Create one for each color picker you want in your GUI
// ======================================================================
var ColorPicker = function(url, hoverJoin, freq, callback) {
};
function encode64(input) {
var output = "";
var chr1, chr2, chr3 = "";
var enc1, enc2, enc3, enc4 = "";
var i = 0;
}
// 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
//CF.log("R: " + r + ", G: " + g + ", B: " + b);
CF.setJoins([
{join: "s10", value: r},
{join: "s11", value: g},
{join: "s12", value: b}
]);
var pixelR = "\x06\x20\xF0\x80\x00\x15\x04\x00\x00\x00\xF0\x06\x01\x32\x00\x01\x01\x32\x03\x01" + String.fromCharCode(r);
var pixelG = "\x06\x20\xF0\x80\x00\x15\x04\x00\x00\x00\xF0\x06\x01\x33\x00\x01\x01\x33\x03\x01" + String.fromCharCode(g);
var pixelB = "\x06\x20\xF0\x80\x00\x15\x04\x00\x00\x00\xF0\x06\x01\x34\x00\x01\x01\x34\x03\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();
};