From 99be63e5a8b492e08d86362c052a74608a7cea11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Mon, 16 Jan 2017 01:13:15 +0100 Subject: [PATCH] Remove initLeds() and initLedCommands because it's better to rather not mess around with the LED control registers. --- usb/pulse-leds.js | 60 +---------------------------------------------- 1 file changed, 1 insertion(+), 59 deletions(-) diff --git a/usb/pulse-leds.js b/usb/pulse-leds.js index 3fdd349d..db8f5f2a 100755 --- a/usb/pulse-leds.js +++ b/usb/pulse-leds.js @@ -16,65 +16,9 @@ ledsRight.fill(0xff) var ledIndex = 0; var matrixId = 0; - -var initLedCommands = [ - [ // only enable the LEDs that are actually in the matrix - uhk.usbCommands.writeLedDriver, - leftLedDriverAddress, - 19, - 0, - 0b00000001, 0b00111111, - 0, 0b00111111, - 0, 0b00111111, - 0, 0b00011111, - 0, 0b00011111, - 0, 0b00011111, - 0, 0b00011111, - 0, 0b00011111, - 0, 0b00011111, - ], - [ // only enable the LEDs that are actually in the matrix - uhk.usbCommands.writeLedDriver, - rightLedDriverAddress, - 19, - 0, - 0b00000001, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - ], - [uhk.usbCommands.writeLedDriver, leftLedDriverAddress, 2, 0xfd, 0x0b], // switch to function page - [uhk.usbCommands.writeLedDriver, leftLedDriverAddress, 2, 0xc2, 0xff], // enable the ghost image prevention bit - [uhk.usbCommands.writeLedDriver, leftLedDriverAddress, 2, 0xfd, 0x00], // switch to page 0 -] - var ledCommandId = 0; -function initLeds() { - var ledCommand = initLedCommands[ledCommandId++]; - console.log('initLeds', ledCommand); - var buffer = new Buffer(ledCommand); - - endpointOut.transfer(buffer, function(err) { - if (err) { - console.error("USB error: %s", err); - process.exit(1); - } - if (ledCommandId < initLedCommands.length) { - initLeds(); - } else { - updateLeds(); - } - }); -} - function updateLeds() { -// console.log('update') var buffer = Buffer.concat([ new Buffer([ uhk.usbCommands.writeLedDriver, @@ -90,13 +34,11 @@ function updateLeds() { console.error("USB error: %s", err); process.exit(1); } -// console.log('update success') endpointIn.transfer(64, function(err2, receivedBuffer) { if (err2) { console.error("USB error: %s", err2); process.exit(2); } -// console.log('Received', uhk.bufferToString(receivedBuffer)); ledIndex += ledCountToUpdatePerCommand; if (ledIndex >= ledMatrixSize) { @@ -109,7 +51,7 @@ function updateLeds() { }); } -initLeds(); +updateLeds(); var letterIdx = 0;