node-red-contrib-periph-adc-dac 1.5.1 → 1.5.3
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 +49 -27
- 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 +31 -3
- package/index.js +0 -11
|
@@ -1,33 +1,31 @@
|
|
|
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('ads1013-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
8
|
address: { value: '0x48' },
|
|
9
9
|
dataRate: { value: '4' }
|
|
10
10
|
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
label: function() { return this.name || 'ADS1013'; },
|
|
15
|
-
paletteLabel: 'ADS1013'
|
|
11
|
+
label: function() {
|
|
12
|
+
return this.name || ('ADS1013 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
13
|
+
}
|
|
16
14
|
});
|
|
17
15
|
</script>
|
|
18
16
|
|
|
19
|
-
<script type="text/html" data-template-name="
|
|
17
|
+
<script type="text/html" data-template-name="ads1013-device">
|
|
20
18
|
<div class="form-row">
|
|
21
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
22
|
-
<input type="text" id="node-input-name" placeholder="ADS1013">
|
|
19
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
20
|
+
<input type="text" id="node-config-input-name" placeholder="ADS1013">
|
|
23
21
|
</div>
|
|
24
22
|
<div class="form-row">
|
|
25
|
-
<label for="node-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
26
|
-
<input type="number" id="node-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
23
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
24
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
27
25
|
</div>
|
|
28
26
|
<div class="form-row">
|
|
29
|
-
<label for="node-input-address"><i class="fa fa-map-marker"></i> I²C address</label>
|
|
30
|
-
<select id="node-input-address" style="width:120px">
|
|
27
|
+
<label for="node-config-input-address"><i class="fa fa-map-marker"></i> I²C address</label>
|
|
28
|
+
<select id="node-config-input-address" style="width:120px">
|
|
31
29
|
<option value="0x48">0x48 (ADDR = GND)</option>
|
|
32
30
|
<option value="0x49">0x49 (ADDR = VDD)</option>
|
|
33
31
|
<option value="0x4A">0x4A (ADDR = SDA)</option>
|
|
@@ -35,8 +33,8 @@
|
|
|
35
33
|
</select>
|
|
36
34
|
</div>
|
|
37
35
|
<div class="form-row">
|
|
38
|
-
<label for="node-input-dataRate"><i class="fa fa-clock-o"></i> Data rate</label>
|
|
39
|
-
<select id="node-input-dataRate" style="width:160px">
|
|
36
|
+
<label for="node-config-input-dataRate"><i class="fa fa-clock-o"></i> Data rate</label>
|
|
37
|
+
<select id="node-config-input-dataRate" style="width:160px">
|
|
40
38
|
<option value="0">128 SPS</option>
|
|
41
39
|
<option value="1">250 SPS</option>
|
|
42
40
|
<option value="2">490 SPS</option>
|
|
@@ -48,7 +46,35 @@
|
|
|
48
46
|
</div>
|
|
49
47
|
</script>
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
<!-- Read node -->
|
|
50
|
+
<script type="text/javascript">
|
|
51
|
+
RED.nodes.registerType('ads1013', {
|
|
52
|
+
category: 'Peripheral',
|
|
53
|
+
color: '#C084FC',
|
|
54
|
+
defaults: {
|
|
55
|
+
name: { value: '' },
|
|
56
|
+
device: { value: '', type: 'ads1013-device', required: true }
|
|
57
|
+
},
|
|
58
|
+
inputs: 1,
|
|
59
|
+
outputs: 1,
|
|
60
|
+
icon: 'font-awesome/fa-tachometer',
|
|
61
|
+
label: function() { return this.name || 'ADS1013'; },
|
|
62
|
+
paletteLabel: 'ADS1013'
|
|
63
|
+
});
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<script type="text/html" data-template-name="ads1013">
|
|
67
|
+
<div class="form-row">
|
|
68
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
69
|
+
<input type="text" id="node-input-name" placeholder="ADS1013">
|
|
70
|
+
</div>
|
|
71
|
+
<div class="form-row">
|
|
72
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
73
|
+
<input type="text" id="node-input-device">
|
|
74
|
+
</div>
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<script type="text/html" data-help-name="ads1013">
|
|
52
78
|
<p>Reads the voltage AIN0 − AIN1 from an ADS1013 12-bit ADC over I²C using a single-shot conversion.</p>
|
|
53
79
|
|
|
54
80
|
<h3>Inputs</h3>
|
package/nodes/ads1013/ads1013.js
CHANGED
|
@@ -4,10 +4,9 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { ADS1013Full } = require('periph/src/chips/adc_dac/ads1013');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function ADS1013DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
|
-
|
|
11
10
|
try {
|
|
12
11
|
const address = parseInt(config.address, 16) || ADS1013Full.I2C_ADDRESS;
|
|
13
12
|
const connection = new I2CConnection(parseInt(config.bus, 10), address);
|
|
@@ -21,19 +20,6 @@ module.exports = function(RED) {
|
|
|
21
20
|
node.error('ADS1013 init failed: ' + e.message);
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
node.on('input', async function(msg, send, done) {
|
|
25
|
-
if (!node.driver) { done(); return; }
|
|
26
|
-
try {
|
|
27
|
-
await node.ready;
|
|
28
|
-
const raw = await node.driver.readRaw();
|
|
29
|
-
msg.payload = { raw, voltage: raw * node.driver.lsb() };
|
|
30
|
-
send(msg);
|
|
31
|
-
done();
|
|
32
|
-
} catch (e) {
|
|
33
|
-
done(e);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
23
|
node.on('close', async function(removed, done) {
|
|
38
24
|
try {
|
|
39
25
|
if (node.connection) await node.connection.close();
|
|
@@ -44,5 +30,25 @@ module.exports = function(RED) {
|
|
|
44
30
|
}
|
|
45
31
|
});
|
|
46
32
|
}
|
|
47
|
-
RED.nodes.registerType('
|
|
33
|
+
RED.nodes.registerType('ads1013-device', ADS1013DeviceNode);
|
|
34
|
+
|
|
35
|
+
function ADS1013ReadNode(config) {
|
|
36
|
+
RED.nodes.createNode(this, config);
|
|
37
|
+
const node = this;
|
|
38
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
39
|
+
|
|
40
|
+
node.on('input', async function(msg, send, done) {
|
|
41
|
+
if (!deviceNode.driver) { done(); return; }
|
|
42
|
+
try {
|
|
43
|
+
await deviceNode.ready;
|
|
44
|
+
const raw = await deviceNode.driver.readRaw();
|
|
45
|
+
msg.payload = { raw, voltage: raw * deviceNode.driver.lsb() };
|
|
46
|
+
send(msg);
|
|
47
|
+
done();
|
|
48
|
+
} catch (e) {
|
|
49
|
+
done(e);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
RED.nodes.registerType('ads1013', ADS1013ReadNode);
|
|
48
54
|
};
|
|
@@ -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('ads1014-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
@@ -9,26 +9,24 @@
|
|
|
9
9
|
gain: { value: '2' },
|
|
10
10
|
dataRate: { value: '4' }
|
|
11
11
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
label: function() { return this.name || 'ADS1014'; },
|
|
16
|
-
paletteLabel: 'ADS1014'
|
|
12
|
+
label: function() {
|
|
13
|
+
return this.name || ('ADS1014 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
14
|
+
}
|
|
17
15
|
});
|
|
18
16
|
</script>
|
|
19
17
|
|
|
20
|
-
<script type="text/html" data-template-name="
|
|
18
|
+
<script type="text/html" data-template-name="ads1014-device">
|
|
21
19
|
<div class="form-row">
|
|
22
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
23
|
-
<input type="text" id="node-input-name" placeholder="ADS1014">
|
|
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="ADS1014">
|
|
24
22
|
</div>
|
|
25
23
|
<div class="form-row">
|
|
26
|
-
<label for="node-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
27
|
-
<input type="number" id="node-input-bus" min="0" style="width:80px"> (Linux /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"> (Linux /dev/i2c-N)
|
|
28
26
|
</div>
|
|
29
27
|
<div class="form-row">
|
|
30
|
-
<label for="node-input-address"><i class="fa fa-map-marker"></i> I²C address</label>
|
|
31
|
-
<select id="node-input-address" style="width:120px">
|
|
28
|
+
<label for="node-config-input-address"><i class="fa fa-map-marker"></i> I²C address</label>
|
|
29
|
+
<select id="node-config-input-address" style="width:120px">
|
|
32
30
|
<option value="0x48">0x48 (ADDR = GND)</option>
|
|
33
31
|
<option value="0x49">0x49 (ADDR = VDD)</option>
|
|
34
32
|
<option value="0x4A">0x4A (ADDR = SDA)</option>
|
|
@@ -36,8 +34,8 @@
|
|
|
36
34
|
</select>
|
|
37
35
|
</div>
|
|
38
36
|
<div class="form-row">
|
|
39
|
-
<label for="node-input-gain"><i class="fa fa-sliders"></i> Gain</label>
|
|
40
|
-
<select id="node-input-gain" style="width:200px">
|
|
37
|
+
<label for="node-config-input-gain"><i class="fa fa-sliders"></i> Gain</label>
|
|
38
|
+
<select id="node-config-input-gain" style="width:200px">
|
|
41
39
|
<option value="0">±6.144 V (3 mV/LSB)</option>
|
|
42
40
|
<option value="1">±4.096 V (2 mV/LSB)</option>
|
|
43
41
|
<option value="2">±2.048 V (1 mV/LSB)</option>
|
|
@@ -47,8 +45,8 @@
|
|
|
47
45
|
</select>
|
|
48
46
|
</div>
|
|
49
47
|
<div class="form-row">
|
|
50
|
-
<label for="node-input-dataRate"><i class="fa fa-clock-o"></i> Data rate</label>
|
|
51
|
-
<select id="node-input-dataRate" style="width:160px">
|
|
48
|
+
<label for="node-config-input-dataRate"><i class="fa fa-clock-o"></i> Data rate</label>
|
|
49
|
+
<select id="node-config-input-dataRate" style="width:160px">
|
|
52
50
|
<option value="0">128 SPS</option>
|
|
53
51
|
<option value="1">250 SPS</option>
|
|
54
52
|
<option value="2">490 SPS</option>
|
|
@@ -60,7 +58,35 @@
|
|
|
60
58
|
</div>
|
|
61
59
|
</script>
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
<!-- Read node -->
|
|
62
|
+
<script type="text/javascript">
|
|
63
|
+
RED.nodes.registerType('ads1014', {
|
|
64
|
+
category: 'Peripheral',
|
|
65
|
+
color: '#C084FC',
|
|
66
|
+
defaults: {
|
|
67
|
+
name: { value: '' },
|
|
68
|
+
device: { value: '', type: 'ads1014-device', required: true }
|
|
69
|
+
},
|
|
70
|
+
inputs: 1,
|
|
71
|
+
outputs: 1,
|
|
72
|
+
icon: 'font-awesome/fa-tachometer',
|
|
73
|
+
label: function() { return this.name || 'ADS1014'; },
|
|
74
|
+
paletteLabel: 'ADS1014'
|
|
75
|
+
});
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<script type="text/html" data-template-name="ads1014">
|
|
79
|
+
<div class="form-row">
|
|
80
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
81
|
+
<input type="text" id="node-input-name" placeholder="ADS1014">
|
|
82
|
+
</div>
|
|
83
|
+
<div class="form-row">
|
|
84
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
85
|
+
<input type="text" id="node-input-device">
|
|
86
|
+
</div>
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<script type="text/html" data-help-name="ads1014">
|
|
64
90
|
<p>Reads the voltage AIN0 − AIN1 from an ADS1014 12-bit ADC over I²C using a single-shot conversion.</p>
|
|
65
91
|
|
|
66
92
|
<h3>Inputs</h3>
|
package/nodes/ads1014/ads1014.js
CHANGED
|
@@ -4,10 +4,9 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { ADS1014Full } = require('periph/src/chips/adc_dac/ads1014');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function ADS1014DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
|
-
|
|
11
10
|
try {
|
|
12
11
|
const address = parseInt(config.address, 16) || ADS1014Full.I2C_ADDRESS;
|
|
13
12
|
const connection = new I2CConnection(parseInt(config.bus, 10), address);
|
|
@@ -22,19 +21,6 @@ module.exports = function(RED) {
|
|
|
22
21
|
node.error('ADS1014 init failed: ' + e.message);
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
node.on('input', async function(msg, send, done) {
|
|
26
|
-
if (!node.driver) { done(); return; }
|
|
27
|
-
try {
|
|
28
|
-
await node.ready;
|
|
29
|
-
const raw = await node.driver.readRaw();
|
|
30
|
-
msg.payload = { raw, voltage: raw * node.driver.lsb() };
|
|
31
|
-
send(msg);
|
|
32
|
-
done();
|
|
33
|
-
} catch (e) {
|
|
34
|
-
done(e);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
24
|
node.on('close', async function(removed, done) {
|
|
39
25
|
try {
|
|
40
26
|
if (node.connection) await node.connection.close();
|
|
@@ -45,5 +31,25 @@ module.exports = function(RED) {
|
|
|
45
31
|
}
|
|
46
32
|
});
|
|
47
33
|
}
|
|
48
|
-
RED.nodes.registerType('
|
|
34
|
+
RED.nodes.registerType('ads1014-device', ADS1014DeviceNode);
|
|
35
|
+
|
|
36
|
+
function ADS1014ReadNode(config) {
|
|
37
|
+
RED.nodes.createNode(this, config);
|
|
38
|
+
const node = this;
|
|
39
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
40
|
+
|
|
41
|
+
node.on('input', async function(msg, send, done) {
|
|
42
|
+
if (!deviceNode.driver) { done(); return; }
|
|
43
|
+
try {
|
|
44
|
+
await deviceNode.ready;
|
|
45
|
+
const raw = await deviceNode.driver.readRaw();
|
|
46
|
+
msg.payload = { raw, voltage: raw * deviceNode.driver.lsb() };
|
|
47
|
+
send(msg);
|
|
48
|
+
done();
|
|
49
|
+
} catch (e) {
|
|
50
|
+
done(e);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
RED.nodes.registerType('ads1014', ADS1014ReadNode);
|
|
49
55
|
};
|
|
@@ -1,37 +1,35 @@
|
|
|
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('ads1113-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
8
|
address: { value: '48', required: true },
|
|
9
9
|
dataRate: { value: '4' }
|
|
10
10
|
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
label: function() { return this.name || 'ADS1113'; },
|
|
15
|
-
paletteLabel: 'ADS1113'
|
|
11
|
+
label: function() {
|
|
12
|
+
return this.name || ('ADS1113 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
13
|
+
}
|
|
16
14
|
});
|
|
17
15
|
</script>
|
|
18
16
|
|
|
19
|
-
<script type="text/html" data-template-name="
|
|
17
|
+
<script type="text/html" data-template-name="ads1113-device">
|
|
20
18
|
<div class="form-row">
|
|
21
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
22
|
-
<input type="text" id="node-input-name" placeholder="ADS1113">
|
|
19
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
20
|
+
<input type="text" id="node-config-input-name" placeholder="ADS1113">
|
|
23
21
|
</div>
|
|
24
22
|
<div class="form-row">
|
|
25
|
-
<label for="node-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
26
|
-
<input type="number" id="node-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
23
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
24
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
27
25
|
</div>
|
|
28
26
|
<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"> 48–4B (ADDR strap), default 48
|
|
27
|
+
<label for="node-config-input-address">Address (hex)</label>
|
|
28
|
+
<input type="text" id="node-config-input-address" placeholder="48" style="width:80px"> 48–4B (ADDR strap), default 48
|
|
31
29
|
</div>
|
|
32
30
|
<div class="form-row">
|
|
33
|
-
<label for="node-input-dataRate"><i class="fa fa-clock-o"></i> Data rate</label>
|
|
34
|
-
<select id="node-input-dataRate" style="width:140px">
|
|
31
|
+
<label for="node-config-input-dataRate"><i class="fa fa-clock-o"></i> Data rate</label>
|
|
32
|
+
<select id="node-config-input-dataRate" style="width:140px">
|
|
35
33
|
<option value="0">8 SPS</option>
|
|
36
34
|
<option value="1">16 SPS</option>
|
|
37
35
|
<option value="2">32 SPS</option>
|
|
@@ -44,7 +42,35 @@
|
|
|
44
42
|
</div>
|
|
45
43
|
</script>
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
<!-- Read node -->
|
|
46
|
+
<script type="text/javascript">
|
|
47
|
+
RED.nodes.registerType('ads1113', {
|
|
48
|
+
category: 'Peripheral',
|
|
49
|
+
color: '#C084FC',
|
|
50
|
+
defaults: {
|
|
51
|
+
name: { value: '' },
|
|
52
|
+
device: { value: '', type: 'ads1113-device', required: true }
|
|
53
|
+
},
|
|
54
|
+
inputs: 1,
|
|
55
|
+
outputs: 1,
|
|
56
|
+
icon: 'font-awesome/fa-microchip',
|
|
57
|
+
label: function() { return this.name || 'ADS1113'; },
|
|
58
|
+
paletteLabel: 'ADS1113'
|
|
59
|
+
});
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<script type="text/html" data-template-name="ads1113">
|
|
63
|
+
<div class="form-row">
|
|
64
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
65
|
+
<input type="text" id="node-input-name" placeholder="ADS1113">
|
|
66
|
+
</div>
|
|
67
|
+
<div class="form-row">
|
|
68
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
69
|
+
<input type="text" id="node-input-device">
|
|
70
|
+
</div>
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<script type="text/html" data-help-name="ads1113">
|
|
48
74
|
<p>Reads the ADS1113 16-bit ΔΣ ADC (one differential input (AIN0 − AIN1), fixed ±2.048 V) over I²C. Default address is <code>0x48</code>; <code>0x48</code>–<code>0x4B</code> are valid depending on the ADDR strap.</p>
|
|
49
75
|
|
|
50
76
|
<h3>Inputs</h3>
|
package/nodes/ads1113/ads1113.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { ADS1113Full } = require('periph/src/chips/adc_dac/ads1113');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function ADS1113DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
10
|
try {
|
|
@@ -17,11 +17,23 @@ module.exports = function(RED) {
|
|
|
17
17
|
} catch (e) {
|
|
18
18
|
node.error('ADS1113 init failed: ' + e.message);
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
node.on('close', function() {
|
|
22
|
+
if (node.connection) node.connection.close();
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
RED.nodes.registerType('ads1113-device', ADS1113DeviceNode);
|
|
26
|
+
|
|
27
|
+
function ADS1113ReadNode(config) {
|
|
28
|
+
RED.nodes.createNode(this, config);
|
|
29
|
+
const node = this;
|
|
30
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
31
|
+
|
|
20
32
|
node.on('input', async function(msg, send, done) {
|
|
21
|
-
if (!
|
|
33
|
+
if (!deviceNode.driver) { done(); return; }
|
|
22
34
|
try {
|
|
23
|
-
await
|
|
24
|
-
const driver =
|
|
35
|
+
await deviceNode.ready;
|
|
36
|
+
const driver = deviceNode.driver;
|
|
25
37
|
const raw = await driver.readRaw();
|
|
26
38
|
msg.payload = { raw, voltage: raw * driver.lsb() };
|
|
27
39
|
send(msg);
|
|
@@ -30,9 +42,6 @@ module.exports = function(RED) {
|
|
|
30
42
|
done(e);
|
|
31
43
|
}
|
|
32
44
|
});
|
|
33
|
-
node.on('close', function() {
|
|
34
|
-
if (node.connection) node.connection.close();
|
|
35
|
-
});
|
|
36
45
|
}
|
|
37
|
-
RED.nodes.registerType('
|
|
46
|
+
RED.nodes.registerType('ads1113', ADS1113ReadNode);
|
|
38
47
|
};
|
|
@@ -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('ads1114-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
@@ -9,30 +9,28 @@
|
|
|
9
9
|
gain: { value: '2' },
|
|
10
10
|
dataRate: { value: '4' }
|
|
11
11
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
label: function() { return this.name || 'ADS1114'; },
|
|
16
|
-
paletteLabel: 'ADS1114'
|
|
12
|
+
label: function() {
|
|
13
|
+
return this.name || ('ADS1114 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
14
|
+
}
|
|
17
15
|
});
|
|
18
16
|
</script>
|
|
19
17
|
|
|
20
|
-
<script type="text/html" data-template-name="
|
|
18
|
+
<script type="text/html" data-template-name="ads1114-device">
|
|
21
19
|
<div class="form-row">
|
|
22
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
23
|
-
<input type="text" id="node-input-name" placeholder="ADS1114">
|
|
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="ADS1114">
|
|
24
22
|
</div>
|
|
25
23
|
<div class="form-row">
|
|
26
|
-
<label for="node-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
27
|
-
<input type="number" id="node-input-bus" min="0" style="width:80px"> (Linux /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"> (Linux /dev/i2c-N)
|
|
28
26
|
</div>
|
|
29
27
|
<div class="form-row">
|
|
30
|
-
<label for="node-input-address">Address (hex)</label>
|
|
31
|
-
<input type="text" id="node-input-address" placeholder="48" style="width:80px"> 48–4B (ADDR strap), default 48
|
|
28
|
+
<label for="node-config-input-address">Address (hex)</label>
|
|
29
|
+
<input type="text" id="node-config-input-address" placeholder="48" style="width:80px"> 48–4B (ADDR strap), default 48
|
|
32
30
|
</div>
|
|
33
31
|
<div class="form-row">
|
|
34
|
-
<label for="node-input-gain"><i class="fa fa-cog"></i> Gain</label>
|
|
35
|
-
<select id="node-input-gain" style="width:140px">
|
|
32
|
+
<label for="node-config-input-gain"><i class="fa fa-cog"></i> Gain</label>
|
|
33
|
+
<select id="node-config-input-gain" style="width:140px">
|
|
36
34
|
<option value="0">±6.144 V</option>
|
|
37
35
|
<option value="1">±4.096 V</option>
|
|
38
36
|
<option value="2">±2.048 V</option>
|
|
@@ -42,8 +40,8 @@
|
|
|
42
40
|
</select>
|
|
43
41
|
</div>
|
|
44
42
|
<div class="form-row">
|
|
45
|
-
<label for="node-input-dataRate"><i class="fa fa-clock-o"></i> Data rate</label>
|
|
46
|
-
<select id="node-input-dataRate" style="width:140px">
|
|
43
|
+
<label for="node-config-input-dataRate"><i class="fa fa-clock-o"></i> Data rate</label>
|
|
44
|
+
<select id="node-config-input-dataRate" style="width:140px">
|
|
47
45
|
<option value="0">8 SPS</option>
|
|
48
46
|
<option value="1">16 SPS</option>
|
|
49
47
|
<option value="2">32 SPS</option>
|
|
@@ -56,7 +54,35 @@
|
|
|
56
54
|
</div>
|
|
57
55
|
</script>
|
|
58
56
|
|
|
59
|
-
|
|
57
|
+
<!-- Read node -->
|
|
58
|
+
<script type="text/javascript">
|
|
59
|
+
RED.nodes.registerType('ads1114', {
|
|
60
|
+
category: 'Peripheral',
|
|
61
|
+
color: '#C084FC',
|
|
62
|
+
defaults: {
|
|
63
|
+
name: { value: '' },
|
|
64
|
+
device: { value: '', type: 'ads1114-device', required: true }
|
|
65
|
+
},
|
|
66
|
+
inputs: 1,
|
|
67
|
+
outputs: 1,
|
|
68
|
+
icon: 'font-awesome/fa-microchip',
|
|
69
|
+
label: function() { return this.name || 'ADS1114'; },
|
|
70
|
+
paletteLabel: 'ADS1114'
|
|
71
|
+
});
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<script type="text/html" data-template-name="ads1114">
|
|
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="ADS1114">
|
|
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="ads1114">
|
|
60
86
|
<p>Reads the ADS1114 16-bit ΔΣ ADC (one differential input (AIN0 − AIN1) with programmable gain) over I²C. Default address is <code>0x48</code>; <code>0x48</code>–<code>0x4B</code> are valid depending on the ADDR strap.</p>
|
|
61
87
|
|
|
62
88
|
<h3>Inputs</h3>
|
package/nodes/ads1114/ads1114.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { ADS1114Full } = require('periph/src/chips/adc_dac/ads1114');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function ADS1114DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
10
|
try {
|
|
@@ -18,11 +18,23 @@ module.exports = function(RED) {
|
|
|
18
18
|
} catch (e) {
|
|
19
19
|
node.error('ADS1114 init failed: ' + e.message);
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
node.on('close', function() {
|
|
23
|
+
if (node.connection) node.connection.close();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
RED.nodes.registerType('ads1114-device', ADS1114DeviceNode);
|
|
27
|
+
|
|
28
|
+
function ADS1114ReadNode(config) {
|
|
29
|
+
RED.nodes.createNode(this, config);
|
|
30
|
+
const node = this;
|
|
31
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
32
|
+
|
|
21
33
|
node.on('input', async function(msg, send, done) {
|
|
22
|
-
if (!
|
|
34
|
+
if (!deviceNode.driver) { done(); return; }
|
|
23
35
|
try {
|
|
24
|
-
await
|
|
25
|
-
const driver =
|
|
36
|
+
await deviceNode.ready;
|
|
37
|
+
const driver = deviceNode.driver;
|
|
26
38
|
const raw = await driver.readRaw();
|
|
27
39
|
msg.payload = { raw, voltage: raw * driver.lsb() };
|
|
28
40
|
send(msg);
|
|
@@ -31,9 +43,6 @@ module.exports = function(RED) {
|
|
|
31
43
|
done(e);
|
|
32
44
|
}
|
|
33
45
|
});
|
|
34
|
-
node.on('close', function() {
|
|
35
|
-
if (node.connection) node.connection.close();
|
|
36
|
-
});
|
|
37
46
|
}
|
|
38
|
-
RED.nodes.registerType('
|
|
47
|
+
RED.nodes.registerType('ads1114', ADS1114ReadNode);
|
|
39
48
|
};
|