add documentation
parent
ecb455e7ea
commit
7e3e92db14
|
@ -46,8 +46,14 @@ class MCP23008 extends Device {
|
|||
.then(() => {
|
||||
return this.inter(port).start()
|
||||
.then(() => {
|
||||
this.inter(port).on('fired', () => {
|
||||
console.log(`interrupt port ${port} hook me \n ${relays}`)
|
||||
// hook.bind(this)(port)
|
||||
|
||||
})
|
||||
return Promise.resolve(`interrupt port ${port} started`)
|
||||
})
|
||||
.catch(err => console.log("error:", err))
|
||||
})
|
||||
)
|
||||
}
|
||||
|
@ -83,7 +89,7 @@ class MCP23008 extends Device {
|
|||
for (let port in this.ports) {
|
||||
for (let setting in registers.pin_config) {
|
||||
let reg = registers.pin_config[setting]
|
||||
if (port === 'B') { reg = reg + 0x10 } // TODO 0x10 should be based on chip config
|
||||
// TODO 0x10 should be based on chip config
|
||||
let byte = 0;
|
||||
let pins = this.ports[port].allPins
|
||||
for (let i = 0; i < 8; i++) {
|
||||
|
@ -92,7 +98,7 @@ class MCP23008 extends Device {
|
|||
}
|
||||
//console.log(`port ${port} - setting ${setting} - reg ${reg} - byte ${byte}`)
|
||||
jobs.push(
|
||||
super.write(reg, byte).then(() => Promise.resolve(`config: wrote ${byte} to register ${reg} on port ${port}`))
|
||||
super.write(portReg(reg, port), byte).then(() => Promise.resolve(`config: wrote ${byte} to register ${reg} on port ${port}`))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -104,8 +110,7 @@ class MCP23008 extends Device {
|
|||
let jobs = []
|
||||
let reg = registers.pin_cmd[cmd]
|
||||
for (let port in this.ports) {
|
||||
jobs.push(() => super.read(reg))
|
||||
reg += 0x10
|
||||
jobs.push(() => super.read(portReg(reg, port)))
|
||||
}
|
||||
return _u.pSeries(jobs)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue