Install onoff for better button watching
This commit is contained in:
parent
77a10fa80a
commit
524aba90d8
|
@ -1,6 +1,26 @@
|
|||
'use strict'
|
||||
|
||||
const gpio = require('gpio')
|
||||
const Gpio = require('onoff')
|
||||
const PINS = {
|
||||
fwd : {
|
||||
pin : 4,
|
||||
dir : 'out'
|
||||
},
|
||||
bwd : {
|
||||
pin : 5,
|
||||
dir : 'out'
|
||||
},
|
||||
micro : {
|
||||
pin : 6,
|
||||
dir : 'in',
|
||||
edge : 'rising'
|
||||
},
|
||||
release : {
|
||||
pin : 7,
|
||||
dir : 'in',
|
||||
edge : 'both'
|
||||
}
|
||||
}
|
||||
|
||||
class Intval {
|
||||
constructor () {
|
||||
|
@ -9,20 +29,10 @@ class Intval {
|
|||
this._declarePins()
|
||||
}
|
||||
_declarePins () {
|
||||
this._pin.fwd = gpio.export(4, {
|
||||
direction: 'out',
|
||||
interval: 100,
|
||||
ready : () => {
|
||||
console.info(`Set pin 4 to OUTPUT`)
|
||||
}
|
||||
})
|
||||
this._pin.bwd = gpio.export(5, {
|
||||
direction: 'out',
|
||||
interval: 100,
|
||||
ready : () => {
|
||||
console.info(`Set pin 5 to OUTPUT`)
|
||||
}
|
||||
})
|
||||
this._pin.fwd = Gpio(4, 'out')
|
||||
this._pin.bwd = Gpio(5, 'out')
|
||||
this._pin.micro = Gpio(6, 'in', 'rising')
|
||||
this._pin.release = Gpio(7, 'in', 'both')
|
||||
}
|
||||
_startFwd () {
|
||||
this._pin.fwd.set(1)
|
||||
|
|
|
@ -30,6 +30,11 @@
|
|||
"tweetnacl": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz"
|
||||
}
|
||||
},
|
||||
"bindings": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz",
|
||||
"integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE="
|
||||
},
|
||||
"bleno": {
|
||||
"version": "https://registry.npmjs.org/bleno/-/bleno-0.4.2.tgz",
|
||||
"integrity": "sha1-IesK10O850eU45L0ph4TsHOT26o=",
|
||||
|
@ -161,6 +166,15 @@
|
|||
"jsbn": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz"
|
||||
}
|
||||
},
|
||||
"epoll": {
|
||||
"version": "0.1.22",
|
||||
"resolved": "https://registry.npmjs.org/epoll/-/epoll-0.1.22.tgz",
|
||||
"integrity": "sha1-GrmmN8/xGiCXDIiLHKIXi2TPUpE=",
|
||||
"requires": {
|
||||
"bindings": "1.2.1",
|
||||
"nan": "https://registry.npmjs.org/nan/-/nan-2.6.2.tgz"
|
||||
}
|
||||
},
|
||||
"escape-regexp-component": {
|
||||
"version": "https://registry.npmjs.org/escape-regexp-component/-/escape-regexp-component-1.0.2.tgz",
|
||||
"integrity": "sha1-nGO20LJf8qiMOtvRjFthrMO5+qI="
|
||||
|
@ -371,8 +385,7 @@
|
|||
},
|
||||
"nan": {
|
||||
"version": "https://registry.npmjs.org/nan/-/nan-2.6.2.tgz",
|
||||
"integrity": "sha1-5P805slf37WuzAjeZZb0NgWn20U=",
|
||||
"optional": true
|
||||
"integrity": "sha1-5P805slf37WuzAjeZZb0NgWn20U="
|
||||
},
|
||||
"ncp": {
|
||||
"version": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz",
|
||||
|
@ -403,6 +416,14 @@
|
|||
"wrappy": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz"
|
||||
}
|
||||
},
|
||||
"onoff": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/onoff/-/onoff-1.1.5.tgz",
|
||||
"integrity": "sha1-tkT9pSe4eJ60ZDwD9YIqqVclCu4=",
|
||||
"requires": {
|
||||
"epoll": "0.1.22"
|
||||
}
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"cron": "^1.2.1",
|
||||
"gpio": "^0.2.7",
|
||||
"node-ipc": "^9.1.0",
|
||||
"onoff": "^1.1.5",
|
||||
"restify": "^5.2.0",
|
||||
"uuid": "^3.1.0",
|
||||
"winston": "^2.3.1"
|
||||
|
|
Loading…
Reference in New Issue