first commit
This commit is contained in:
commit
a5a0434432
1126 changed files with 439481 additions and 0 deletions
30
Software/NodeJS/libs/sensors/genericDigitalOutputSensor.js
Normal file
30
Software/NodeJS/libs/sensors/genericDigitalOutputSensor.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// Thanks to Craig Watkins for the contribution
|
||||
var DigitalSensor = require('./base/digitalSensor')
|
||||
var commands = require('../commands')
|
||||
|
||||
function GenericDigitalOutputSensor(pin) {
|
||||
DigitalSensor.apply(this, Array.prototype.slice.call(arguments))
|
||||
}
|
||||
GenericDigitalOutputSensor.prototype = new DigitalSensor()
|
||||
|
||||
GenericDigitalOutputSensor.prototype.turnOn = function() {
|
||||
this.board.pinMode(this.board.OUTPUT)
|
||||
var write = this.board.writeBytes(commands.dWrite.concat([this.pin, 1, commands.unused]))
|
||||
if (write) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
GenericDigitalOutputSensor.prototype.turnOff = function() {
|
||||
this.board.pinMode(this.board.OUTPUT)
|
||||
var write = this.board.writeBytes(commands.dWrite.concat([this.pin, 0, commands.unused]))
|
||||
if (write) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GenericDigitalOutputSensor
|
||||
Loading…
Add table
Add a link
Reference in a new issue