first commit
This commit is contained in:
commit
a5a0434432
1126 changed files with 439481 additions and 0 deletions
29
Software/NodeJS/libs/sensors/SPDTRelay.js
Normal file
29
Software/NodeJS/libs/sensors/SPDTRelay.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
var DigitalSensor = require('./base/digitalSensor'),
|
||||
commands = require('../commands')
|
||||
|
||||
function SPDTRelay(pin) {
|
||||
DigitalSensor.apply(this, Array.prototype.slice.call(arguments))
|
||||
}
|
||||
SPDTRelay.prototype = new DigitalSensor()
|
||||
|
||||
SPDTRelay.prototype.on = 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
|
||||
}
|
||||
}
|
||||
|
||||
SPDTRelay.prototype.off = 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 = SPDTRelay
|
||||
Loading…
Add table
Add a link
Reference in a new issue