Bumped version to 0.13.3

This commit is contained in:
edgarsilva 2014-04-21 18:15:30 -05:00
parent 050b20c945
commit 938c11872c
3 changed files with 24 additions and 26 deletions

View File

@ -187,6 +187,8 @@ Thank you!
## Release History
Version 0.13.3 - Fixes bug with disconnect functions not being called.
Version 0.13.2 - Use pure Express, adds server-sent-events, upd API.
Version 0.13.1 - Add API authentication and HTTPS support

View File

@ -27,49 +27,46 @@ namespace("Cylon.IO", function() {
var LOW = 0;
function DigitalPin(opts) {
this.pinNum = opts.pin;
this.pinNum = opts.pin.toString();
this.status = 'low';
this.ready = false;
this.mode = opts.mode;
}
DigitalPin.prototype.connect = function(mode) {
var self = this;
var _this = this;
if (this.mode == null) { this.mode = mode; }
FS.exists(this._pinPath(), function(exists) {
exists ? self._openPin() : self._createGPIOPin();
exists ? _this._openPin() : _this._createGPIOPin();
});
};
DigitalPin.prototype.close = function() {
var self = this,
num = this.pinNum.toString();
var _this = this;
FS.writeFile(this._unexportPath(), num, function(err) {
self._closeCallback(err);
FS.writeFile(this._unexportPath(), this.pinNum, function(err) {
_this._closeCallback(err);
});
};
DigitalPin.prototype.closeSync = function() {
var num = this.pinNum.toString();
FS.writeFileSync(this._unexportPath(), num);
FS.writeFileSync(this._unexportPath(), this.pinNum);
this._closeCallback(false);
};
DigitalPin.prototype.digitalWrite = function(value) {
if (this.mode !== 'w') { this._setMode('w'); }
var self = this;
var _this = this;
this.status = value === 1 ? 'high' : 'low';
FS.writeFile(this._valuePath(), value, function(err) {
if (err) {
self.emit('error', "Error occurred while writing value " + value + " to pin " + self.pinNum);
_this.emit('error', "Error occurred while writing value " + value + " to pin " + _this.pinNum);
} else {
self.emit('digitalWrite', value);
_this.emit('digitalWrite', value);
}
});
@ -83,18 +80,18 @@ namespace("Cylon.IO", function() {
//
// Returns the defined interval
DigitalPin.prototype.digitalRead = function(interval) {
var self = this;
var _this = this;
if (this.mode !== 'r') { this._setMode('r'); }
every(interval, function() {
FS.readFile(self._valuePath(), function(err, data) {
FS.readFile(_this._valuePath(), function(err, data) {
if (err) {
var error = "Error occurred while reading from pin " + self.pinNum;
self.emit('error', error);
var error = "Error occurred while reading from pin " + _this.pinNum;
_this.emit('error', error);
} else {
var readData = parseInt(data.toString());
self.emit('digitalRead', readData);
_this.emit('digitalRead', readData);
}
});
});
@ -109,14 +106,13 @@ namespace("Cylon.IO", function() {
// Creates the GPIO file to read/write from
DigitalPin.prototype._createGPIOPin = function() {
var self = this,
num = this.pinNum.toString();
var _this = this;
FS.writeFile(this._exportPath(), num, function(err) {
FS.writeFile(this._exportPath(), this.pinNum, function(err) {
if (err) {
self.emit('error', 'Error while creating pin files');
_this.emit('error', 'Error while creating pin files');
} else {
self._openPin();
_this._openPin();
}
});
};
@ -140,11 +136,11 @@ namespace("Cylon.IO", function() {
this.mode = mode;
var self = this,
var _this = this,
data = (mode === 'w') ? GPIO_WRITE : GPIO_READ;
FS.writeFile(this._directionPath(), data, function(err) {
self._setModeCallback(err, emitConnect);
_this._setModeCallback(err, emitConnect);
});
};

View File

@ -1,6 +1,6 @@
{
"name": "cylon",
"version": "0.13.2",
"version": "0.13.3",
"main": "lib/cylon.js",
"description": "A JavaScript robotics framework using Node.js",
"homepage": "http://cylonjs.com",