return boolean for read pin instead of pin number

master
David Kebler 2017-10-17 09:38:46 -07:00
parent 6dcd4da327
commit a46e9501eb
2 changed files with 7 additions and 3 deletions

View File

@ -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",

View File

@ -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