sensortag-shake

1.0.3 • Public • Published

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.

Readme

Keywords

Package Sidebar

Install

npm i sensortag-shake

Weekly Downloads

0

Version

1.0.3

License

MIT

Last publish

Collaborators

  • notthetup