node-red-contrib-periph-io-expander 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -10
- package/examples/mcp23008/demo.json +45 -27
- package/examples/mcp23017/demo.json +86 -21
- package/examples/pca6408a/demo.json +36 -18
- package/examples/pca6416a/demo.json +36 -18
- package/examples/pca9536/demo.json +27 -9
- package/examples/pca9539/demo.json +36 -18
- package/examples/pcf8574/demo.json +102 -14
- package/examples/pcf8575/demo.json +1 -70
- package/examples/tca9554/demo.json +36 -18
- package/examples/tpic6b595/demo.json +1 -117
- package/nodes/mcp23008/mcp23008.html +55 -33
- package/nodes/mcp23008/mcp23008.js +25 -14
- package/nodes/mcp23017/mcp23017.html +39 -13
- package/nodes/mcp23017/mcp23017.js +17 -11
- package/nodes/pca6408a/pca6408a.html +46 -22
- package/nodes/pca6408a/pca6408a.js +25 -14
- package/nodes/pca6416a/pca6416a.html +46 -22
- package/nodes/pca6416a/pca6416a.js +26 -15
- package/nodes/pca9536/pca9536.html +38 -14
- package/nodes/pca9536/pca9536.js +25 -14
- package/nodes/pca9539/pca9539.html +46 -22
- package/nodes/pca9539/pca9539.js +26 -15
- package/nodes/pcf8574/pcf8574.html +39 -13
- package/nodes/pcf8574/pcf8574.js +17 -11
- package/nodes/pcf8575/pcf8575.html +39 -13
- package/nodes/pcf8575/pcf8575.js +17 -11
- package/nodes/tca9554/tca9554.html +46 -22
- package/nodes/tca9554/tca9554.js +25 -14
- package/nodes/tpic6b595/tpic6b595.html +50 -24
- package/nodes/tpic6b595/tpic6b595.js +19 -13
- package/package.json +10 -12
- package/index.js +0 -11
package/nodes/pcf8575/pcf8575.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { Pcf8575Full } = require('periph/src/chips/io_expander/pcf8575');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function Pcf8575DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
10
|
try {
|
|
@@ -18,21 +18,32 @@ module.exports = function(RED) {
|
|
|
18
18
|
node.error('PCF8575 init failed: ' + e.message);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
node.on('close', async function() {
|
|
22
|
+
if (node.connection) await node.connection.close();
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
RED.nodes.registerType('pcf8575-device', Pcf8575DeviceNode);
|
|
26
|
+
|
|
27
|
+
function Pcf8575ReadNode(config) {
|
|
28
|
+
RED.nodes.createNode(this, config);
|
|
29
|
+
const node = this;
|
|
30
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
31
|
+
|
|
21
32
|
node.on('input', async function(msg, send, done) {
|
|
22
|
-
if (!
|
|
33
|
+
if (!deviceNode.chip) { done(new Error('PCF8575 not initialised')); return; }
|
|
23
34
|
try {
|
|
24
35
|
const p = msg.payload;
|
|
25
36
|
if (p && typeof p.pin === 'number' && typeof p.value === 'number') {
|
|
26
|
-
await
|
|
37
|
+
await deviceNode.chip._setPin(p.pin, p.value ? 1 : 0);
|
|
27
38
|
done();
|
|
28
39
|
} else if (p && typeof p.pin === 'number') {
|
|
29
40
|
const port = Math.floor(p.pin / 8);
|
|
30
41
|
const bit = p.pin % 8;
|
|
31
|
-
msg.payload = { pin: p.pin, value: ((await
|
|
42
|
+
msg.payload = { pin: p.pin, value: ((await deviceNode.chip.readPort(port)) >> bit) & 1 };
|
|
32
43
|
send(msg);
|
|
33
44
|
done();
|
|
34
45
|
} else if (p && typeof p.port === 'number') {
|
|
35
|
-
msg.payload = { port: p.port, value: await
|
|
46
|
+
msg.payload = { port: p.port, value: await deviceNode.chip.readPort(p.port) };
|
|
36
47
|
send(msg);
|
|
37
48
|
done();
|
|
38
49
|
} else {
|
|
@@ -40,11 +51,6 @@ module.exports = function(RED) {
|
|
|
40
51
|
}
|
|
41
52
|
} catch (e) { done(e); }
|
|
42
53
|
});
|
|
43
|
-
|
|
44
|
-
node.on('close', async function() {
|
|
45
|
-
if (node.connection) await node.connection.close();
|
|
46
|
-
});
|
|
47
54
|
}
|
|
48
|
-
|
|
49
|
-
RED.nodes.registerType('periph-pcf8575', Pcf8575Node);
|
|
55
|
+
RED.nodes.registerType('pcf8575', Pcf8575ReadNode);
|
|
50
56
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
1
2
|
<script type="text/javascript">
|
|
2
|
-
RED.nodes.registerType('
|
|
3
|
-
category:
|
|
4
|
-
color: '#C084FC',
|
|
3
|
+
RED.nodes.registerType('tca9554-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
@@ -9,41 +9,65 @@
|
|
|
9
9
|
gpioChip: { value: '0' },
|
|
10
10
|
intPin: { value: '' }
|
|
11
11
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
label: function() {
|
|
16
|
-
return this.name || ('TCA9554 @ 0x' + this.address + ' (bus ' + this.bus + ')');
|
|
17
|
-
},
|
|
18
|
-
paletteLabel: 'TCA9554'
|
|
12
|
+
label: function() {
|
|
13
|
+
return this.name || ('TCA9554 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
14
|
+
}
|
|
19
15
|
});
|
|
20
16
|
</script>
|
|
21
17
|
|
|
22
|
-
<script type="text/html" data-template-name="
|
|
18
|
+
<script type="text/html" data-template-name="tca9554-device">
|
|
23
19
|
<div class="form-row">
|
|
24
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
25
|
-
<input type="text" id="node-input-name" placeholder="TCA9554">
|
|
20
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
21
|
+
<input type="text" id="node-config-input-name" placeholder="TCA9554">
|
|
26
22
|
</div>
|
|
27
23
|
<div class="form-row">
|
|
28
|
-
<label for="node-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
29
|
-
<input type="number" id="node-input-bus" min="0" style="width:80px"> (/dev/i2c-N)
|
|
24
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
25
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (/dev/i2c-N)
|
|
30
26
|
</div>
|
|
31
27
|
<div class="form-row">
|
|
32
|
-
<label for="node-input-address">Address (hex)</label>
|
|
33
|
-
<input type="text" id="node-input-address" placeholder="20" style="width:80px">
|
|
28
|
+
<label for="node-config-input-address">Address (hex)</label>
|
|
29
|
+
<input type="text" id="node-config-input-address" placeholder="20" style="width:80px">
|
|
34
30
|
20 … 27 (A2..A0)
|
|
35
31
|
</div>
|
|
36
32
|
<div class="form-row">
|
|
37
|
-
<label for="node-input-gpioChip">GPIO chip</label>
|
|
38
|
-
<input type="number" id="node-input-gpioChip" min="0" style="width:80px"> (for the optional INT line)
|
|
33
|
+
<label for="node-config-input-gpioChip">GPIO chip</label>
|
|
34
|
+
<input type="number" id="node-config-input-gpioChip" min="0" style="width:80px"> (for the optional INT line)
|
|
35
|
+
</div>
|
|
36
|
+
<div class="form-row">
|
|
37
|
+
<label for="node-config-input-intPin">INT GPIO line</label>
|
|
38
|
+
<input type="number" id="node-config-input-intPin" min="0" style="width:80px" placeholder="none">
|
|
39
|
+
</div>
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<!-- Read node -->
|
|
43
|
+
<script type="text/javascript">
|
|
44
|
+
RED.nodes.registerType('tca9554', {
|
|
45
|
+
category: 'Peripheral',
|
|
46
|
+
color: '#C084FC',
|
|
47
|
+
defaults: {
|
|
48
|
+
name: { value: '' },
|
|
49
|
+
device: { value: '', type: 'tca9554-device', required: true }
|
|
50
|
+
},
|
|
51
|
+
inputs: 1,
|
|
52
|
+
outputs: 1,
|
|
53
|
+
icon: 'font-awesome/fa-microchip',
|
|
54
|
+
label: function() { return this.name || 'TCA9554'; },
|
|
55
|
+
paletteLabel: 'TCA9554'
|
|
56
|
+
});
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<script type="text/html" data-template-name="tca9554">
|
|
60
|
+
<div class="form-row">
|
|
61
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
62
|
+
<input type="text" id="node-input-name" placeholder="TCA9554">
|
|
39
63
|
</div>
|
|
40
64
|
<div class="form-row">
|
|
41
|
-
<label for="node-input-
|
|
42
|
-
<input type="
|
|
65
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
66
|
+
<input type="text" id="node-input-device">
|
|
43
67
|
</div>
|
|
44
68
|
</script>
|
|
45
69
|
|
|
46
|
-
<script type="text/html" data-help-name="
|
|
70
|
+
<script type="text/html" data-help-name="tca9554">
|
|
47
71
|
<p>Controls and reads an 8-bit TCA9554 I/O expander (I²C / SMBus, TI). Every input has a fixed internal 100 kΩ pull-up (always on).</p>
|
|
48
72
|
|
|
49
73
|
<h3>Inputs</h3>
|
package/nodes/tca9554/tca9554.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { Tca9554Full } = require('periph/src/chips/io_expander/tca9554');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function Tca9554DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
10
|
try {
|
|
@@ -27,7 +27,7 @@ module.exports = function(RED) {
|
|
|
27
27
|
await node.chip.ready;
|
|
28
28
|
await node.chip.onInterrupt(async (changed) => {
|
|
29
29
|
const value = await node.chip.readPort();
|
|
30
|
-
node.
|
|
30
|
+
node.emit('periph-data', { payload: { port: 0, changed, value } });
|
|
31
31
|
}, { intPin });
|
|
32
32
|
} catch (e) {
|
|
33
33
|
node.error('TCA9554 INT setup failed: ' + e.message);
|
|
@@ -35,21 +35,38 @@ module.exports = function(RED) {
|
|
|
35
35
|
})();
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
node.on('close', async function() {
|
|
39
|
+
if (node.chip) await node.chip.offInterrupt();
|
|
40
|
+
if (node.connection) await node.connection.close();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
RED.nodes.registerType('tca9554-device', Tca9554DeviceNode);
|
|
44
|
+
|
|
45
|
+
function Tca9554ReadNode(config) {
|
|
46
|
+
RED.nodes.createNode(this, config);
|
|
47
|
+
const node = this;
|
|
48
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
49
|
+
if (deviceNode.on) {
|
|
50
|
+
const onData = (m) => node.send(m);
|
|
51
|
+
deviceNode.on('periph-data', onData);
|
|
52
|
+
node.on('close', () => deviceNode.removeListener('periph-data', onData));
|
|
53
|
+
}
|
|
54
|
+
|
|
38
55
|
node.on('input', async function(msg, send, done) {
|
|
39
|
-
if (!
|
|
56
|
+
if (!deviceNode.chip) { done(new Error('TCA9554 not initialised')); return; }
|
|
40
57
|
try {
|
|
41
58
|
const p = msg.payload;
|
|
42
59
|
if (p && typeof p.pin === 'number' && typeof p.value === 'number') {
|
|
43
|
-
const pin =
|
|
44
|
-
if ((
|
|
60
|
+
const pin = deviceNode.chip.pin(p.pin);
|
|
61
|
+
if ((deviceNode.chip._direction >> p.pin) & 1) await pin.setDirection('out');
|
|
45
62
|
await pin.write(p.value ? 1 : 0);
|
|
46
63
|
done();
|
|
47
64
|
} else if (p && typeof p.pin === 'number') {
|
|
48
|
-
msg.payload = { pin: p.pin, value: ((await
|
|
65
|
+
msg.payload = { pin: p.pin, value: ((await deviceNode.chip.readPort()) >> p.pin) & 1 };
|
|
49
66
|
send(msg);
|
|
50
67
|
done();
|
|
51
68
|
} else if (p && typeof p.port === 'number') {
|
|
52
|
-
msg.payload = { port: p.port, value: await
|
|
69
|
+
msg.payload = { port: p.port, value: await deviceNode.chip.readPort() };
|
|
53
70
|
send(msg);
|
|
54
71
|
done();
|
|
55
72
|
} else {
|
|
@@ -57,12 +74,6 @@ module.exports = function(RED) {
|
|
|
57
74
|
}
|
|
58
75
|
} catch (e) { done(e); }
|
|
59
76
|
});
|
|
60
|
-
|
|
61
|
-
node.on('close', async function() {
|
|
62
|
-
if (node.chip) await node.chip.offInterrupt();
|
|
63
|
-
if (node.connection) await node.connection.close();
|
|
64
|
-
});
|
|
65
77
|
}
|
|
66
|
-
|
|
67
|
-
RED.nodes.registerType('periph-tca9554', Tca9554Node);
|
|
78
|
+
RED.nodes.registerType('tca9554', Tca9554ReadNode);
|
|
68
79
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
1
2
|
<script type="text/javascript">
|
|
2
|
-
RED.nodes.registerType('
|
|
3
|
-
category:
|
|
4
|
-
color: '#C084FC',
|
|
3
|
+
RED.nodes.registerType('tpic6b595-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
rckPin: { value: '17', required: true, validate: RED.validators.number() },
|
|
@@ -11,52 +11,78 @@
|
|
|
11
11
|
srckPin: { value: '', required: false, validate: RED.validators.number() },
|
|
12
12
|
numDevices: { value: '1', required: true, validate: RED.validators.number() }
|
|
13
13
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
label: function() { return this.name || ('TPIC6B595 × ' + (this.numDevices || 1)); },
|
|
18
|
-
paletteLabel: 'TPIC6B595'
|
|
14
|
+
label: function() {
|
|
15
|
+
return this.name || 'TPIC6B595';
|
|
16
|
+
}
|
|
19
17
|
});
|
|
20
18
|
</script>
|
|
21
19
|
|
|
22
|
-
<script type="text/html" data-template-name="
|
|
20
|
+
<script type="text/html" data-template-name="tpic6b595-device">
|
|
23
21
|
<div class="form-row">
|
|
24
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
25
|
-
<input type="text" id="node-input-name" placeholder="TPIC6B595">
|
|
22
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
23
|
+
<input type="text" id="node-config-input-name" placeholder="TPIC6B595">
|
|
26
24
|
</div>
|
|
27
25
|
<div class="form-row">
|
|
28
|
-
<label for="node-input-rckPin"><i class="fa fa-microchip"></i> RCK pin</label>
|
|
29
|
-
<input type="number" id="node-input-rckPin" min="0" style="width:80px">
|
|
26
|
+
<label for="node-config-input-rckPin"><i class="fa fa-microchip"></i> RCK pin</label>
|
|
27
|
+
<input type="number" id="node-config-input-rckPin" min="0" style="width:80px">
|
|
30
28
|
(register clock GPIO line)
|
|
31
29
|
</div>
|
|
32
30
|
<div class="form-row">
|
|
33
|
-
<label for="node-input-srclrPin">SRCLR pin</label>
|
|
34
|
-
<input type="number" id="node-input-srclrPin" min="-1" style="width:80px">
|
|
31
|
+
<label for="node-config-input-srclrPin">SRCLR pin</label>
|
|
32
|
+
<input type="number" id="node-config-input-srclrPin" min="-1" style="width:80px">
|
|
35
33
|
(shift-register clear; -1 to disable)
|
|
36
34
|
</div>
|
|
37
35
|
<div class="form-row">
|
|
38
|
-
<label for="node-input-gPin">G pin</label>
|
|
39
|
-
<input type="number" id="node-input-gPin" min="-1" style="width:80px">
|
|
36
|
+
<label for="node-config-input-gPin">G pin</label>
|
|
37
|
+
<input type="number" id="node-config-input-gPin" min="-1" style="width:80px">
|
|
40
38
|
(output enable; -1 to disable)
|
|
41
39
|
</div>
|
|
42
40
|
<div class="form-row">
|
|
43
|
-
<label for="node-input-serInPin">SER IN pin (software SPI)</label>
|
|
44
|
-
<input type="number" id="node-input-serInPin" min="0" style="width:80px">
|
|
41
|
+
<label for="node-config-input-serInPin">SER IN pin (software SPI)</label>
|
|
42
|
+
<input type="number" id="node-config-input-serInPin" min="0" style="width:80px">
|
|
45
43
|
(leave blank for hardware SPI)
|
|
46
44
|
</div>
|
|
47
45
|
<div class="form-row">
|
|
48
|
-
<label for="node-input-srckPin">SRCK pin (software SPI)</label>
|
|
49
|
-
<input type="number" id="node-input-srckPin" min="0" style="width:80px">
|
|
46
|
+
<label for="node-config-input-srckPin">SRCK pin (software SPI)</label>
|
|
47
|
+
<input type="number" id="node-config-input-srckPin" min="0" style="width:80px">
|
|
50
48
|
(leave blank for hardware SPI)
|
|
51
49
|
</div>
|
|
52
50
|
<div class="form-row">
|
|
53
|
-
<label for="node-input-numDevices">Cascaded devices</label>
|
|
54
|
-
<input type="number" id="node-input-numDevices" min="1" max="8" style="width:60px">
|
|
51
|
+
<label for="node-config-input-numDevices">Cascaded devices</label>
|
|
52
|
+
<input type="number" id="node-config-input-numDevices" min="1" max="8" style="width:60px">
|
|
55
53
|
(1–8; pin index range = numDevices × 8)
|
|
56
54
|
</div>
|
|
57
55
|
</script>
|
|
58
56
|
|
|
59
|
-
|
|
57
|
+
<!-- Read node -->
|
|
58
|
+
<script type="text/javascript">
|
|
59
|
+
RED.nodes.registerType('tpic6b595', {
|
|
60
|
+
category: 'Peripheral',
|
|
61
|
+
color: '#C084FC',
|
|
62
|
+
defaults: {
|
|
63
|
+
name: { value: '' },
|
|
64
|
+
device: { value: '', type: 'tpic6b595-device', required: true }
|
|
65
|
+
},
|
|
66
|
+
inputs: 1,
|
|
67
|
+
outputs: 1,
|
|
68
|
+
icon: 'font-awesome/fa-microchip',
|
|
69
|
+
label: function() { return this.name || 'TPIC6B595'; },
|
|
70
|
+
paletteLabel: 'TPIC6B595'
|
|
71
|
+
});
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<script type="text/html" data-template-name="tpic6b595">
|
|
75
|
+
<div class="form-row">
|
|
76
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
77
|
+
<input type="text" id="node-input-name" placeholder="TPIC6B595">
|
|
78
|
+
</div>
|
|
79
|
+
<div class="form-row">
|
|
80
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
81
|
+
<input type="text" id="node-input-device">
|
|
82
|
+
</div>
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<script type="text/html" data-help-name="tpic6b595">
|
|
60
86
|
<p>Drives a Texas Instruments TPIC6B595 8-bit power SIPO shift register (or
|
|
61
87
|
multiple cascaded devices) through a SiPo (serial-in/parallel-out)
|
|
62
88
|
connection. SER IN / SRCK may be either an SPI bus (hardware mode) or two
|
|
@@ -5,7 +5,7 @@ module.exports = function(RED) {
|
|
|
5
5
|
const { SiPoConnection } = require('periph/src/connection/sipo');
|
|
6
6
|
const { Tpic6b595Full } = require('periph/src/chips/io_expander/tpic6b595');
|
|
7
7
|
|
|
8
|
-
function
|
|
8
|
+
function Tpic6b595DeviceNode(config) {
|
|
9
9
|
RED.nodes.createNode(this, config);
|
|
10
10
|
const node = this;
|
|
11
11
|
try {
|
|
@@ -26,35 +26,41 @@ module.exports = function(RED) {
|
|
|
26
26
|
node.error('TPIC6B595 init failed: ' + e.message);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
node.on('close', async function() {
|
|
30
|
+
if (node.connection) await node.connection.close();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
RED.nodes.registerType('tpic6b595-device', Tpic6b595DeviceNode);
|
|
34
|
+
|
|
35
|
+
function Tpic6b595ReadNode(config) {
|
|
36
|
+
RED.nodes.createNode(this, config);
|
|
37
|
+
const node = this;
|
|
38
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
39
|
+
|
|
29
40
|
node.on('input', async function(msg, send, done) {
|
|
30
|
-
if (!
|
|
41
|
+
if (!deviceNode.chip) { done(new Error('TPIC6B595 not initialised')); return; }
|
|
31
42
|
try {
|
|
32
43
|
const p = msg.payload;
|
|
33
44
|
if (p && typeof p.pin === 'number' && typeof p.value === 'number') {
|
|
34
|
-
await
|
|
45
|
+
await deviceNode.chip.pin(p.pin).write(p.value ? 1 : 0);
|
|
35
46
|
done();
|
|
36
47
|
} else if (p && typeof p.port === 'number' && typeof p.value === 'number') {
|
|
37
|
-
await
|
|
48
|
+
await deviceNode.chip.writePort(p.port, p.value & 0xFF);
|
|
38
49
|
done();
|
|
39
50
|
} else if (p && p.command === 'off') {
|
|
40
|
-
await
|
|
51
|
+
await deviceNode.chip.off();
|
|
41
52
|
done();
|
|
42
53
|
} else if (p && typeof p.outputEnable === 'boolean') {
|
|
43
|
-
|
|
54
|
+
deviceNode.chip.setOutputEnable(p.outputEnable);
|
|
44
55
|
done();
|
|
45
56
|
} else if (p && Array.isArray(p.values)) {
|
|
46
|
-
|
|
57
|
+
deviceNode.chip.writeAll(p.values);
|
|
47
58
|
done();
|
|
48
59
|
} else {
|
|
49
60
|
done(new Error('msg.payload must be {pin,value}, {port,value}, {command:"off"}, {outputEnable:true|false}, or {values:[...]}.'));
|
|
50
61
|
}
|
|
51
62
|
} catch (e) { done(e); }
|
|
52
63
|
});
|
|
53
|
-
|
|
54
|
-
node.on('close', async function() {
|
|
55
|
-
if (node.connection) await node.connection.close();
|
|
56
|
-
});
|
|
57
64
|
}
|
|
58
|
-
|
|
59
|
-
RED.nodes.registerType('periph-tpic6b595', Tpic6b595Node);
|
|
65
|
+
RED.nodes.registerType('tpic6b595', Tpic6b595ReadNode);
|
|
60
66
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-periph-io-expander",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Node-RED nodes for IO expander chips",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -9,20 +9,18 @@
|
|
|
9
9
|
"spi",
|
|
10
10
|
"peripheral"
|
|
11
11
|
],
|
|
12
|
-
"main": "index.js",
|
|
13
12
|
"node-red": {
|
|
14
13
|
"nodes": {
|
|
15
14
|
"mcp23008": "nodes/mcp23008/mcp23008.js",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"periph-tpic6b595": "nodes/tpic6b595/tpic6b595.js"
|
|
15
|
+
"mcp23017": "nodes/mcp23017/mcp23017.js",
|
|
16
|
+
"pca6408a": "nodes/pca6408a/pca6408a.js",
|
|
17
|
+
"pca6416a": "nodes/pca6416a/pca6416a.js",
|
|
18
|
+
"pca9536": "nodes/pca9536/pca9536.js",
|
|
19
|
+
"pca9539": "nodes/pca9539/pca9539.js",
|
|
20
|
+
"pcf8574": "nodes/pcf8574/pcf8574.js",
|
|
21
|
+
"pcf8575": "nodes/pcf8575/pcf8575.js",
|
|
22
|
+
"tca9554": "nodes/tca9554/tca9554.js",
|
|
23
|
+
"tpic6b595": "nodes/tpic6b595/tpic6b595.js"
|
|
26
24
|
}
|
|
27
25
|
},
|
|
28
26
|
"dependencies": {
|
package/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
module.exports = function(RED) {
|
|
5
|
-
const nodesDir = path.join(__dirname, 'nodes');
|
|
6
|
-
if (!fs.existsSync(nodesDir)) return;
|
|
7
|
-
fs.readdirSync(nodesDir).forEach(function(chip) {
|
|
8
|
-
const nodeFile = path.join(nodesDir, chip, chip + '.js');
|
|
9
|
-
if (fs.existsSync(nodeFile)) require(nodeFile)(RED);
|
|
10
|
-
});
|
|
11
|
-
};
|