From a46e9501eb82c250974cbdbc68803092bb45c060 Mon Sep 17 00:00:00 2001 From: David Kebler Date: Tue, 17 Oct 2017 09:38:46 -0700 Subject: [PATCH] return boolean for read pin instead of pin number --- package.json | 2 +- src/mcp23008-17.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b177fe8..09575e9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@uci/mcp", "main": "src/mcp23008-17.js", - "version": "0.1.0", + "version": "0.1.1", "description": "Classes and Helper Functions for using the MCP chip on I2C Bus", "scripts": { "test": "./node_modules/.bin/mocha --reporter list --timeout 30000", diff --git a/src/mcp23008-17.js b/src/mcp23008-17.js index 96a8d40..8ee9ba7 100644 --- a/src/mcp23008-17.js +++ b/src/mcp23008-17.js @@ -154,7 +154,8 @@ class MCP23008 extends aggregate(Device, EventEmitter) { port = 'A' } await this.readPort(port, opts) - return this.ports[port].state.bwOp(Math.pow(2, pin - 1), 'check') + TODO return just true or false not the decimal of pin - will need new version on npm + return this.ports[port].state.bwOp(Math.pow(2, pin - 1), 'check') ? true : false } async writePort(byte, op, port = 'A') { @@ -241,7 +242,10 @@ class MCP23017 extends MCP23008 { return this.ports[port].pin(id) } - pid(num, port) { return this.ports[port].pins[num - 1].id } + pid(num, port) { + console.log('pin for pid',this.ports[port].pins[num - 1]) + return this.ports[port].pins[num - 1].id + } } // end MCP23017 Class