LIS2DH12 Accelerometer

The LIS2DH12 is an ultra-low-power high-performance three-axis linear accelerometer with a digital I2C/SPI serial interface.

You can use the LIS2DH12 (About Modules) module with the LIS2DH12 as follows:

SPI1.setup({miso:..., mosi:..., sck:...);
var accel = require("LIS2DH12").connectSPI(SPI1, CS_PIN, function(xyz) {
   // callback whenever dats is received
   console.log(xyz);
   // prints { "x": 3.90625, "y": -7.8125, "z": 984.375 }
});
accel.setPowerMode(on?"low":"powerdown");

Reference

// internal - read from to a register
LIS2DH12.prototype.read = function (reg, len) { ... }

// internal - write to a register
LIS2DH12.prototype.write = function (reg, data) { ... }

/* Set the power state of the accelerometer. 
  Either :

  "normal" - 100Hz
  "low" - 1Hz
  "fast" - 1000Hz
  "highres" - 1000Hz
  "powerdown" - Off
*/
LIS2DH12.prototype.setPowerMode = function (mode) { ... }

// an object with {x,y,z} elements
LIS2DH12.prototype.getXYZ = function () { ... }

// Initialise the LIS2DH12 module with the given SPI interface and CS pins
exports.connectSPI = function (spi, cs, callback) { ... }

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.