fix super calls to write and promise chains

master
David Kebler 2017-01-16 00:04:24 -08:00
parent f724ef775e
commit 860b38b621
2 changed files with 34 additions and 31 deletions

View File

@ -13,7 +13,6 @@ class MCP23008 extends Device {
this.ports = {} this.ports = {}
opts.portID = 'A' opts.portID = 'A'
this.ports.A = new Port(opts) this.ports.A = new Port(opts)
console.log(this.ports.A)
// if not specified there RPi is not managing the interrupt // if not specified there RPi is not managing the interrupt
// pin number on RPi that is connected to and services the interrupt. 4/17/27/22 = 7/11/13/15 // pin number on RPi that is connected to and services the interrupt. 4/17/27/22 = 7/11/13/15
if (opts.interPin) { if (opts.interPin) {
@ -22,9 +21,9 @@ class MCP23008 extends Device {
} // end constructor } // end constructor
init() { init() {
console.log('chip ', chip_config.cmd, chipSetByte()) console.log('chip configuration', chip_config.cmd, chipSetByte())
return this.write(chip_config.cmd, chipSetByte()) // configure chip return super.write(chip_config.cmd, chipSetByte()) // configure chip
.then(this.writePinsCfg()) .then(() => { return this.writePinsCfg() })
} }
@ -45,7 +44,7 @@ class MCP23008 extends Device {
} }
// console.log(`port ${port} - setting ${setting} - reg ${reg} - byte ${byte}`) // console.log(`port ${port} - setting ${setting} - reg ${reg} - byte ${byte}`)
jobs.push( jobs.push(
() => this.write(reg, byte) // .then((resp)=>console.log(`done writing config ${resp}`)) () => super.write(reg, byte) //.then((resp) => console.log(`done writing config ${resp}`))
) )
} }
} }

View File

@ -76,6 +76,10 @@
expect(mcp8.pin(8).cfg.ivrt, "pin address getter failed").to.equal(1) expect(mcp8.pin(8).cfg.ivrt, "pin address getter failed").to.equal(1)
}); });
});
});
const ADDR = 0x20, const ADDR = 0x20,
W = 0x09, W = 0x09,
R = 0x0A, R = 0x0A,
@ -87,21 +91,21 @@
name: 'outputs 1-8' name: 'outputs 1-8'
}) })
let tasks = [ // let tasks = [
testout.init(), // testout.init(),
testout.write(W, PINSON) // testout.write(W, PINSON)
//
// ]
] testout.init()
.then(() => {
testout.init().then(() => return testout.write(W, PINSON)
testout.write(W, PINSON).then(() => .then(() => {
testout.read(R).then((resp) => { return testout.read(R)
.then((resp) => {
console.log('Pins Set On', resp) console.log('Pins Set On', resp)
testout.write(W, PINSOFF) return testout.write(W, PINSOFF)
}) })
) })
) })
.catch(err => console.log('errors:', err))
});
});