diff --git a/launchpad.js b/launchpad.js index 9eca09d..548b9e2 100644 --- a/launchpad.js +++ b/launchpad.js @@ -212,14 +212,14 @@ var Launchpad = function(port, initAnimation) { }; Launchpad.prototype.renderByte = function(x, y, color, byte) { - + byte = byte.toLowerCase(); switch (byte) { case '1': break; case 'r': color = exports.colors.red.high; - break; + break; case 'o': color = exports.colors.orange.high; break; @@ -232,10 +232,24 @@ Launchpad.prototype.renderByte = function(x, y, color, byte) { default: color = exports.colors.off; break; - } + } this._grid[y][x].light(color); }; +Launchpad.prototype.renderColors = function(colors) { + if (colors === undefined) return; + for (var x = 0; x < colors.length; x++) { + var colorColumn = colors[x]; + for (var y = 0; y < colorColumn.length; y++) { + if (!this._grid[y][x]) { + console.log("Button not found: x:"+x+", y:"+y); + return; + } + this._grid[y][x].light(colorColumn[y]); + } + } +}; + Launchpad.prototype.renderBytes = function(bytes, color) { if (bytes === undefined) return; for (var x = 0; x < bytes.length; x++) {