0.1.0 • Published 9 years ago

pidee v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

Pidee Node.js Module

Requirements

If you have not do so already, pidee-service needs to be installed and running on the Raspberry Pi.

Installing pidee-service

To install and run pidee-service first ssh into your Raspberry Pi then run the following commands:

sudo echo "deb http://pidee.theworkers.net/raspbian wheezy main" >> /etc/apt/sources.list
wget -qO - http://pidee.theworkers.net/pidee.public.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install pidee

How to use

npm install pidee

Adds the node pidee module from npm to your project.

API

pidee.on( domain, callback )

Listen for pidee change events. The domain can be: 'dip', 'button', 'dip.1', 'dip.2'. See domains for full list.

Example:

pidee.on( 'bottom', function ( value ) {
    // Button has changed
});

pidee.get( domain )

Returns a value on the pidee board. The domain can be: 'dip', 'button', 'dip.1', 'dip.2' etc. See domains for full list.

Example:
var value = pidee.get( 'dip.1' ) // return 0 or 1

pidee.set( domain, value )

Sets the value of the leds. The domain can be: 'led.yellow', 'led.green', 'led.blue'. See domains for full list.

Example:
`var value = pidee.get( 'led.yellow', true );

pidee.on( 'error', callback )

Listen to error events. The callback function should be in the form: function ( err, errorCode, message ). Without this errors will be thrown.

Example:

pidee.on( 'error', function ( err, errorCode, message ) {
    console.log( 'Pidee error:', err );
    console.log( 'Pidee error code:', code );
    console.log( 'Pidee error message:', message );
});

Example

var Pidee = require( 'pidee' );

var pidee = new Pidee();

pidee.on( 'error', function ( err, code, message ) {
    console.log( 'Pidee error:', err );
    console.log( 'Pidee error code:', code );
    console.log( 'Pidee error message:', message );
});

pidee.open( function () {

    // Turn on yellow led
    pidee.set( 'led.yellow', Pidee.ON );

    // Get the dip value
    var value = pidee.get( 'dip' );

    // Listen for button presses
    pidee.on( 'button', function ( value ) {
        console.log( 'Button changes', value );
    });

});

Domains

DomainValue Range
all
led0,7
led.yellow0,1
led.green0,1
led.red0,1
dip0,255
dip.00,1
dip.10,1
dip.20,1
dip.30,1
dip.40,1
dip.50,1
dip.60,1
dip.70,1
button0,1
DomainGETSETON
led
dip
button
all