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

radxa-rock

v0.0.14

Published

GPIO interface for the Radxa Rock

Downloads

12

Readme

Radxa Rock

This is a library for interfacing with the Radxa Rock's () GPIO.

It is still WAY in development.

Currently examples/blink/blink.js will toggle GPIO 198 on and off for 500ms. If you connect an LED from Pin 37(-) to 39(+) with a resistor you will see the LED blink on and off. You could also connect from pin 37(+) with a resistor to pin 40(-) and see the LED alternate on and off opposite the 37/38 connection.

See the reference/ folder for reference images and the led.sh file that started it all.

Install

npm install radxa-rock

API

General

Anytime there is a [callback] it is optional. If you leave it out then return values will be returned in a sync manor. Using the callback may lead to performance improvements though so you should always use the callback if you can.

All [callback]'s function the exact same, they return as:

callback(err, value)

Where err is any error that occurred and if there was no error then value is present.

radxa-rock.CONST

Contains a hash with common PIN names and number already assigned for you. See examples/blink/blink.js for a readable example.

radxa-rock.Rock()

The constructor for a new Rock object. You should only need one for your entire application.

Rock.get(pinNumber, [callback])

Returns the value of pinNumber if the PIN is in input mode. If the pin is not in input mode will return an error.

Rock.set(pinNumber, value, [callback])

Sets the value of pinNumber to the value specified if the pin is in output mode. Will return an error if the pin is not in output mode.

Rock.setPinMode(pinNumber, direction, [callback])

Sets the mode (in/out) for the specified pinNumber. Returns once the pin's mode has been set if called sync fashion, or calls the callback when the mode is set if called in the async fashion.

Rock.getPinMode(pinNumber, [callback])

Returns the mode the pin is currently in. One of:

in - The pin is setup as an input
out - The pin is setup as an output
undefined - The pin isn't setup yet

Rock.mode(pinNumber, [mode] [callback])

Sets or gets the Pin Number's mode.

pinNumber - What pin to check or set
mode - optional, if there then mode will be set to it
callback - called with the result

radxa-rock.Pin()

Constructor for a new Pin object. The Pin object provides streamlined integration of the Rock's IO Pins. Can be used instead of passing in the pin number to each Rock call. Later may be extended to implement something like polling. Will more than likely replace the Rock objects internal callers to make sure there is only one accessor of the Pin's.

Pin.mode([mode], [callback])

Get or set the underlying Pin's mode. If mode is passed in then the pin will be set to the new mode.

If callback is passed then the result will be returned to the callback.

Pin.get([callback])

Get the current value of the underlying Pin.

If callback is provided then return the value to the callback, if callback is not provided then return the value.

Pin.set(value, [callback])

Set the value of the current underlying Pin. Call the optional callback with the value once it's set.

Pin.val([value], [callback])

Shortcut to get/set the current value of the underling Pin. If value is passed then calls Pin.set(value, callback), otherwise calls Pin.get(callback).

License

The MIT License (MIT)

Copyright (c) 2014 Jeremy Darling

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Pull requests welcome for bug fixes and enhancements!