Fix bug in GPIO example.
This commit is contained in:
parent
831fbe4069
commit
239056fa65
|
@ -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';
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue