Fix bug in GPIO example.

This commit is contained in:
Edgar O Silva 2013-11-04 18:06:12 -06:00
parent 831fbe4069
commit 239056fa65
3 changed files with 5 additions and 4 deletions

2
dist/digital-pin.js vendored
View File

@ -40,7 +40,7 @@
DigitalPin.prototype.digitalWrite = function(value) {
var status;
if (this.mode !== 'w') {
setMode('w');
this._setMode('w');
}
return status = value === 1 ? 'high' : 'low';
};

View File

@ -1,5 +1,5 @@
require ('./digital-pin')
require('../src/digital-pin')
pin4 = new DigitalPin(pin: 4)
pin4 = new Cylon.IO.DigitalPin(pin: 4)
pin4.digitalWrite(1)

View File

@ -15,6 +15,7 @@ namespace = require 'node-namespace'
#
namespace 'Cylon.IO', ->
class @DigitalPin
GPIO_PATH = "/sys/class/gpio"
GPIO_DIRECTION_READ = "in"
GPIO_DIRECTION_WRITE = "out"
@ -32,7 +33,7 @@ namespace 'Cylon.IO', ->
@_setMode(opts.mode)
digitalWrite: (value) ->
setMode('w') unless @mode == 'w'
@_setMode('w') unless @mode == 'w'
status = if (value == 1) then 'high' else 'low'
# Sets the mode for the GPIO pin by writing the correct values to the pin reference files