# piface

> Raspberry Pi PiFace

Latest version **2.0.10** (published 2016-03-09) · 0 weekly downloads

## Install

```sh
npm install piface
pnpm add piface
yarn add piface
bun add piface
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.10 |
| Published | 2016-03-09 |
| First published | 2016-03-07 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4.0.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Ced-Dev |
| Maintainers | ced-dev |
| Keywords | PiFace, Raspberry Pi |

## Links

- npm: https://www.npmjs.com/package/piface
- Repository: https://github.com/ced-dev/piface
- Homepage: https://github.com/ced-dev/piface#readme
- Issues: https://github.com/ced-dev/piface/issues
- npm.io page: https://npm.io/package/piface

## Dependencies (1)

- [node-gyp](https://npm.io/package/node-gyp.md) >= 2.0.0

## Recent versions

- 2.0.10 (latest) — 2016-03-09
- 2.0.9 — 2016-03-09
- 2.0.8 — 2016-03-09
- 2.0.7 — 2016-03-09
- 2.0.6 — 2016-03-08
- 2.0.5 — 2016-03-08
- 2.0.4 — 2016-03-08
- 2.0.3 — 2016-03-08
- 2.0.2 — 2016-03-07
- 2.0.1 — 2016-03-07
- 2.0.0 — 2016-03-07
- 1.0.1 — 2016-03-07
- 1.0.0 — 2016-03-07

## README

### About
Simple wrapper for the <a href="http://www.piface.org.uk/products/piface_digital/" target="_new">PiFace Digital</a> 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/

- 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

```javascript
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

```javascript
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);
```

---
_Source: https://npm.io/package/piface · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
