0.1.17 incorporate new byte utility location, and logging

master
David Kebler 2019-02-14 14:01:30 -08:00
parent 54a2c237f3
commit a44e6426d2
5 changed files with 15 additions and 15 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "@uci/mcp", "name": "@uci/mcp",
"main": "src", "main": "src",
"version": "0.1.9", "version": "0.1.17",
"description": "Classes and Helper Functions for using the MCP chip on I2C Bus", "description": "Classes and Helper Functions for using the MCP chip on I2C Bus",
"scripts": { "scripts": {
"relays": "node -r esm examples/relays", "relays": "node -r esm examples/relays",
@ -29,9 +29,9 @@
}, },
"homepage": "https://github.com/uCOMmandIt/uci-mcp#readme", "homepage": "https://github.com/uCOMmandIt/uci-mcp#readme",
"dependencies": { "dependencies": {
"@uci/i2c-device": "^0.1.4", "@uci/i2c-device": "^0.1.12",
"@uci/logger": "0.0.6", "@uci-utils/logger": "0.0.13",
"@uci/utils": "^0.1.1" "@uci-utils/byte": "^0.2.0"
}, },
"devDependencies": { "devDependencies": {
"chai": "^4.1.2", "chai": "^4.1.2",

View File

@ -1,8 +1,8 @@
// import _ from '@uci/utils/src/byte' import * as _ from '@uci-utils/byte'
// import _ from '../../archive/uci-utils/src/byte'
import _ from '@uci/utils/src/byte'
import { CHIP, PIN } from './config' import { CHIP, PIN } from './config'
// TODO add uci debug logging
export default { export default {
chip:{ chip:{
// for custom chip configuration set packet.cfg='custom' then packet.setting should be a // 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==='number') pins = [pins]
if (typeof pins==='string') { if (typeof pins==='string') {
if (pins==='all') pins = _.byteFormat(255,{in:'DEC', out:'PLC'}) 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') return new _.Byte(pins,'PLC')
} }

View File

@ -33,7 +33,7 @@ export const PIN = {
usedef: 0, // if usedef = 0 defval not used usedef: 0, // if usedef = 0 defval not used
defval: 0 defval: 0
}, },
toggle_switch: { toggle_switch: { // includes pullup by default
dir: 1, // 0 output,1 input dir: 1, // 0 output,1 input
ivrt: 1, // for reading let 1 be zero and vice versa ivrt: 1, // for reading let 1 be zero and vice versa
pullup: 1, pullup: 1,

View File

@ -2,7 +2,7 @@ import Device from '@uci/i2c-device'
// import Device from '../../uci-i2c-device/src/device-packet' // import Device from '../../uci-i2c-device/src/device-packet'
import commands from './commands' import commands from './commands'
import logger from '@uci/logger' import logger from '@uci-utils/logger'
let log = {} let log = {}
class MCP230XX extends Device { class MCP230XX extends Device {
@ -26,9 +26,7 @@ class MCP230XX extends Device {
let res = await this.chipcfg({}) let res = await this.chipcfg({})
let cfg = this.chip17 ? '10100010' : '00100010' let cfg = this.chip17 ? '10100010' : '00100010'
if (res.response !== cfg) if (res.response !== cfg)
throw `could not configure mcp chip at ${ throw `could not configure mcp chip at ${this.address}/${this.address.toString(16)}`
this.address
}=0x${this.address.toString(16)}`
} }
} // end of MCP230XX Class } // end of MCP230XX Class

View File

@ -1,7 +1,7 @@
import MCP230XX from './mcp230xx' 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 = {} let log = {}
// if opts.iport not set then will be generated based on pin number // if opts.iport not set then will be generated based on pin number