npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vl53l1x

v1.0.0

Published

A Node.js library for a vl53l1x TOF distance sensor

Downloads

25

Readme

VL53L1X

A Node.js library for a vl53l1x TOF distance sensor

const VL53L1X = require('vl53l1x')

//Development i2c board: https://www.npmjs.com/package/i2cdriver
// const driver = 'i2cdriver/i2c-bus'
// const busNumber = '/dev/tty.usbserial-DO01INSW'

//Builtin i2c bus: //https://www.npmjs.com/package/i2c-bus
const driver = 'i2c-bus'
const busNumber = 1

VL53L1X(busNumber, 0x29, {driver:driver}).then(async (device) => {

  device.on('data', (data) =>
    console.log(data)
  )

  await device.start()

  process.on('exit', async (code) => {
    await device.stop()
  })
})

API

All functions return a Promise.

VL53L1X(busNumber[,address[,options]])

busNumber: The bus number to use address: The i2c address of the device. (Default 0x29) options:

  • driver: The Node.js module that communicates with the i2c bus. (Default: 'i2c-bus') Any module that matches the 'i2c-bus' interface can be used.
  • config: An Array of bytes to initialize the device. (Default: VL51L1X_DEFAULT_CONFIGURATION)

vl53l1x.mode(mode)

mode: 'short' or 'long'

vl53l1x.timing()

Gets the current timing settings. returns: An object with { dwell: int, sleep: int }

vl53l1x.vl53l1x.timing(dwell, sleep = 1)

Sets the timing settings.

dwell: Time in milliseconds the device will spend collecting signals mode: Time in milliseconds the device will wait between measurements

vl53l1x.roi(width, height, center = 199)

Sets the Region Of Interest.

width: Number of SPADs to use horizontally. (min 4, max 16) height: Number of SPADs to use vertically. (min 4, max 16)

vl53l1x.offset(distance)

Sets the calibration offset.

distance: The offset distance in millimeters. Max resolution is .25 mm.

Use calibrate_offset() to determine the offset.

vl53l1x.offset(cps)

Sets the crosstalk compensation.

cps: The compensation value in cps (counts per second).

Use calibrate_xtalk() to determine the value.

vl53l1x.start()

Starts polling for data. Results are emitted to the data event.

vl53l1x.stop()

Stops polling for data.

vl53l1x.measure()

Performs a single measurement and returns the result. Results are also emitted to the data event.

returns: An object with the measurement data.

vl53l1x.calibrate_offset()

Performs offset calibration. When complete, returns the value that was written to the device. You should pass this value to vl53l1x.offset(distance) on device start.

vl53l1x.calibrate_xtalk()

Performs crosstalk calibration. When complete, returns the value that was written to the device. You should pass this value to vl53l1x.xtalk(cps) on device start.

vl53l1x.on('data', (data) => {})

Receives measurement data. Use vl53l1x.start() to start polling.

Example data:

{
  status: 0,
  ambient: 8,
  numSPADs: 4,
  sigPerSPAD: 19944,
  distance: 115
}

License

MIT