Created
October 30, 2015 03:18
-
-
Save bunnybones1/2a6d027e4a16e41f6397 to your computer and use it in GitHub Desktop.
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
console.log('test'); | |
var HID = require('node-hid'); | |
var devices = HID.devices(); | |
console.log(devices); | |
var device = new HID.HID('USB_20ff_0100_14500000'); | |
var vec3 = require('gl-vec3'); | |
var chart = require('ascii-chart'); | |
var accel = [0, 0, 0]; | |
var quat = [0, 0, 0, 0]; | |
device.on("data", function(data) { | |
// console.log(data); | |
console.log('\033c'); | |
for (var i = 0; i < 3; i++) { | |
accel[i] = ((data.readUIntLE(i*2, 2) - 0x7fff) * 6 / 0x7fff); | |
console.log(accel[i]); | |
}; | |
for (var i = 3; i < 7; i++) { | |
quat[i-3] = ((data.readUIntLE(i*2, 2) - 0x7fff) / 0x7fff); | |
console.log(quat[i-3]); | |
}; | |
// console.log(pos); | |
// console.log(vec3.length(accel)); | |
}); | |
device.on("error", function(err) { | |
console.log(err); | |
}); | |
var state = false; | |
function toggleConnection() { | |
state = !state; | |
} | |
setInterval(toggleConnection, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment