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

@steveyeh/vernier-godirect

v1.8.9

Published

A JavaScript library to easily interact with [Vernier Go Direct® Sensors](https://www.vernier.com/products/sensors/go-direct-sensors).

Downloads

45

Readme

GODIRECT JS - Vernier Go Direct® Sensor Library

Build Status Dependabot

A JavaScript library to easily interact with Vernier Go Direct® Sensors.

This is a modified version of the original @vernier/godirect package, changing minMeasurementPeriod to 1.

Requirements

This library is currently only implemented using WebBluetooth and WebHID both of which have limited browser support

Partial WebHID functionality is available in Chrome 78 behind a flag on desktop OSes. You will need to enable the "Experimental Web Platform Features" flag (chrome://flags/#enable-experimental-web-platform-features) and restart Chrome.

Installation

Use the unpkg module version of library in your HTML document:

<script src="https://unpkg.com/@steveyeh/vernier-godirect/dist/godirect.min.umd.js"></script>

Use the library as a JavaScript module:

  1. Install the module via npm:
$ npm i @steveyeh/vernier-godirect
  1. Import the module into your JavaScript file:
import godirect from './node_modules/@steveyeh/vernier-godirect/dist/godirect.min.esm.js';

Example Usage

HTML

A user action is required to open the BLE device list in the browser (e.g. a user click event from a button). Create a button to initiate the request.

<button id="select_device">Select Go Direct Device</button>

JavaScript

Listen for the button click event.

const selectDeviceBtn = document.querySelector('#select_device');

selectDeviceBtn.addEventListener('click', async () => {
  // All following code will go here.
});

Open the browsers device list chooser. This call returns your selected device back. We'll assign the selected device to a constant called device;

NOTE: you cannot invoke godirect.selectDevice() outside of a user interaction, like a click event. This is part of the browser security model.

// opens the browser list of ble devices matching to GDX
const device = await godirect.selectDevice();

// Get a filtered array of only the enabled sensor(s).
const enabledSensors = device.sensors.filter(s => s.enabled);

// Loop through the array of `enabledSensors` and log the value changes.
enabledSensors.forEach(sensor => {
  sensor.on('value-changed', (sensor) => {
    // log the sensor name, new value, and units.
    console.log(`Sensor: ${sensor.name} value: ${sensor.value} units: ${sensor.unit}`);
  });
});

See this example and others (including our Python versions) at our examples repository: https://github.com/VernierST/godirect-examples or visit the live demos

License

BSD 3-Clause License.

Vernier products are designed for educational use. Our products are not designed nor are they recommended for any industrial, medical, or commercial process such as life support, patient diagnosis, control of a manufacturing process, or industrial testing of any kind.