add documentation
parent
ecb455e7ea
commit
7e3e92db14
|
@ -46,8 +46,14 @@ class MCP23008 extends Device {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return this.inter(port).start()
|
return this.inter(port).start()
|
||||||
.then(() => {
|
.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`)
|
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 port in this.ports) {
|
||||||
for (let setting in registers.pin_config) {
|
for (let setting in registers.pin_config) {
|
||||||
let reg = registers.pin_config[setting]
|
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 byte = 0;
|
||||||
let pins = this.ports[port].allPins
|
let pins = this.ports[port].allPins
|
||||||
for (let i = 0; i < 8; i++) {
|
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}`)
|
//console.log(`port ${port} - setting ${setting} - reg ${reg} - byte ${byte}`)
|
||||||
jobs.push(
|
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 jobs = []
|
||||||
let reg = registers.pin_cmd[cmd]
|
let reg = registers.pin_cmd[cmd]
|
||||||
for (let port in this.ports) {
|
for (let port in this.ports) {
|
||||||
jobs.push(() => super.read(reg))
|
jobs.push(() => super.read(portReg(reg, port)))
|
||||||
reg += 0x10
|
|
||||||
}
|
}
|
||||||
return _u.pSeries(jobs)
|
return _u.pSeries(jobs)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue