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.js
First, 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(); // => false
More options:
const options = {
onNonSupportedBrowser(){...},
signalReceived(state){...}
}
You must have Node.js.
# Clone this repository
git clone [email protected]:timhabermaas/stackmat.js.git
# Install the dependencies
cd stackmat.js
npm install
Build the library (and run tests):
npm run build
Run tests:
npm run test
# or
npm run test:auto
Run the example:
npm run example