last cleanup after uci-dev split out

master
David Kebler 2017-01-16 22:44:10 -08:00
parent 50cc30069a
commit 1c7af6009f
1 changed files with 3 additions and 60 deletions

View File

@ -1,11 +1,10 @@
'use strict'
const expect = require('chai').expect,
i2c = require('uci-i2c'),
_u = require('uci-utils'),
MCP = require('../lib/mcp23008-17')
let bus1 = new i2c.Bus(1)
const bus = {}
const config_sets = {
output: {
@ -40,7 +39,7 @@
describe('I2C Device Classes - ', function () {
let mcp17 = new MCP.MCP23017(bus1, 0x20, {
let mcp17 = new MCP.MCP23017(bus, 0x20, {
pin_cfg_default: 'momentary_switch',
name: 'switches 1-16'
})
@ -59,7 +58,7 @@
});
let mcp8 = new MCP.MCP23008(bus1, 0x21, {
let mcp8 = new MCP.MCP23008(bus, 0x21, {
pin_cfg_default: 'toggle_switch',
name: 'test 1-8'
})
@ -79,59 +78,3 @@
});
});
let ADDR = 0x20,
W = 0x09,
R = 0x0A,
PINSON = 0xa5,
PINSOFF = 0x00
let testout = new MCP.MCP23008(bus1, ADDR, {
pin_cfg_default: 'output',
name: 'outputs 1-8'
})
function tstout() {
return testout.init()
.then(() => {
console.log('testing device write and read')
return testout.write(W, PINSON)
.then(() => {
return testout.read(R)
.then((resp) => {
console.log('Pins Set On', _u.byteFormat(resp, { in: 'DEC', out: 'PLC' }))
return _u.pDelay(1000)
.then(() => {
console.log('Reset Pins')
return testout.write(W, PINSOFF)
})
})
})
})
.catch(err => console.log('errors:', err))
}
const
ADDR17 = 0x27,
port = { A: 0x09, B: 0x19 }
let testin = new MCP.MCP23017(bus1, ADDR17, {
pin_cfg_default: 'toggle_switch',
name: 'read inputs 1-16'
})
function tstin(p) {
return testin.init()
.then(() => {
console.log('port', port[p])
return testin.read(port[p])
.then((resp) => {
console.log('Port ', p, ' Pins', _u.byteFormat(resp, { in: 'DEC', out: 'PLC' }))
})
})
.catch(err => console.log('errors:', err))
}
// tstout().then(() => tstin())
bus1.qAdd(tstin('A'))
bus1.qAdd(tstin('B'))