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

lgpio

v1.0.6

Published

lg GPIO bindings for NodeJS

Downloads

4

Readme

NodeJS bindings for lg

This package provides NodeJS bindings for the lg GPIO library.

Disclaimer

This is my first time writing native Node bindings for a C library. Heck, it's my first time writing any C/C++ code! So if things don't work as expected, or if the bindings leak memory like nobody's business, please don't be too hard on me. I'll be happy for any issue reports and / or pull requests.

Prerequisites

You need to have the lg library installed on your system. Since the library doesn't compile outside Linux, this might complicate things slightly. This package can be installed anywhere, but the bindings themselves will only be compiled on Linux to prevent npm install from dying all the time. This should enable you to develop on your local machine regardless of platform or architecture and run the code on machines which actually have GPIO for the underlying library to work with.

On a Raspberry Pi the lg library is easily downloaded, compiled and installed in three commands. Refer to the library website for the how-to.

Installation

npm install --save lgpio

Docs

The API documentation is autogenerated from the (pretty extensive) JSDocs which are present in the included TypeScript declaration files. Most of the documentation is copied verbatim from the lg library docs, only altered where it makes sense.

About

The bindings are mostly 1:1 with the underlying C functions, except the lg prefix is stripped from the function names (you'll usually want to import * as lg anyway). The call signatures are mostly kept identical, except for obvious differences:

  • All functions which indicate an error by returning a negative integer value throw an error instead; this means all functions whose return value only signifies success or failure return void in JS.
  • Passing array length separately from the array itself (as you need to do in C) is unnecessary in JS, so the array length / count parameters are omitted where applicable.
  • Some parameters can be omitted and fall back to sane defaults (like the initial output level of a GPIO, which defaults to low).