pif

piface

Raspberry PiFace and NodeJS

Showing:

Popularity

Downloads/wk

6

GitHub Stars

4

Maintenance

Last Commit

6yrs ago

Contributors

1

Package

Dependencies

1

License

Type Definitions

Tree-Shakeable

No?

Categories

Readme

About

Simple wrapper for the PiFace Digital and NodeJS (v4+ or v5+)

Installation

Note: recent Kernel versions need Device-Tree to be disabled in order to use SPI.

  • Install NodeJS

Follow the instructions available here: https://nodejs.org/en/download/package-manager/

(Optional) Update npm and node-gyp

npm install -g npm@latest
npm install -g node-gyp@latest
  • Download, build and install the C libraries
sudo apt-get install automake libtool git
git clone https://github.com/thomasmacpherson/piface.git
cd piface/c
./autogen.sh && ./configure && make && sudo make install
sudo ldconfig
cd ../scripts
sudo ./spidev-setup
  • Install the PiFace NodeJS module
npm install piface
  • Usage
var pfio = require("piface");

pfio.init();
var i = 0;
for (i = 0; i < 8; i++) {
    console.log("Pin #" + i + " = " + pfio.digital_read(0));
}

i = -1;
function anim() {
    i++;
    console.log("Pin #" + i + " on");
    pfio.digital_write(i, 1);
    if (i < 8) {
        setTimeout(function () {
            console.log("Pin #" + i + " off");
            pfio.digital_write(i, 0);
            if (i < 7) {
                anim();
            } else {
                pfio.deinit();
            }
        }, 250);
    }
}
anim();
  • Methods
pfio.init();
pfio.deinit();
var val = pfio.digital_read(pin); // returns 0 or 1
pfio.digital_write(pin, val);
var val = pfio.read_input(); // returns 0..255
var val = pfio.read_output(pin, val); // returns 0..255
pfio.write_output(val);

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100