node-red-contrib-periph-adc-dac 1.5.0 → 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 +44 -26
- package/examples/ad5243/demo.json +11 -5
- package/examples/ad5248/demo.json +1 -1
- package/examples/ad5251/demo.json +11 -5
- package/examples/ad5252/demo.json +11 -5
- package/examples/ad7705/demo.json +1 -1
- package/examples/ad7706/demo.json +1 -1
- package/examples/ads1013/demo.json +1 -76
- package/examples/ads1014/demo.json +1 -77
- package/examples/ads1113/demo.json +10 -4
- package/examples/ads1114/demo.json +10 -4
- package/examples/ads1115/demo.json +11 -5
- package/examples/ads7828/demo.json +12 -6
- package/examples/cat5171/demo.json +10 -4
- package/examples/cs43l22/demo.json +13 -7
- package/examples/ds1881/demo.json +12 -6
- package/examples/ds3502/demo.json +11 -5
- package/examples/es8311/demo.json +1 -1
- package/examples/hx710a/demo.json +38 -10
- package/examples/hx710b/demo.json +56 -15
- package/examples/hx711/demo.json +32 -9
- package/examples/hy3131/demo.json +1 -1
- package/examples/mcp3422/demo.json +12 -6
- package/examples/mcp4725/demo.json +1 -1
- package/examples/mcp4728/demo.json +5 -5
- package/examples/mcp4xxx/demo.json +1 -1
- package/examples/pcf8591/demo.json +30 -8
- package/nodes/ad5243/ad5243.html +46 -20
- package/nodes/ad5243/ad5243.js +28 -22
- package/nodes/ad5248/ad5248.html +3 -3
- package/nodes/ad5248/ad5248.js +1 -1
- package/nodes/ad5251/ad5251.html +45 -19
- package/nodes/ad5251/ad5251.js +29 -23
- package/nodes/ad5252/ad5252.html +45 -19
- package/nodes/ad5252/ad5252.js +29 -23
- package/nodes/ad7705/ad7705.html +3 -3
- package/nodes/ad7705/ad7705.js +1 -1
- package/nodes/ad7706/ad7706.html +3 -3
- package/nodes/ad7706/ad7706.js +1 -1
- package/nodes/ads1013/ads1013.html +44 -18
- package/nodes/ads1013/ads1013.js +22 -16
- package/nodes/ads1014/ads1014.html +46 -20
- package/nodes/ads1014/ads1014.js +22 -16
- package/nodes/ads1113/ads1113.html +44 -18
- package/nodes/ads1113/ads1113.js +17 -8
- package/nodes/ads1114/ads1114.html +46 -20
- package/nodes/ads1114/ads1114.js +17 -8
- package/nodes/ads1115/ads1115.html +48 -22
- package/nodes/ads1115/ads1115.js +17 -8
- package/nodes/ads7828/ads7828.html +47 -21
- package/nodes/ads7828/ads7828.js +23 -17
- package/nodes/cat5171/cat5171.html +46 -20
- package/nodes/cat5171/cat5171.js +28 -22
- package/nodes/cs43l22/cs43l22.html +48 -22
- package/nodes/cs43l22/cs43l22.js +29 -22
- package/nodes/ds1881/ds1881.html +48 -22
- package/nodes/ds1881/ds1881.js +34 -27
- package/nodes/ds3502/ds3502.html +46 -20
- package/nodes/ds3502/ds3502.js +25 -19
- package/nodes/es8311/es8311.html +3 -3
- package/nodes/es8311/es8311.js +1 -1
- package/nodes/hx710a/hx710a.html +48 -22
- package/nodes/hx710a/hx710a.js +18 -13
- package/nodes/hx710b/hx710b.html +48 -22
- package/nodes/hx710b/hx710b.js +18 -13
- package/nodes/hx711/hx711.html +48 -22
- package/nodes/hx711/hx711.js +17 -12
- package/nodes/hy3131/hy3131.html +3 -3
- package/nodes/hy3131/hy3131.js +1 -1
- package/nodes/mcp3422/mcp3422.html +46 -20
- package/nodes/mcp3422/mcp3422.js +28 -22
- package/nodes/mcp4725/mcp4725.html +3 -3
- package/nodes/mcp4725/mcp4725.js +1 -1
- package/nodes/mcp4728/mcp4728.html +3 -3
- package/nodes/mcp4728/mcp4728.js +1 -1
- package/nodes/mcp4xxx/mcp4xxx.html +3 -3
- package/nodes/mcp4xxx/mcp4xxx.js +1 -1
- package/nodes/pcf8591/pcf8591.html +37 -11
- package/nodes/pcf8591/pcf8591.js +16 -7
- package/package.json +1 -1
- package/index.js +0 -11
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
</script>
|
|
29
29
|
|
|
30
30
|
<script type="text/javascript">
|
|
31
|
-
RED.nodes.registerType('
|
|
31
|
+
RED.nodes.registerType('mcp4728', {
|
|
32
32
|
category: 'Peripheral',
|
|
33
33
|
color: '#C084FC',
|
|
34
34
|
defaults: {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
});
|
|
49
49
|
</script>
|
|
50
50
|
|
|
51
|
-
<script type="text/html" data-template-name="
|
|
51
|
+
<script type="text/html" data-template-name="mcp4728">
|
|
52
52
|
<div class="form-row">
|
|
53
53
|
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
54
54
|
<input type="text" id="node-input-device">
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
</div>
|
|
94
94
|
</script>
|
|
95
95
|
|
|
96
|
-
<script type="text/html" data-help-name="
|
|
96
|
+
<script type="text/html" data-help-name="mcp4728">
|
|
97
97
|
<p>Sets the output voltage of one channel (A–D) of an MCP4728 quad-channel 12-bit DAC over I²C.</p>
|
|
98
98
|
<p>Any input message triggers a DAC write. The device is configured via an <b>mcp4728-device</b> config node. Pass a 4-element array as <code>msg.payload</code> to update all four channels simultaneously via Fast Write.</p>
|
|
99
99
|
|
package/nodes/mcp4728/mcp4728.js
CHANGED
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
|
|
96
96
|
<!-- Node: set or read the wipers -->
|
|
97
97
|
<script type="text/javascript">
|
|
98
|
-
RED.nodes.registerType('
|
|
98
|
+
RED.nodes.registerType('mcp4xxx', {
|
|
99
99
|
category: 'Peripheral',
|
|
100
100
|
color: '#C084FC',
|
|
101
101
|
defaults: {
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
});
|
|
111
111
|
</script>
|
|
112
112
|
|
|
113
|
-
<script type="text/html" data-template-name="
|
|
113
|
+
<script type="text/html" data-template-name="mcp4xxx">
|
|
114
114
|
<div class="form-row">
|
|
115
115
|
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
116
116
|
<input type="text" id="node-input-device">
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
</div>
|
|
122
122
|
</script>
|
|
123
123
|
|
|
124
|
-
<script type="text/html" data-help-name="
|
|
124
|
+
<script type="text/html" data-help-name="mcp4xxx">
|
|
125
125
|
<p>Sets or reads the volatile wiper(s) of an MCP4XXX I²C digital potentiometer / rheostat
|
|
126
126
|
(MCP4531 … MCP4662: 7 / 8-bit, one or two networks, volatile or non-volatile). The device is
|
|
127
127
|
configured via an <b>mcp4xxx-device</b> config node.</p>
|
package/nodes/mcp4xxx/mcp4xxx.js
CHANGED
|
@@ -1,11 +1,41 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
1
2
|
<script type="text/javascript">
|
|
2
|
-
RED.nodes.registerType('
|
|
3
|
+
RED.nodes.registerType('pcf8591-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '48', required: true }
|
|
9
|
+
},
|
|
10
|
+
label: function() {
|
|
11
|
+
return this.name || ('PCF8591 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<script type="text/html" data-template-name="pcf8591-device">
|
|
17
|
+
<div class="form-row">
|
|
18
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
19
|
+
<input type="text" id="node-config-input-name" placeholder="PCF8591">
|
|
20
|
+
</div>
|
|
21
|
+
<div class="form-row">
|
|
22
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
23
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
24
|
+
</div>
|
|
25
|
+
<div class="form-row">
|
|
26
|
+
<label for="node-config-input-address">Address (hex)</label>
|
|
27
|
+
<input type="text" id="node-config-input-address" placeholder="48" style="width:80px"> default: 48 (0x48)
|
|
28
|
+
</div>
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<!-- Read node -->
|
|
32
|
+
<script type="text/javascript">
|
|
33
|
+
RED.nodes.registerType('pcf8591', {
|
|
3
34
|
category: 'Peripheral',
|
|
4
35
|
color: '#C084FC',
|
|
5
36
|
defaults: {
|
|
6
37
|
name: { value: '' },
|
|
7
|
-
|
|
8
|
-
address: { value: '48', required: true },
|
|
38
|
+
device: { value: '', type: 'pcf8591-device', required: true },
|
|
9
39
|
inputMode: { value: '4 single-ended' }
|
|
10
40
|
},
|
|
11
41
|
inputs: 1,
|
|
@@ -16,18 +46,14 @@
|
|
|
16
46
|
});
|
|
17
47
|
</script>
|
|
18
48
|
|
|
19
|
-
<script type="text/html" data-template-name="
|
|
49
|
+
<script type="text/html" data-template-name="pcf8591">
|
|
20
50
|
<div class="form-row">
|
|
21
51
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
22
52
|
<input type="text" id="node-input-name" placeholder="PCF8591">
|
|
23
53
|
</div>
|
|
24
54
|
<div class="form-row">
|
|
25
|
-
<label for="node-input-
|
|
26
|
-
<input type="
|
|
27
|
-
</div>
|
|
28
|
-
<div class="form-row">
|
|
29
|
-
<label for="node-input-address">Address (hex)</label>
|
|
30
|
-
<input type="text" id="node-input-address" placeholder="48" style="width:80px"> default: 48 (0x48)
|
|
55
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
56
|
+
<input type="text" id="node-input-device">
|
|
31
57
|
</div>
|
|
32
58
|
<div class="form-row">
|
|
33
59
|
<label for="node-input-inputMode"><i class="fa fa-cog"></i> Input mode</label>
|
|
@@ -40,7 +66,7 @@
|
|
|
40
66
|
</div>
|
|
41
67
|
</script>
|
|
42
68
|
|
|
43
|
-
<script type="text/html" data-help-name="
|
|
69
|
+
<script type="text/html" data-help-name="pcf8591">
|
|
44
70
|
<p>Reads the four analog inputs of a PCF8591 8-bit ADC/DAC over I²C. Default address is <code>0x48</code>; any address in the range <code>0x48</code>–<code>0x4F</code> is valid depending on the A0/A1/A2 pin states.</p>
|
|
45
71
|
|
|
46
72
|
<h3>Inputs</h3>
|
package/nodes/pcf8591/pcf8591.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { PCF8591Full } = require('periph/src/chips/adc_dac/pcf8591');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function PCF8591DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
10
|
try {
|
|
@@ -14,10 +14,22 @@ module.exports = function(RED) {
|
|
|
14
14
|
} catch (e) {
|
|
15
15
|
node.error('PCF8591 init failed: ' + e.message);
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
node.on('close', function() {
|
|
19
|
+
if (node.connection) node.connection.close();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
RED.nodes.registerType('pcf8591-device', PCF8591DeviceNode);
|
|
23
|
+
|
|
24
|
+
function PCF8591ReadNode(config) {
|
|
25
|
+
RED.nodes.createNode(this, config);
|
|
26
|
+
const node = this;
|
|
27
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
28
|
+
|
|
17
29
|
node.on('input', async function(msg, send, done) {
|
|
18
|
-
if (!
|
|
30
|
+
if (!deviceNode.driver) { done(); return; }
|
|
19
31
|
try {
|
|
20
|
-
const driver =
|
|
32
|
+
const driver = deviceNode.driver;
|
|
21
33
|
if (msg.payload && msg.payload.dac !== undefined) {
|
|
22
34
|
await driver.set_dac(msg.payload.dac);
|
|
23
35
|
}
|
|
@@ -29,9 +41,6 @@ module.exports = function(RED) {
|
|
|
29
41
|
done(e);
|
|
30
42
|
}
|
|
31
43
|
});
|
|
32
|
-
node.on('close', function() {
|
|
33
|
-
if (node.connection) node.connection.close();
|
|
34
|
-
});
|
|
35
44
|
}
|
|
36
|
-
RED.nodes.registerType('
|
|
45
|
+
RED.nodes.registerType('pcf8591', PCF8591ReadNode);
|
|
37
46
|
};
|
package/package.json
CHANGED
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
|
-
};
|