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

spark-tinker

v0.1.0

Published

Official Spark Tinker plugin for Spark API.

Downloads

2

Readme

sparkjs

Spark-Tinker is a plugin made to work with Spark Api and interact with the default tinker firmware included with the Spark core. It uses node.js and can run on Windows, Mac OS X, and Linux fairly easily. You can use it to create your own plugins and use in conjuction with the Spark Api. It's also open source so you can edit, change or even send in pull requests if you want to share!

Instalation

First, make sure you have node.js installed!

Next, open a command prompt or terminal, and install by typing:

$ npm install spark
$ npm install spark-tinker

Usage

/*jslint node: true */
"use strict";

var Spark =require('spark');

// Make sure the spark-tinker npm module is installed before
// including the plugin.
Spark.include('tinker');

Spark.on('login', function() {
  // If login is successful we get and accessToken,
  // we'll use that to call Spark API ListDevices
  var devicesPr = Spark.listDevices();

  devicesPr.then(
    // We get an array with devices back and we list them
    function(devices){
      console.log('API call List Devices: ', devices);

      // callback to be executed by each core
      var callback = function(err, data) {
        if (err) {
          console.log('An error occurred while calling function:', err);
        } else {
          console.log('function called successfully:', data);
        }
      };

      // We get the Spark core device and call Tinker commands on it:
      var core = devices[0];
      core.tinker.digitalWrite('D0', 'LOW', callback);
      //core.tinker.digitalRead('D1', callback);
      //core.tinker.analogWrite('D0', 128, callback);
      //core.tinker.analogRead('D0', callback);
    },
    function(err) {
      console.log('API call failed: ', err);
    }
  );
});

// Login as usual
Spark.login({ username: 'myUserName', password: 'MyPassword' });

For further examples visit /examples directory: https://github.com/spark/sparkjs/tree/master/examples

Getting Started

It's important that you login before executing any command and that you pull the list of devices from the cloud before using them, since all plugins that interact with custom firmwares and work on the devices themselves.

Every function returns a promise for you to handle the async result, or you can pass a callback function, or add a listner for that specific event. (Please note that if a callback function is passed, the function will return null instead of a promise)

  • More examples on how to use promises/callbacks visit: https://github.com/spark/sparkjs/tree/master/examples

Device object

You can get a list of devices by calling: spark.getDevices()

This plugin will add the following functions to each device:

  • digitalWrite() -> spark.devices[0].tinker.digitalWrite();
  • digitalRead() -> spark.devices[0].tinker.digitalRead();
  • analogRead() -> spark.devices[0].tinker.analogRead();
  • analogWrite() -> spark.devices[0].tinker.analogWrite();

Setup your dev environment

  • Install your local dependencies:
$ npm install
  • Install globally mocha, istanbul and jshint
$ npm install -g mocha
$ npm install -g istanbul
$ npm install -g jshint

How to test

make test

Lint your code

make lint

Coverage report

make cover