Skip to content

timhabermaas/stackmat.js

Repository files navigation

Stackmat.js

Build Status npm version

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/

Installation

npm install stackmat.js

Usage

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){...}
}

Contribute

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

About

Access the Stackmat Timer from within JavaScript using the HTML5 Audio API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published