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

nuimojs

v1.0.3

Published

Nuimo.js - A Node.js library for interacting with Nuimo devices

Downloads

4

Readme

Nuimo.js - A Node.js library for interacting with Nuimo devices

UPDATE 1.0.0 - Changed:

  • Nuimo will now keep scanning after discovering a device. You must manually call stop() to cease.

Installation

Node.js v6.0+ required.

npm install nuimojs --save

Nuimo.js uses the Noble BLE library by Sandeep Mistry. On macOS everything should function out of the box. On Linux and Windows there are certain dependencies which may need installed first.

Note: Nuimo.js has been tested on macOS 10.11 and Debian/Raspbian on the Raspberry Pi 3 Model B. It is also reported to work on Windows 10 (See these notes).

Usage

let Nuimo = require("nuimojs"),
    nuimo = new Nuimo();

Examples are available in the "examples" directory.

Class: Nuimo

Note: Subclass of EventEmitter.

Constructor(whitelist)

An optional whitelist of UUID's to discover. Leave undefined to discover all, or specify an array (For multiple devices) or string (For a single device).

Methods

scan()

Begins scanning for Nuimo devices.

stop()

Stops scanning for Nuimo devices.

getConnectedDevices()

Returns an array of all the connected devices (Items are instances of Device).

getConnectedDeviceByUUID(uuid)

Return the Device matching the requested UUID if it is connected.

Events

on("discover", callback(device))

Triggered when a new Nuimo device is discovered.

Class: Device

Note: Subclass of EventEmitter.

Properties

uuid

Device unique identifier.

batteryLevel

The current battery level as a percentage between 0-100.

rssi

Received Signal Strength Indicator (RSSI) value of the device.

Methods

connect(callback())

Connects to a previously discovered Nuimo device. The callback is triggered when the device is ready for interacting with.

setLEDMatrix(matrix, brightness, timeout, options = {})

Outputs a pattern to the 9x9 LED matrix on the front of the device.

Matrix is either:

  • An array of 81 items, each representing one of the 81 LED's, starting at the top left. Each item in the array should be either 0 or 1.
  • A buffer of 11 bytes, each bit representing one of the 81 LED's, with the last 7 of the 11th byte being unused.

Brightness is a value between 0-255. Timeout is how long the pattern should appear for (In milliseconds).

Two options are currently available (If options is undefined, both are disabled by default):

  • options.onionSkinning (boolean) - Allows smoother transitions between matrices.
  • options.builtinMatrix (boolean) - Use the inbuilt matrix (Undocumented, subject to change).

Note: Options may also be specified as an integer representing a bitfield, with the following values:

  • ONION_SKINNING - 16
  • BUILTIN_MATRIX - 32

Examples:

setLEDMatrix(yourmatrix, yourbrightness, yourtimeout); // Default
setLEDMatrix(yourmatrix, yourbrightness, yourtimeout, {
    onionSkinning: true,
    builtinMatrix: true
}); // Enable onion skinning and inbuilt matrix
setLEDMatrix(yourmatrix, yourbrightness, yourtimeout, 16 + 32); // Using bitfield, enable onion skinning and inbuilt matrix

Events

on("connect", callback())

Triggered when the device is ready for interacting with.

on("disconnect", callback())

Triggered when the device is disconnected.

on("batteryLevelChange", callback(level))

Triggered when the battery level drops. (Note: Level is as a percentage between 0-100)

on("rssiChange", callback(rssi))

Triggered when the RSSI changes.

The following events are triggered when the device is interacted with:

on("press", callback())

Triggered when the user presses down on the central button.

on("release", callback())

Triggered when the user releases the central button.

on("swipe", callback(direction))

Triggered when the user swipes in a direction on the central pad. Direction can be one of: Nuimo.Swipe.LEFT, Nuimo.Swipe.RIGHT, Nuimo.Swipe.UP, or Nuimo.Swipe.DOWN.

Individual events are also triggered: "swipeLeft", "swipeRight", "swipeUp", "swipeDown". No direction is passed to the callback for these events.

on("touch", callback(area))

Triggered when the user touches an area on the central pad. Area can be one of: Nuimo.Area.LEFT, Nuimo.Area.RIGHT, Nuimo.Area.TOP, Nuimo.Area.BOTTOM, Nuimo.Area.LONGLEFT, Nuimo.Area.LONGRIGHT, Nuimo.Area.LONGTOP, or Nuimo.Area.LONGBOTTOM.

Individual events are also triggered: "touchLeft", "touchRight", "touchTop", "touchBottom", "longTouchLeft", "longTouchRight", "longTouchTop", "longTouchBottom". No area is passed to the callback for these events.

on("rotate", callback(amount))

Triggered when the user rotates the outer ring. The amount is the amount of degrees the ring was rotated (Negative for counterclockwise).

on("fly", callback(direction, speed))

Triggered when the user waves their hand over the sensor. Direction is either Nuimo.Fly.LEFT or Nuimo.Fly.RIGHT.

Individual events are also triggered: "flyLeft", "flyRight". No direction is passed to the callback for these events.

Note: In earlier Nuimo firmware versions, speed could be 0, 1, or 2. In later versions, speed is always 0.

on("distance", callback(distance))

Note: This was previously named "detect", which is now deprecated.

Triggered when a hand is detected over the sensor. The distance represents how close the hand is to the sensor (Between 0-255, 255 being farthest away).

Note: This event is continuously triggered as long as a hand is detected.