working on interrupt init

master
David Kebler 2017-01-24 14:46:01 -08:00
parent 8368b5d3fe
commit ba2db815e5
1 changed files with 10 additions and 5 deletions

View File

@ -19,17 +19,23 @@ class MCP23008 extends Device {
init() { init() {
// console.log('chip configuration', chip_config.cmd, chipSetByte()) // console.log('chip configuration', chip_config.cmd, chipSetByte())
// console.log(super.write.toString()) // console.log(super.write.toString())
let jobs = [super.write(chip_config.cmd, chipSetByte(this.chip_config))] // configure chip let jobs = [() => { return super.write(chip_config.cmd, chipSetByte(this.chip_config)) }] // configure chip
for (let port in this.ports) { for (let port in this.ports) {
if (this.ports[port].interrupt) { jobs.push(this.ports[port].interrupt.init()) } if (this.inter(port)) {
console.log('interrupt init', this.inter(port).init().toString())
jobs.push(() => { return this.inter(port).init() })
} }
jobs.push(this.writePinsCfg()) }
jobs.push(() => { return this.writePinsCfg() })
return _u.pSeries(jobs) return _u.pSeries(jobs)
} }
pin(id) { return this.ports.A.pin(id) } // get a reference to a particular pin's object pin(id) { return this.ports.A.pin(id) } // get a reference to a particular pin's object
interrupt(port = 'A') { return this.ports[port].interrupt } inter(port = 'A') {
return this.ports[port].interrupt
}
// pin configurations should already be set before calling // pin configurations should already be set before calling
writePinsCfg() { writePinsCfg() {
@ -133,7 +139,6 @@ class MCP23017 extends MCP23008 {
opts.portID = 'B' opts.portID = 'B'
this.ports.B = new Port(opts) this.ports.B = new Port(opts)
this.ports.B.interrupt = opts.interruptB ? opts.interruptB : opts.interrupt this.ports.B.interrupt = opts.interruptB ? opts.interruptB : opts.interrupt
} }
pin(id, port) { pin(id, port) {