0.1.23 refactored pin configuration types. Now output and 5 flavors of input (4 of which interrupt inputs)
swapped order of package returned for interrupt find so that the pin state is not lost (overwritten)master
parent
b987c446a4
commit
bbe8ee511c
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@uci/mcp",
|
||||
"main": "src",
|
||||
"version": "0.1.22",
|
||||
"version": "0.1.23",
|
||||
"description": "Classes and Helper Functions for using the MCP chip on I2C Bus",
|
||||
"scripts": {
|
||||
"relays": "node -r esm examples/relays",
|
||||
|
|
|
@ -41,7 +41,15 @@ export const PIN = {
|
|||
usedef: 0, // if usedef = 0 defval not used
|
||||
defval: 0
|
||||
},
|
||||
toggle_switch: { // includes pullup by default
|
||||
input: {
|
||||
dir: 1, // 0 output,1 input
|
||||
ivrt: 0,
|
||||
pullup: 0,
|
||||
intr: 0, // if intr = 0 usedef,deval not used
|
||||
usedef: 0, // if usedef = 0 defval not used
|
||||
defval: 0
|
||||
},
|
||||
input_interrupt: { // includes pullup by default
|
||||
dir: 1, // 0 output,1 input
|
||||
ivrt: 1, // for reading let 1 be zero and vice versa
|
||||
pullup: 1,
|
||||
|
@ -49,7 +57,7 @@ export const PIN = {
|
|||
usedef: 0, // if usedef = 0 defval not used
|
||||
defval: 0
|
||||
},
|
||||
toggle_switch_no_pullup: {
|
||||
input_interrupt_ext_up: {
|
||||
dir: 1, // 0 output,1 input
|
||||
ivrt: 1, // for reading let 1 be zero and vice versa
|
||||
pullup: 0, // use external pullup 5V with external resister!
|
||||
|
@ -57,7 +65,7 @@ export const PIN = {
|
|||
usedef: 0, // if usedef = 0 defval not used
|
||||
defval: 0
|
||||
},
|
||||
toggle_switch_pulldown: {
|
||||
input_interrupt_ext_down: {
|
||||
dir: 1, // 0 output,1 input
|
||||
ivrt: 0, // for reading let 1 be zero and vice versa
|
||||
pullup: 0, // use external pulldown
|
||||
|
@ -65,7 +73,7 @@ export const PIN = {
|
|||
usedef: 0, // if usedef = 0 defval not used
|
||||
defval: 0
|
||||
},
|
||||
momentary_switch: {
|
||||
momentary_interrupt: {
|
||||
dir: 1, // 0 output,1 input
|
||||
ivrt: 1, // for reading let 1 be zero and vice versa
|
||||
pullup: 1,
|
||||
|
|
|
@ -29,6 +29,7 @@ class MCP230XX extends Device {
|
|||
log.fatal({msg:'unable to configure mcp chip', error:res.error, cfg:this.chipCfg, address:this.address})
|
||||
throw `${res.error} at address ${this.address}/${this.address.toString(16)}`
|
||||
}
|
||||
await this.commands.pin.cfg({pins:'all'}) //pins are outputs by default
|
||||
}
|
||||
} // end of MCP230XX Class
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class MCP230XXi extends MCP230XX {
|
|||
let cfg = {
|
||||
port: this[pin].mport || 'A',
|
||||
pins: this[pin].pins || 'all',
|
||||
cfg: this[pin].type || 'toggle_switch'
|
||||
cfg: this[pin].type || 'input_interrupt'
|
||||
}
|
||||
// this will set default type to internal pullup, only need to to change indivial pins to external if desired
|
||||
await this.pin.cfg(cfg)
|
||||
|
@ -141,12 +141,13 @@ const ipincommands = {
|
|||
packet.reg = null
|
||||
if (packet.pins) {
|
||||
// avoid bad interrupt (i.e. no pin caused interrupt)
|
||||
res.state = (await this.pin.status(packet)).status.pins[0][1]
|
||||
res.port = packet.port
|
||||
res.ipin = inter.pin
|
||||
res.port = packet.port
|
||||
delete inter.cmd; delete inter._header; delete inter.pin
|
||||
Object.assign(res,inter)
|
||||
delete res.status
|
||||
res.state = (await this.pin.status(packet)).status.pins[0][1]
|
||||
console.log('emitted interrupt packet', res)
|
||||
this.emit('interrupt', res)
|
||||
log.debug({msg:'found pin now resetting mcp port interrupt', response:res})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue