tessel/camera-vc0706 — pull request #8 by EvanSimpson (2014-05-29 22:06:51+00:00)
Title: Implement .use() configuration

Camera now configurable from .use() option, for one or both of compression and resolution.
```'ready'``` is not emitted until all configurations have completed without error.

An example using this new configuration:

```js
var tessel = require('tessel');
var Camera = require('camera-vc0706')

var camera = Camera.use(tessel.port['A'], {
compression: 255,
resolution: 'vga'
}, function(){console.log('Camera callback called')});

var notificationLED = tessel.led[3]; // Set up an LED to notify when we're taking a picture

// Wait for the camera module to say it's ready
camera.on('ready', function() {
notificationLED.high();
// Take the picture
camera.takePicture(function(err, image) {
if (err) {
console.log('error taking image', err);
} else {
notificationLED.low();
// Name the image
var name = 'picture-' + Math.floor(Date.now()*1000) + '.jpg';
// Save the image
console.log('Picture saving as', name, '...');
process.sendfile(name, image);
console.log('done.');
// Turn the camera off to end the script
camera.disable();
}
});
});

camera.on('error', function(err) {
console.error(err);
});
```