upgrade to esm from @std/esm
parent
9652041671
commit
a0eb28fdc0
19
package.json
19
package.json
|
@ -1,16 +1,16 @@
|
||||||
{
|
{
|
||||||
"name": "@uci/mcp",
|
"name": "@uci/mcp",
|
||||||
"main": "src",
|
"main": "src",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"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 --require @std/esm examples/relays",
|
"relays": "node -r esm examples/relays",
|
||||||
"swr": "node --require @std/esm examples/mcp-switch-relay",
|
"swr": "node -r esm examples/mcp-switch-relay",
|
||||||
"test": "./node_modules/.bin/mocha --reporter list --timeout 30000",
|
"test": "./node_modules/.bin/mocha --reporter list --timeout 30000",
|
||||||
"testw": "./node_modules/.bin/mocha --reporter list -- watch --timeout 30000",
|
"testw": "./node_modules/.bin/mocha --reporter list -- watch --timeout 30000",
|
||||||
"testibc": "istanbul cover ./node_modules/.bin/_mocha test/ --report lcovonly -- -R spec --recursive && codecov || true",
|
"testibc": "istanbul cover ./node_modules/.bin/_mocha test/ --report lcovonly -- -R spec --recursive && codecov || true",
|
||||||
"sample": "node demo/sample.js",
|
"sample": "node demo/sample.js",
|
||||||
"inter": "sudo node -r @std/esm examples/interrupt"
|
"inter": "sudo node -r esm examples/interrupt"
|
||||||
},
|
},
|
||||||
"author": "David Kebler",
|
"author": "David Kebler",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -28,18 +28,17 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/uCOMmandIt/uci-mcp#readme",
|
"homepage": "https://github.com/uCOMmandIt/uci-mcp#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uci/i2c-device": "^0.1.1",
|
"@uci/i2c-device": "^0.1.3",
|
||||||
"@uci/interrupt": "^0.1.1",
|
"@uci/interrupt": "^0.1.4",
|
||||||
"@uci/logger": "0.0.1",
|
"@uci/logger": "^0.0.2",
|
||||||
"@uci/mqtt": "0.0.1",
|
"@uci/mqtt": "^0.0.3",
|
||||||
"@uci/utils": "^0.1.1"
|
"@uci/utils": "^0.1.1"
|
||||||
},
|
},
|
||||||
"@std/esm": "cjs",
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@std/esm": "^0.22.0",
|
|
||||||
"chai": "^4.1.2",
|
"chai": "^4.1.2",
|
||||||
"codecov": "^3.0.0",
|
"codecov": "^3.0.0",
|
||||||
"debug": "^3.1.0",
|
"debug": "^3.1.0",
|
||||||
|
"esm": "^3.0.22",
|
||||||
"istanbul": "^0.4.5",
|
"istanbul": "^0.4.5",
|
||||||
"mocha": "^5.0.1",
|
"mocha": "^5.0.1",
|
||||||
"nodemon": "^1.15.1"
|
"nodemon": "^1.15.1"
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import MCP230XX from './mcp230xx'
|
||||||
|
import MCP230XXi from './mcp230xxi'
|
||||||
|
|
||||||
|
export { MCP230XX as MCP230XX }
|
||||||
|
export { MCP230XXi as MCP230XXi }
|
||||||
|
|
||||||
|
export default MCP230XX
|
|
@ -1,15 +0,0 @@
|
||||||
import MCP230XX from './mcp230xx'
|
|
||||||
import MCP230XXi from './mcp230xxi'
|
|
||||||
// import Relays from './relays'
|
|
||||||
// import RelayBanks from './relay-banks'
|
|
||||||
// import Switches from './switches'
|
|
||||||
// import SwitchBanks from './switch-banks'
|
|
||||||
|
|
||||||
export { MCP230XX as MCP230XX }
|
|
||||||
export { MCP230XXi as MCP230XXi }
|
|
||||||
// export { Interrupt as Interrupt }
|
|
||||||
// export { Relays as Relays }
|
|
||||||
// export { RelayBanks as RelayBanks }
|
|
||||||
// export { Switches as Switches }
|
|
||||||
// export { SwitchBanks as SwitchBanks }
|
|
||||||
export default MCP230XX
|
|
|
@ -2,23 +2,13 @@ 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 { pin, chip } from './commands'
|
import { pin, chip } from './commands'
|
||||||
|
|
||||||
// import logger from '../../uci-logger/src/logger'
|
|
||||||
import logger from '@uci/logger'
|
import logger from '@uci/logger'
|
||||||
let log = {}
|
let log = {}
|
||||||
const LOG_OPTS = (id) => {
|
|
||||||
return {
|
|
||||||
repo:'uci-mcp',
|
|
||||||
npm:'@uci/mcp',
|
|
||||||
file:'src/mcp230xx.mjs',
|
|
||||||
class:'MCP230XX',
|
|
||||||
id:id,
|
|
||||||
instance_created:new Date().getTime()
|
|
||||||
}}
|
|
||||||
|
|
||||||
export default class MCP230XX extends Device {
|
export default class MCP230XX extends Device {
|
||||||
constructor(opts) {
|
constructor(opts) {
|
||||||
super(opts)
|
super(opts)
|
||||||
log = logger.child(LOG_OPTS(this.id))
|
log = logger({file:'src/mcp230xx.js',class:'MCP230XX',name:'mcp',id:this.id})
|
||||||
this.chip17 = opts.chip17
|
this.chip17 = opts.chip17
|
||||||
this.pin = this.bindFuncs(pin)
|
this.pin = this.bindFuncs(pin)
|
||||||
this.chip = this.bindFuncs(chip)
|
this.chip = this.bindFuncs(chip)
|
||||||
|
@ -26,9 +16,7 @@ export default class MCP230XX extends Device {
|
||||||
|
|
||||||
async init(){
|
async init(){
|
||||||
await super.init()
|
await super.init()
|
||||||
// console.log(this.address, this.chip17)
|
|
||||||
let res = await this.chip.cfg({})
|
let res = await this.chip.cfg({})
|
||||||
// console.log(res)
|
|
||||||
let cfg = this.chip17 ?'10100010':'00100010'
|
let cfg = this.chip17 ?'10100010':'00100010'
|
||||||
if (res.response !==cfg ) throw `could not configure mcp chip at ${this.address}=0x${this.address.toString(16)}`
|
if (res.response !==cfg ) throw `could not configure mcp chip at ${this.address}=0x${this.address.toString(16)}`
|
||||||
}
|
}
|
|
@ -1,17 +1,8 @@
|
||||||
import MCP230XX from './mcp230xx'
|
import MCP230XX from './mcp230xx'
|
||||||
import logger from '@uci/logger'
|
|
||||||
import { byteFormat } from '@uci/utils/src/byte'
|
import { byteFormat } from '@uci/utils/src/byte'
|
||||||
|
|
||||||
|
import logger from '@uci/logger'
|
||||||
let log = {}
|
let log = {}
|
||||||
const LOG_OPTS = (id) => {
|
|
||||||
return {
|
|
||||||
repo:'uci-mcp',
|
|
||||||
npm:'@uci/mcp',
|
|
||||||
file:'src/mcp230xxi.mjs',
|
|
||||||
class:'MCP230XXi',
|
|
||||||
id:id,
|
|
||||||
instance_created:new Date().getTime()
|
|
||||||
}}
|
|
||||||
|
|
||||||
// sockets:'inter#s>t', inter:{port:INTERRUPT_PORT}
|
// sockets:'inter#s>t', inter:{port:INTERRUPT_PORT}
|
||||||
|
|
||||||
|
@ -49,8 +40,8 @@ export default class MCP230XXi extends MCP230XX {
|
||||||
this[pin] = opts[pin] || {}
|
this[pin] = opts[pin] || {}
|
||||||
})
|
})
|
||||||
this.pins = pins
|
this.pins = pins
|
||||||
log = logger.child(LOG_OPTS(this.id))
|
log = logger({file:'src/mcp230xxi.js',class:'MCP230XXi',name:'mcp',id:this.id})
|
||||||
Object.assign(this.pin, this.bindFuncs(pin))
|
Object.assign(this.pin, this.bindFuncs(pin)) // add interrupt pin commands to base set in "command.js"
|
||||||
this._interruptProcess = null
|
this._interruptProcess = null
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue