Commit 2ab367e2 authored by TJ Horner's avatar TJ Horner

some cool changes

parent 384e08f7
......@@ -28,9 +28,13 @@ function Button(launchpad, note){
launchpad._output.sendMessage([144, self.toNote(), color]);
}
// rgb values 0-63 I think
this.pulseColor = function(color){
launchpad.sendSysEx([40, self.toNote(), color]);
}
// rgb values 0-63
this.setRgbColor = function(r, g, b){
launchpad._output.sendMessage([240, 0, 32, 41, 2, 16, 11, self.toNote(), r, g, b, 247]);
launchpad.sendSysEx([11, self.toNote(), r, g, b]);
}
this.getColor = function(){
......
// TODO we don't need this anymore
// since I discovered sysex messages
var launchColors = require('./colors.json');
Array.min = function(array){
......
......@@ -44,13 +44,34 @@ function Launchpad(params){
throw new Error("// TODO: Implement MK2 support.");
}
// convenience method for adding the header and terminator to sysex messages
this.sendSysEx = function(bytes){
// sysex header
var message = [240, 0, 32, 41, 2, 16];
// sysex message
bytes.forEach(function(byte){
message.push(byte);
});
// sysex terminator
message.push(247);
// console.log("sysex", message);
self._output.sendMessage(message);
}
this.getButton = function(x, y){
return self.buttons[(x.toString() === "0" ? "" : x.toString()) + y.toString()];
}
this.lightAll = function(color){
self.sendSysEx([14, color]);
// self.buttons.forEach(function(button){
// button.setColor(color);
// });
}
this.lightAllRgb = function(r, g, b){
self.buttons.forEach(function(button){
button.setColor(color);
button.setRgbColor(r, g, b);
});
}
......@@ -60,21 +81,19 @@ function Launchpad(params){
});
}
// defunct for now
this.sendSysEx = function(bytes){
// sysex header
var message = [240, 0, 32, 41, 2, 16];
// sysex message
message.concat(bytes);
// sysex terminator
message.push(247);
self._output.sendMessage(message);
}
this.toLayout = function(layout){
self._output.sendMessage([240, 0, 32, 41, 2, 16, 44, layout, 247]);
}
this.scrollText = function(text, color, loop, speed){
var message = [20, color, loop];
for(var i=0;i<text.length;i++){
message.push(text.charCodeAt(i));
}
self.sendSysEx(message);
if(speed) self.sendSysEx([20, color, loop, speed]);
}
return this;
}
......
......@@ -2,7 +2,7 @@
var Launchpad = require('..'),
launchpad = new Launchpad.connect({
in: 1,
out: 2,
out: 1,
type: Launchpad.types.PRO
});
......@@ -15,9 +15,12 @@ launchpad.darkAll();
// launchpad.getButton(8, 8).setColor(Launchpad.getColor(255, 255, 0));
// launchpad.getButton(1, 8).setColor(Launchpad.getColor(0, 0, 255));
launchpad.scrollText("launchpad-mk2 node module", 50, 0, 6);
launchpad.on("press", function(button, velocity){
console.log("Button", button.x, button.y, "pressed with velocity", velocity);
button.setColor(Math.floor((Math.random() * 127) + 1));
// button.setColor(Math.floor((Math.random() * 127) + 1));
button.pulseColor(Math.floor((Math.random() * 127) + 1));
// button.setRgbColor(30, 10, 0);
if(button.x === 1 && button.y === 0) launchpad.darkAll();
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment