diff --git a/package.json b/package.json index a4d9140..39a1709 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@uci/mcp", "main": "src", - "version": "0.1.9", + "version": "0.1.17", "description": "Classes and Helper Functions for using the MCP chip on I2C Bus", "scripts": { "relays": "node -r esm examples/relays", @@ -29,9 +29,9 @@ }, "homepage": "https://github.com/uCOMmandIt/uci-mcp#readme", "dependencies": { - "@uci/i2c-device": "^0.1.4", - "@uci/logger": "0.0.6", - "@uci/utils": "^0.1.1" + "@uci/i2c-device": "^0.1.12", + "@uci-utils/logger": "0.0.13", + "@uci-utils/byte": "^0.2.0" }, "devDependencies": { "chai": "^4.1.2", diff --git a/src/commands.js b/src/commands.js index 955ba09..bcd654a 100644 --- a/src/commands.js +++ b/src/commands.js @@ -1,8 +1,8 @@ -// import _ from '@uci/utils/src/byte' -// import _ from '../../archive/uci-utils/src/byte' -import _ from '@uci/utils/src/byte' +import * as _ from '@uci-utils/byte' import { CHIP, PIN } from './config' +// TODO add uci debug logging + export default { chip:{ // for custom chip configuration set packet.cfg='custom' then packet.setting should be a @@ -107,7 +107,9 @@ const parsePins = function(pins) { if (typeof pins==='number') pins = [pins] if (typeof pins==='string') { if (pins==='all') pins = _.byteFormat(255,{in:'DEC', out:'PLC'}) - else pins = pins.split(/[,:\s]+/).map(Number).filter( (x) => !Number.isNaN(x)) + else { + pins = pins.split(/[,:\s]+/).map(Number).filter( (x) => !Number.isNaN(x)) + } } return new _.Byte(pins,'PLC') } diff --git a/src/config.js b/src/config.js index 3160eb3..675dc07 100644 --- a/src/config.js +++ b/src/config.js @@ -33,7 +33,7 @@ export const PIN = { usedef: 0, // if usedef = 0 defval not used defval: 0 }, - toggle_switch: { + toggle_switch: { // includes pullup by default dir: 1, // 0 output,1 input ivrt: 1, // for reading let 1 be zero and vice versa pullup: 1, diff --git a/src/mcp230xx.js b/src/mcp230xx.js index 0a8ef70..2595455 100644 --- a/src/mcp230xx.js +++ b/src/mcp230xx.js @@ -2,7 +2,7 @@ import Device from '@uci/i2c-device' // import Device from '../../uci-i2c-device/src/device-packet' import commands from './commands' -import logger from '@uci/logger' +import logger from '@uci-utils/logger' let log = {} class MCP230XX extends Device { @@ -26,9 +26,7 @@ class MCP230XX extends Device { let res = await this.chipcfg({}) let cfg = this.chip17 ? '10100010' : '00100010' if (res.response !== cfg) - throw `could not configure mcp chip at ${ - this.address - }=0x${this.address.toString(16)}` + throw `could not configure mcp chip at ${this.address}/${this.address.toString(16)}` } } // end of MCP230XX Class diff --git a/src/mcp230xxi.js b/src/mcp230xxi.js index a4314ad..ce34464 100644 --- a/src/mcp230xxi.js +++ b/src/mcp230xxi.js @@ -1,7 +1,7 @@ import MCP230XX from './mcp230xx' -import { byteFormat } from '@uci/utils/src/byte' +import { byteFormat } from '@uci-utils/byte' -import logger from '@uci/logger' +import logger from '@uci-utils/logger' let log = {} // if opts.iport not set then will be generated based on pin number