set "both" as default so on or off triggers

master
David Kebler 2017-01-25 14:13:51 -08:00
parent 19ea1f88ff
commit 846979a48f
1 changed files with 6 additions and 6 deletions

View File

@ -19,15 +19,15 @@ class Interrupt extends EventEmitter {
this.num = pin_number;
this.hook = opts.hook // will be passed back with the emit
this.path = GPIO_ROOT_PATH + 'gpio' + this.num + '/'
this.edge = opts.edge // default 'falling'
this.edge = opts.edge // default 'both'
this.delay = opts.delay // default = 50
this.pullup = opts.pullup ? opts.pullup : (num, state) => { return `raspi-gpio set ${num} ${state}` } // default rpi using raspi-gpio
// this.pullup = (num, state) => { return `raspi-gpio set ${num} ${state}` }
this.dbt = opts.debounce ? opts.debounce : 300
this.dbt = opts.debounce ? opts.debounce : 200
this.poller = new Epoll(
debounce((err, fd, events) => {
if (err) { this.emit('error', err) } else { this.clear().then(this.emit('fired', this.hook)) }
}, this.dbt, true)
}, this.dbt, true) // true = leading
)
}
@ -42,7 +42,7 @@ class Interrupt extends EventEmitter {
this._pull(this.num),
this._export(this.num),
this._direction('in', this.delay),
() => this._edge(this.edge),
() => this._edge(this.edge), // TODO determine why these need additional function
() => this._fd(),
() => this.clear().then(() => {
this.start()
@ -95,7 +95,7 @@ class Interrupt extends EventEmitter {
this.poller.remove(this.valuefd).close();
}
/**************/
/*******private methods*********/
_pull(num, state = 'pu') {
if (this.pullup === 'external') { return Promise.resolve('pull must be set externally') } else {
@ -131,7 +131,7 @@ class Interrupt extends EventEmitter {
})
}
_edge(edge = 'falling') {
_edge(edge = 'both') {
return fs.writeFile(this.path + 'edge', edge)
.then(() => {
return Promise.resolve('edge set')