Remove initLeds() and initLedCommands because it's better to rather not mess around with the LED control registers.

This commit is contained in:
László Monda
2017-01-16 01:13:15 +01:00
parent c3457e33b7
commit 99be63e5a8
+1 -59
View File
@@ -16,65 +16,9 @@ ledsRight.fill(0xff)
var ledIndex = 0; var ledIndex = 0;
var matrixId = 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; 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() { function updateLeds() {
// console.log('update')
var buffer = Buffer.concat([ var buffer = Buffer.concat([
new Buffer([ new Buffer([
uhk.usbCommands.writeLedDriver, uhk.usbCommands.writeLedDriver,
@@ -90,13 +34,11 @@ function updateLeds() {
console.error("USB error: %s", err); console.error("USB error: %s", err);
process.exit(1); process.exit(1);
} }
// console.log('update success')
endpointIn.transfer(64, function(err2, receivedBuffer) { endpointIn.transfer(64, function(err2, receivedBuffer) {
if (err2) { if (err2) {
console.error("USB error: %s", err2); console.error("USB error: %s", err2);
process.exit(2); process.exit(2);
} }
// console.log('Received', uhk.bufferToString(receivedBuffer));
ledIndex += ledCountToUpdatePerCommand; ledIndex += ledCountToUpdatePerCommand;
if (ledIndex >= ledMatrixSize) { if (ledIndex >= ledMatrixSize) {
@@ -109,7 +51,7 @@ function updateLeds() {
}); });
} }
initLeds(); updateLeds();
var letterIdx = 0; var letterIdx = 0;