pidee
v0.1.0
Published
Pidee Node.js Module ====================
Downloads
2
Readme
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
| Domain | Value Range | |-----------------|:-----------:| | all | | | led | [0,7] | | led.yellow | [0,1] | | led.green | [0,1] | | led.red | [0,1] | | dip | [0,255] | | dip.0 | [0,1] | | dip.1 | [0,1] | | dip.2 | [0,1] | | dip.3 | [0,1] | | dip.4 | [0,1] | | dip.5 | [0,1] | | dip.6 | [0,1] | | dip.7 | [0,1] | | button | [0,1] |
| Domain | GET | SET | ON | |---------|:--------:|:--------:|:-------------:| | led | | ✓ | | | dip | ✓ | | ✓ | | button | ✓ | | ✓ | | all | ✓ | | ✓ |