Shake detector for TI SensorTag
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
.npmignore
LICENSE
README.md
index.js
package.json

README.md

SensorTag-Shake

Simple shake detection library for the TI SensorTag based on the popular SensorTag package.

Install

npm install --save sensortag-shake

Usage

var SensorTagShake = require('sensortag-shake');

var sensortagshake = new SensorTagShake('+x');

sensortagshake.on('shake', function(data){
	console.log("Shook with ", data.value, "at", data.time);
});

API

Constructor

eg : var sensortagshake = new SensorTagShake(direction, {sensorTag : sensorTagObj});

  • direction: String - The direction of shake to detect. This is a string with sign (+,-) and a coordinate (x,y,z). For eg. '+x'.
  • options : Object - An options object with the folloing optional properties.
    • sensorTag : Object - A SensorTag object, which has already discovered and connected to a SensorTag hardware. This allows a SensorTag object to be used with multiple libraries. If this optional value is not specified, this constructor will re-discover and re-connect to the SensorTag.

Events

eg : sensortagshake.on('shake', function(data){}

  • The SensorTag object emits a shake event, which contains a data object as defined below.
  • data : Object - Has the following properties.
    • value : Number - Number indicating the final accelerometer value when the shake was detected.
    • time : Number - Timestamp (msec) of the detection of the shake. This has (based on the SensorTag HW) minimum granularity of 200msec.