fix super calls to write and promise chains
parent
f724ef775e
commit
860b38b621
|
@ -13,7 +13,6 @@ class MCP23008 extends Device {
|
|||
this.ports = {}
|
||||
opts.portID = 'A'
|
||||
this.ports.A = new Port(opts)
|
||||
console.log(this.ports.A)
|
||||
// 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
|
||||
if (opts.interPin) {
|
||||
|
@ -22,9 +21,9 @@ class MCP23008 extends Device {
|
|||
} // end constructor
|
||||
|
||||
init() {
|
||||
console.log('chip ', chip_config.cmd, chipSetByte())
|
||||
return this.write(chip_config.cmd, chipSetByte()) // configure chip
|
||||
.then(this.writePinsCfg())
|
||||
console.log('chip configuration', chip_config.cmd, chipSetByte())
|
||||
return super.write(chip_config.cmd, chipSetByte()) // configure chip
|
||||
.then(() => { return this.writePinsCfg() })
|
||||
|
||||
}
|
||||
|
||||
|
@ -45,7 +44,7 @@ class MCP23008 extends Device {
|
|||
}
|
||||
// console.log(`port ${port} - setting ${setting} - reg ${reg} - byte ${byte}`)
|
||||
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}`))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,10 @@
|
|||
expect(mcp8.pin(8).cfg.ivrt, "pin address getter failed").to.equal(1)
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
const ADDR = 0x20,
|
||||
W = 0x09,
|
||||
R = 0x0A,
|
||||
|
@ -87,21 +91,21 @@
|
|||
name: 'outputs 1-8'
|
||||
})
|
||||
|
||||
let tasks = [
|
||||
testout.init(),
|
||||
testout.write(W, PINSON)
|
||||
// let tasks = [
|
||||
// testout.init(),
|
||||
// testout.write(W, PINSON)
|
||||
//
|
||||
// ]
|
||||
|
||||
]
|
||||
|
||||
testout.init().then(() =>
|
||||
testout.write(W, PINSON).then(() =>
|
||||
testout.read(R).then((resp) => {
|
||||
testout.init()
|
||||
.then(() => {
|
||||
return testout.write(W, PINSON)
|
||||
.then(() => {
|
||||
return testout.read(R)
|
||||
.then((resp) => {
|
||||
console.log('Pins Set On', resp)
|
||||
testout.write(W, PINSOFF)
|
||||
return testout.write(W, PINSOFF)
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
})
|
||||
})
|
||||
.catch(err => console.log('errors:', err))
|
||||
|
|
Loading…
Reference in New Issue