woodyrew / node-pilite

Node.js module for communicating with a Pi Lite
MIT License
0 stars 0 forks source link

pilite

PiLite API module for programming in node.js.

The API mostly mirrors the functionality provided by the serial communications but with handy methods and value validations. The source code isn't complicated and will help you better understand how it works.

What's a piLite?

It's a credit card sized pcb that snugly fits on top of a Raspberry Pi.

Ciseco piLite

See [Using the Pi-Lite pre-loaded software](http://openmicros.org/index.php/articles/94-ciseco-product-documentation/raspberry-pi/280#Using the Pi-Lite pre-loaded software) for the commands that are used with this module.

Getting Started

First of all, run through the piLite setup instructions before plugging it in

Not got node installed on your Pi? Check out the install instructions for the Raspberry Pi - you don't need to npm install serial as it's included in this module.

Install the module with: npm install pilite

var pilite = require('pilite');
pilite.connect(function() {
    // Run piLite commands
}

Example

var pilite = require('pilite');

pilite.connect(function() {
    pilite.clear();

    // Toggles a random pixel twice a second.
    var timer = setInterval(function() {
        column = 1 + Math.floor(Math.random() * 14),
        row = 1 + Math.floor(Math.random() * 9);

        pilite.pixel(column, row, "TOGGLE");
    }, 500);
});

API methods

Please read the source code to get a better understanding of each of these methods, what's expected in the parameters is documented there. The unit tests are also useful to this end.

setSpeed(value, options)

Set scrolling delay in ms 1 is scrolling very fast, 1000 is scrolling very slow. Default speed is 80.

frameBuffer(value, options)

Sets a frame instantly in one go. This is the most efficient method of updating the state of the PiLite if you want to do animations or multiple state changes at once without a bit of lag.

Using a 126 character string in ones and zeros to represent each LED state (on or off)

barGraph(column, value, options)

Sets a column to a percentage

chart(data, options)

Create graph from an array (max 14 columns)

vuMeter(row, value, options)

vuMeter - Horizontal bar graph

pixel(column, row, action, options)

Set a pixel's state

all(value, options)

Set all the pixels on or off

'clear(options)'

Turns all pixels off - Alias to ALL,OFF

'scroll(value, options)'

Scroll value columns left (+) or right (-)

text(column, row, character, options)

Display character at location x,y.

write(data)

Writes commands to the serial to instruct the Pi Lite. You can use this to pass text to scroll.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Credits

Fabrizio Codello's Example Gist provided the basis for this module.

Release History

License

Copyright (c) 2013 Andrew Goodricke
Licensed under the MIT license.