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

odroid-gpio

v0.0.2

Published

A simple node.js-based GPIO helper for the Odroid c1

Downloads

9

Readme

odroid-gpio

odroid-gpio is a simple node.js based library to help access the GPIO of the Odoid C1.

var gpio = require("odroid-gpio");

gpio.open(16, "output", function(err) {		// Open pin 16 for output
	gpio.write(16, 1, function() {			// Set pin 16 high (1)
		gpio.close(16);						// Close pin 16
	});
});

Pin configuration

You can use the physical numbering:

Odroid pins

Requirement: gpio-admin

The GPIO pins require you to be root to access them. That's totally unsafe for several reasons. To get around this problem, you should use the excellent gpio-admin.

Do the following on your raspberry pi:

git clone git://github.com/quick2wire/quick2wire-gpio-admin.git
cd quick2wire-gpio-admin
make
sudo make install
sudo adduser $USER gpio

replaceing $USER your username.

After this, you will need to logout and log back in.

Usage

.open(pinNumber, [options], [callback])

Aliased to .export

Makes pinNumber available for use.

  • pinNumber: The pin number to make available. Remember, pinNumber is the physical pin number on the Pi.
  • options: (Optional) Should be a string, such as input or input pullup. You can specify whether the pin direction should be input or output (or in or out). You can additionally set the internal pullup / pulldown resistor by sepcifying pullup or pulldown (or up or down). If options isn't provided, it defaults to output. If a direction (input or output) is not specified (eg. only up), then the direction defaults to output.
  • callback: (Optional) Will be called when the pin is available for use. May receive an error as the first argument if something went wrong.

.close(pinNumber, [callback])

Aliased to .unexport

Closes pinNumber.

  • pinNumber: The pin number to close. Again, pinNumber is the physical pin number on the Pi.
  • callback: (Optional) Will be called when the pin is closed. Again, may receive an error as the first argument.

.setDirection(pinNumber, direction, [callback])

Changes the direction from input to output or vice-versa.

  • pinNumber: As usual.
  • direction: Either input or in or output or out.
  • callback: Will be called when direction change is complete. May receive an error as usual.

.getDirection(pinNumber, [callback])

Gets the direction of the pin. Acts like a getter for the method above.

  • pinNumber: As usual
  • callback: Will be called when the direction is received. The first argument could be an error. The second argument will either be in or out.

.read(pinNumber, [callback])

Reads the current value of the pin. Most useful if the pin is in the input direction.

  • pinNumber: As usual.
  • callback: Will receive a possible error object as the first argument, and the value of the pin as the second argument. The value will be either 0 or 1 (numeric).

Example:

gpio.read(16, function(err, value) {
	if(err) throw err;
	console.log(value);	// The current state of the pin
});

.write(pinNumber, value, [callback])

Writes value to pinNumber. Will obviously fail if the pin is not in the output direction.

  • pinNumber: As usual.
  • value: Should be either a numeric 0 or 1. Any value that isn't 0 or 1 will be coerced to be boolean, and then converted to 0 (false) or 1 (true). Just stick to sending a numeric 0 or 1, will you? ;)
  • callback: Will be called when the value is set. Again, might receive an error.

Misc

  • To run tests: npm install && npm test where you've got the checkout.
  • This module was created, git push'ed and npm publish'ed all from the Raspberry Pi! The Pi rocks!

Inspiration

This lib is inspired by pi-gpio.

MIT License