TimeSwipe wrapper for NodeJs
- Driver installation (instructions) - latest driver for download
- Run module with root permission (
sudo
)
npm install timeswipe
Example:
var timeswipe = require('timeswipe');
// Settings
timeswipe.SetBridge(0);
timeswipe.SetSensorOffsets(0,0,0,0);
timeswipe.SetSensorGains(1,1,1,1);
timeswipe.SetSensorTransmissions(1,1,1,1);
// Event Listener for Button
timeswipe.onButton(async function (pressed, counter) {
console.error("onButton pressed: ", pressed, " counter: ", counter);
});
// Event Listener for Errors
timeswipe.onError(async function (errors) {
console.error("onError errors: ", errors);
});
var lines = 0
// Start measurement
timeswipe.Start(async function (data, error) {
if (error) {
console.error("errors: ",error);
} else {
data.forEach(function(entry) {
lines = lines + 1;
});
}
});
const promise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, 10000)
})
function onComplete () {
timeswipe.Stop()
console.log('got lines: ', lines)
process.exit(0)
}
promise.then(onComplete)
Settings for Offset, Gain and Transmission can be applied for each signal separated.
Set Offset for measured data (bit).
Set board internal measurement-gain (bit --> V).
Set sensor specific transmission (V --> real unit). You get those from their datasheet.
Choose primary or secondary measurement type. For TimeSwipe pHAT IEPE this is 0 for IEPE, 1 for voltage signal (+-10V). For TimeSwipe pHAT DMS this is 0 for bridge circuits, 1 for current signal (4-20mA).
With this you can start measurement. Add callback with input data (array) and error (count of errors occured while record.
Event Listener for button pressed/released.
Event Listener for errors.
Stop measurement.
docker run --rm -v "$PWD/":/usr/src -w /usr/src pandaofficial/timeswipe_js /usr/src/build.sh
npm version patch
npm publish
git push --tags