Stackmat.js is a library for JavaScript which helps you to access the Stackmat Timer from your web application.
Demo: http://timhabermaas.github.io/stackmat.js/
npm install stackmat.jsFirst, create a Stackmat.Timer object and pass in a callback function which gets called every time the timer sends a signal - around five times a second.
import { Stackmat } from 'stackmat.js';
const options = {
signalReceived(state) {
console.log("Current Time: " + state.getTimeAsString())
}
};
const timer = new Stackmat.Timer(options);then enable capturing input by calling start
timer.start();If you don't want to receive any further data call timer.stop().
The signalReceived callback gets one argument: The current state of the Stackmat timer.
Available methods on it are:
state.getTimeAsString(); // => "0:32.12"
state.getTimeInMilliseconds(); // => 32120
state.isRunning(); // => true
state.isReset(); // => false
state.isLeftHandPressed(); // => true
state.isRightHandPressed(); // => falseMore options:
const options = {
onNonSupportedBrowser(){...},
signalReceived(state){...}
}You must have Node.js.
# Clone this repository
git clone git@github.com:timhabermaas/stackmat.js.git
# Install the dependencies
cd stackmat.js
npm installBuild the library (and run tests):
npm run buildRun tests:
npm run test
# or
npm run test:autoRun the example:
npm run example