From 7e3e92db14a32407590e6d48c76a9aff467e272f Mon Sep 17 00:00:00 2001 From: David Kebler Date: Mon, 15 May 2017 11:01:29 -0700 Subject: [PATCH] add documentation --- lib/mcp23008-17.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/mcp23008-17.js b/lib/mcp23008-17.js index ae47d6b..2a3388c 100644 --- a/lib/mcp23008-17.js +++ b/lib/mcp23008-17.js @@ -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) }