Bumped version to 0.13.3
This commit is contained in:
parent
050b20c945
commit
938c11872c
|
@ -187,6 +187,8 @@ Thank you!
|
||||||
|
|
||||||
## Release History
|
## 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.2 - Use pure Express, adds server-sent-events, upd API.
|
||||||
|
|
||||||
Version 0.13.1 - Add API authentication and HTTPS support
|
Version 0.13.1 - Add API authentication and HTTPS support
|
||||||
|
|
|
@ -27,49 +27,46 @@ namespace("Cylon.IO", function() {
|
||||||
var LOW = 0;
|
var LOW = 0;
|
||||||
|
|
||||||
function DigitalPin(opts) {
|
function DigitalPin(opts) {
|
||||||
this.pinNum = opts.pin;
|
this.pinNum = opts.pin.toString();
|
||||||
this.status = 'low';
|
this.status = 'low';
|
||||||
this.ready = false;
|
this.ready = false;
|
||||||
this.mode = opts.mode;
|
this.mode = opts.mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
DigitalPin.prototype.connect = function(mode) {
|
DigitalPin.prototype.connect = function(mode) {
|
||||||
var self = this;
|
var _this = this;
|
||||||
|
|
||||||
if (this.mode == null) { this.mode = mode; }
|
if (this.mode == null) { this.mode = mode; }
|
||||||
|
|
||||||
FS.exists(this._pinPath(), function(exists) {
|
FS.exists(this._pinPath(), function(exists) {
|
||||||
exists ? self._openPin() : self._createGPIOPin();
|
exists ? _this._openPin() : _this._createGPIOPin();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
DigitalPin.prototype.close = function() {
|
DigitalPin.prototype.close = function() {
|
||||||
var self = this,
|
var _this = this;
|
||||||
num = this.pinNum.toString();
|
|
||||||
|
|
||||||
FS.writeFile(this._unexportPath(), num, function(err) {
|
FS.writeFile(this._unexportPath(), this.pinNum, function(err) {
|
||||||
self._closeCallback(err);
|
_this._closeCallback(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
DigitalPin.prototype.closeSync = function() {
|
DigitalPin.prototype.closeSync = function() {
|
||||||
var num = this.pinNum.toString();
|
FS.writeFileSync(this._unexportPath(), this.pinNum);
|
||||||
|
|
||||||
FS.writeFileSync(this._unexportPath(), num);
|
|
||||||
this._closeCallback(false);
|
this._closeCallback(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
DigitalPin.prototype.digitalWrite = function(value) {
|
DigitalPin.prototype.digitalWrite = function(value) {
|
||||||
if (this.mode !== 'w') { this._setMode('w'); }
|
if (this.mode !== 'w') { this._setMode('w'); }
|
||||||
|
|
||||||
var self = this;
|
var _this = this;
|
||||||
this.status = value === 1 ? 'high' : 'low';
|
this.status = value === 1 ? 'high' : 'low';
|
||||||
|
|
||||||
FS.writeFile(this._valuePath(), value, function(err) {
|
FS.writeFile(this._valuePath(), value, function(err) {
|
||||||
if (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 {
|
} else {
|
||||||
self.emit('digitalWrite', value);
|
_this.emit('digitalWrite', value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -83,18 +80,18 @@ namespace("Cylon.IO", function() {
|
||||||
//
|
//
|
||||||
// Returns the defined interval
|
// Returns the defined interval
|
||||||
DigitalPin.prototype.digitalRead = function(interval) {
|
DigitalPin.prototype.digitalRead = function(interval) {
|
||||||
var self = this;
|
var _this = this;
|
||||||
|
|
||||||
if (this.mode !== 'r') { this._setMode('r'); }
|
if (this.mode !== 'r') { this._setMode('r'); }
|
||||||
|
|
||||||
every(interval, function() {
|
every(interval, function() {
|
||||||
FS.readFile(self._valuePath(), function(err, data) {
|
FS.readFile(_this._valuePath(), function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
var error = "Error occurred while reading from pin " + self.pinNum;
|
var error = "Error occurred while reading from pin " + _this.pinNum;
|
||||||
self.emit('error', error);
|
_this.emit('error', error);
|
||||||
} else {
|
} else {
|
||||||
var readData = parseInt(data.toString());
|
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
|
// Creates the GPIO file to read/write from
|
||||||
DigitalPin.prototype._createGPIOPin = function() {
|
DigitalPin.prototype._createGPIOPin = function() {
|
||||||
var self = this,
|
var _this = this;
|
||||||
num = this.pinNum.toString();
|
|
||||||
|
|
||||||
FS.writeFile(this._exportPath(), num, function(err) {
|
FS.writeFile(this._exportPath(), this.pinNum, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
self.emit('error', 'Error while creating pin files');
|
_this.emit('error', 'Error while creating pin files');
|
||||||
} else {
|
} else {
|
||||||
self._openPin();
|
_this._openPin();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -140,11 +136,11 @@ namespace("Cylon.IO", function() {
|
||||||
|
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
|
|
||||||
var self = this,
|
var _this = this,
|
||||||
data = (mode === 'w') ? GPIO_WRITE : GPIO_READ;
|
data = (mode === 'w') ? GPIO_WRITE : GPIO_READ;
|
||||||
|
|
||||||
FS.writeFile(this._directionPath(), data, function(err) {
|
FS.writeFile(this._directionPath(), data, function(err) {
|
||||||
self._setModeCallback(err, emitConnect);
|
_this._setModeCallback(err, emitConnect);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cylon",
|
"name": "cylon",
|
||||||
"version": "0.13.2",
|
"version": "0.13.3",
|
||||||
"main": "lib/cylon.js",
|
"main": "lib/cylon.js",
|
||||||
"description": "A JavaScript robotics framework using Node.js",
|
"description": "A JavaScript robotics framework using Node.js",
|
||||||
"homepage": "http://cylonjs.com",
|
"homepage": "http://cylonjs.com",
|
||||||
|
|
Loading…
Reference in New Issue