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
package/nodes/cs43l22/cs43l22.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { CS43L22Full, BEEP, FMT } = require('periph/src/chips/adc_dac/cs43l22');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function CS43L22DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
10
|
node.ready = null;
|
|
@@ -31,31 +31,48 @@ module.exports = function(RED) {
|
|
|
31
31
|
node.error('CS43L22 init failed: ' + e.message);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
node.on('close', async function(removed, done) {
|
|
35
|
+
try {
|
|
36
|
+
if (node.connection) await node.connection.close();
|
|
37
|
+
} catch (e) {
|
|
38
|
+
// bus may already be gone; nothing more to do on close
|
|
39
|
+
} finally {
|
|
40
|
+
done();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
RED.nodes.registerType('cs43l22-device', CS43L22DeviceNode);
|
|
45
|
+
|
|
46
|
+
function CS43L22ReadNode(config) {
|
|
47
|
+
RED.nodes.createNode(this, config);
|
|
48
|
+
const node = this;
|
|
49
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
50
|
+
|
|
34
51
|
node.on('input', async function(msg, send, done) {
|
|
35
|
-
if (!
|
|
52
|
+
if (!deviceNode.driver) { done(); return; }
|
|
36
53
|
try {
|
|
37
|
-
await
|
|
54
|
+
await deviceNode.ready;
|
|
38
55
|
const p = msg.payload;
|
|
39
56
|
const isObj = p && typeof p === 'object';
|
|
40
57
|
let handled = false;
|
|
41
|
-
if (isObj && p.start === true) { await
|
|
42
|
-
if (isObj && p.stop === true) { await
|
|
43
|
-
if (isObj && typeof p.volume === 'number') { await
|
|
44
|
-
if (isObj && typeof p.mute === 'boolean') { await
|
|
58
|
+
if (isObj && p.start === true) { await deviceNode.driver.start(); handled = true; }
|
|
59
|
+
if (isObj && p.stop === true) { await deviceNode.driver.stop(); handled = true; }
|
|
60
|
+
if (isObj && typeof p.volume === 'number') { await deviceNode.driver.setVolume(p.volume); handled = true; }
|
|
61
|
+
if (isObj && typeof p.mute === 'boolean') { await deviceNode.driver.mute(p.mute); handled = true; }
|
|
45
62
|
if (isObj && p.beep && typeof p.beep === 'object') {
|
|
46
63
|
const b = p.beep;
|
|
47
|
-
await
|
|
64
|
+
await deviceNode.driver.setBeep(b.frequency ?? 12, b.onTime ?? 2, b.offTime ?? 0, b.volume ?? -6,
|
|
48
65
|
b.mode ?? BEEP.SINGLE);
|
|
49
66
|
handled = true;
|
|
50
67
|
}
|
|
51
68
|
if (isObj && p.tone && typeof p.tone === 'object') {
|
|
52
|
-
await
|
|
69
|
+
await deviceNode.driver.setTone(p.tone.treble ?? 0, p.tone.bass ?? 0);
|
|
53
70
|
handled = true;
|
|
54
71
|
}
|
|
55
72
|
if (handled && !(isObj && typeof p.volume === 'number')) { done(); return; }
|
|
56
73
|
msg.payload = {
|
|
57
|
-
volume: await
|
|
58
|
-
status: await
|
|
74
|
+
volume: await deviceNode.driver.getVolume(),
|
|
75
|
+
status: await deviceNode.driver.readStatus(),
|
|
59
76
|
};
|
|
60
77
|
send(msg);
|
|
61
78
|
done();
|
|
@@ -63,16 +80,6 @@ module.exports = function(RED) {
|
|
|
63
80
|
done(e);
|
|
64
81
|
}
|
|
65
82
|
});
|
|
66
|
-
|
|
67
|
-
node.on('close', async function(removed, done) {
|
|
68
|
-
try {
|
|
69
|
-
if (node.connection) await node.connection.close();
|
|
70
|
-
} catch (e) {
|
|
71
|
-
// bus may already be gone; nothing more to do on close
|
|
72
|
-
} finally {
|
|
73
|
-
done();
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
83
|
}
|
|
77
|
-
RED.nodes.registerType('
|
|
84
|
+
RED.nodes.registerType('cs43l22', CS43L22ReadNode);
|
|
78
85
|
};
|
package/nodes/ds1881/ds1881.html
CHANGED
|
@@ -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('ds1881-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
@@ -10,26 +10,24 @@
|
|
|
10
10
|
zerocrossing: { value: true },
|
|
11
11
|
nonvolatile: { value: false }
|
|
12
12
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
label: function() { return this.name || 'DS1881'; },
|
|
17
|
-
paletteLabel: 'DS1881'
|
|
13
|
+
label: function() {
|
|
14
|
+
return this.name || ('DS1881 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
15
|
+
}
|
|
18
16
|
});
|
|
19
17
|
</script>
|
|
20
18
|
|
|
21
|
-
<script type="text/html" data-template-name="
|
|
19
|
+
<script type="text/html" data-template-name="ds1881-device">
|
|
22
20
|
<div class="form-row">
|
|
23
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
24
|
-
<input type="text" id="node-input-name" placeholder="DS1881">
|
|
21
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
22
|
+
<input type="text" id="node-config-input-name" placeholder="DS1881">
|
|
25
23
|
</div>
|
|
26
24
|
<div class="form-row">
|
|
27
|
-
<label for="node-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
28
|
-
<input type="number" id="node-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
25
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
26
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
29
27
|
</div>
|
|
30
28
|
<div class="form-row">
|
|
31
|
-
<label for="node-input-address"><i class="fa fa-at"></i> I²C address</label>
|
|
32
|
-
<select id="node-input-address" style="width:200px">
|
|
29
|
+
<label for="node-config-input-address"><i class="fa fa-at"></i> I²C address</label>
|
|
30
|
+
<select id="node-config-input-address" style="width:200px">
|
|
33
31
|
<option value="0x28">0x28 (A2 A1 A0 = 000)</option>
|
|
34
32
|
<option value="0x29">0x29 (A2 A1 A0 = 001)</option>
|
|
35
33
|
<option value="0x2A">0x2A (A2 A1 A0 = 010)</option>
|
|
@@ -41,23 +39,51 @@
|
|
|
41
39
|
</select>
|
|
42
40
|
</div>
|
|
43
41
|
<div class="form-row">
|
|
44
|
-
<label for="node-input-option"><i class="fa fa-sliders"></i> Option</label>
|
|
45
|
-
<select id="node-input-option" style="width:260px">
|
|
42
|
+
<label for="node-config-input-option"><i class="fa fa-sliders"></i> Option</label>
|
|
43
|
+
<select id="node-config-input-option" style="width:260px">
|
|
46
44
|
<option value="1">1 — 1 dB steps, 0 to −62 dB + mute</option>
|
|
47
45
|
<option value="2">2 — 1/2/3 dB steps (DS1808 compatible)</option>
|
|
48
46
|
</select>
|
|
49
47
|
</div>
|
|
50
48
|
<div class="form-row">
|
|
51
|
-
<label for="node-input-zerocrossing"><i class="fa fa-bolt"></i> Zero-crossing</label>
|
|
52
|
-
<input type="checkbox" id="node-input-zerocrossing" style="width:auto"> clickless wiper changes (up to 50 ms)
|
|
49
|
+
<label for="node-config-input-zerocrossing"><i class="fa fa-bolt"></i> Zero-crossing</label>
|
|
50
|
+
<input type="checkbox" id="node-config-input-zerocrossing" style="width:auto"> clickless wiper changes (up to 50 ms)
|
|
51
|
+
</div>
|
|
52
|
+
<div class="form-row">
|
|
53
|
+
<label for="node-config-input-nonvolatile"><i class="fa fa-database"></i> Nonvolatile</label>
|
|
54
|
+
<input type="checkbox" id="node-config-input-nonvolatile" style="width:auto"> store every wiper write in EEPROM (50 000 writes)
|
|
55
|
+
</div>
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<!-- Read node -->
|
|
59
|
+
<script type="text/javascript">
|
|
60
|
+
RED.nodes.registerType('ds1881', {
|
|
61
|
+
category: 'Peripheral',
|
|
62
|
+
color: '#C084FC',
|
|
63
|
+
defaults: {
|
|
64
|
+
name: { value: '' },
|
|
65
|
+
device: { value: '', type: 'ds1881-device', required: true }
|
|
66
|
+
},
|
|
67
|
+
inputs: 1,
|
|
68
|
+
outputs: 1,
|
|
69
|
+
icon: 'font-awesome/fa-volume-up',
|
|
70
|
+
label: function() { return this.name || 'DS1881'; },
|
|
71
|
+
paletteLabel: 'DS1881'
|
|
72
|
+
});
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<script type="text/html" data-template-name="ds1881">
|
|
76
|
+
<div class="form-row">
|
|
77
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
78
|
+
<input type="text" id="node-input-name" placeholder="DS1881">
|
|
53
79
|
</div>
|
|
54
80
|
<div class="form-row">
|
|
55
|
-
<label for="node-input-
|
|
56
|
-
<input type="
|
|
81
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
82
|
+
<input type="text" id="node-input-device">
|
|
57
83
|
</div>
|
|
58
84
|
</script>
|
|
59
85
|
|
|
60
|
-
<script type="text/html" data-help-name="
|
|
86
|
+
<script type="text/html" data-help-name="ds1881">
|
|
61
87
|
<p>Controls the two audio log-taper channels of a DS1881 dual digital potentiometer. Attenuation is in dB (0 dB = wiper at H); position 63 (Option 1) or 33 (Option 2) is mute. By default the wipers are volatile and power up at mute.</p>
|
|
62
88
|
|
|
63
89
|
<h3>Inputs</h3>
|
package/nodes/ds1881/ds1881.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { DS1881Full } = require('periph/src/chips/adc_dac/ds1881');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function DS1881DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
10
|
node.lastDb = [0, 0];
|
|
@@ -28,45 +28,62 @@ module.exports = function(RED) {
|
|
|
28
28
|
node.error('DS1881 init failed: ' + e.message);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
node.on('close', async function(removed, done) {
|
|
32
|
+
try {
|
|
33
|
+
if (node.connection) await node.connection.close();
|
|
34
|
+
} catch (e) {
|
|
35
|
+
// bus may already be gone; nothing more to do on close
|
|
36
|
+
} finally {
|
|
37
|
+
done();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
RED.nodes.registerType('ds1881-device', DS1881DeviceNode);
|
|
42
|
+
|
|
43
|
+
function DS1881ReadNode(config) {
|
|
44
|
+
RED.nodes.createNode(this, config);
|
|
45
|
+
const node = this;
|
|
46
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
47
|
+
|
|
31
48
|
async function readback() {
|
|
32
|
-
const [position0, position1, raw] = await
|
|
33
|
-
const cfg = await
|
|
49
|
+
const [position0, position1, raw] = await deviceNode.driver.readAll();
|
|
50
|
+
const cfg = await deviceNode.driver.getConfig();
|
|
34
51
|
return {
|
|
35
52
|
position0, position1,
|
|
36
|
-
db0:
|
|
37
|
-
db1:
|
|
53
|
+
db0: deviceNode.driver.positionToDb(position0),
|
|
54
|
+
db1: deviceNode.driver.positionToDb(position1),
|
|
38
55
|
config: { option: cfg.option, zeroCrossing: cfg.zeroCrossing, nonvolatile: cfg.nonvolatile, raw },
|
|
39
56
|
};
|
|
40
57
|
}
|
|
41
58
|
|
|
42
59
|
node.on('input', async function(msg, send, done) {
|
|
43
|
-
if (!
|
|
60
|
+
if (!deviceNode.driver) { done(); return; }
|
|
44
61
|
try {
|
|
45
|
-
await
|
|
62
|
+
await deviceNode.ready;
|
|
46
63
|
const p = msg.payload;
|
|
47
64
|
const isObj = p && typeof p === 'object';
|
|
48
65
|
if (isObj && p.store === true) {
|
|
49
|
-
await
|
|
66
|
+
await deviceNode.driver.store();
|
|
50
67
|
done();
|
|
51
68
|
return;
|
|
52
69
|
}
|
|
53
70
|
if (isObj && typeof p.mute === 'boolean') {
|
|
54
71
|
const channels = typeof p.channel === 'number' ? [p.channel] : [0, 1];
|
|
55
72
|
for (const ch of channels) {
|
|
56
|
-
if (p.mute) await
|
|
57
|
-
else await
|
|
73
|
+
if (p.mute) await deviceNode.driver.mute(ch);
|
|
74
|
+
else await deviceNode.driver.setAttenuation(ch, deviceNode.lastDb[ch]);
|
|
58
75
|
}
|
|
59
76
|
done();
|
|
60
77
|
return;
|
|
61
78
|
}
|
|
62
79
|
if (isObj && typeof p.db === 'number' && typeof p.channel === 'number') {
|
|
63
|
-
await
|
|
64
|
-
|
|
65
|
-
const position = await
|
|
66
|
-
msg.payload = { channel: p.channel, position, db:
|
|
80
|
+
await deviceNode.driver.setAttenuation(p.channel, p.db);
|
|
81
|
+
deviceNode.lastDb[p.channel] = p.db;
|
|
82
|
+
const position = await deviceNode.driver.getPosition(p.channel);
|
|
83
|
+
msg.payload = { channel: p.channel, position, db: deviceNode.driver.positionToDb(position) };
|
|
67
84
|
} else if (isObj && typeof p.db === 'number') {
|
|
68
|
-
await
|
|
69
|
-
|
|
85
|
+
await deviceNode.driver.setAttenuationBoth(p.db);
|
|
86
|
+
deviceNode.lastDb = [p.db, p.db];
|
|
70
87
|
const r = await readback();
|
|
71
88
|
msg.payload = { position0: r.position0, position1: r.position1, db0: r.db0, db1: r.db1 };
|
|
72
89
|
} else {
|
|
@@ -78,16 +95,6 @@ module.exports = function(RED) {
|
|
|
78
95
|
done(e);
|
|
79
96
|
}
|
|
80
97
|
});
|
|
81
|
-
|
|
82
|
-
node.on('close', async function(removed, done) {
|
|
83
|
-
try {
|
|
84
|
-
if (node.connection) await node.connection.close();
|
|
85
|
-
} catch (e) {
|
|
86
|
-
// bus may already be gone; nothing more to do on close
|
|
87
|
-
} finally {
|
|
88
|
-
done();
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
98
|
}
|
|
92
|
-
RED.nodes.registerType('
|
|
99
|
+
RED.nodes.registerType('ds1881', DS1881ReadNode);
|
|
93
100
|
};
|
package/nodes/ds3502/ds3502.html
CHANGED
|
@@ -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('ds3502-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
|
vhigh: { value: '15', required: true, validate: RED.validators.number() },
|
|
10
10
|
vlow: { value: '0', required: true, validate: RED.validators.number() }
|
|
11
11
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
label: function() { return this.name || 'DS3502'; },
|
|
16
|
-
paletteLabel: 'DS3502'
|
|
12
|
+
label: function() {
|
|
13
|
+
return this.name || ('DS3502 @ ' + 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="ds3502-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="DS3502">
|
|
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="DS3502">
|
|
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-at"></i> I²C address</label>
|
|
31
|
-
<select id="node-input-address" style="width:200px">
|
|
28
|
+
<label for="node-config-input-address"><i class="fa fa-at"></i> I²C address</label>
|
|
29
|
+
<select id="node-config-input-address" style="width:200px">
|
|
32
30
|
<option value="0x28">0x28 (A1 = A0 = GND)</option>
|
|
33
31
|
<option value="0x29">0x29 (A1 = GND, A0 = VCC)</option>
|
|
34
32
|
<option value="0x2A">0x2A (A1 = VCC, A0 = GND)</option>
|
|
@@ -36,16 +34,44 @@
|
|
|
36
34
|
</select>
|
|
37
35
|
</div>
|
|
38
36
|
<div class="form-row">
|
|
39
|
-
<label for="node-input-vhigh"><i class="fa fa-bolt"></i> RH voltage</label>
|
|
40
|
-
<input type="number" id="node-input-vhigh" step="any" style="width:80px"> V
|
|
37
|
+
<label for="node-config-input-vhigh"><i class="fa fa-bolt"></i> RH voltage</label>
|
|
38
|
+
<input type="number" id="node-config-input-vhigh" step="any" style="width:80px"> V
|
|
39
|
+
</div>
|
|
40
|
+
<div class="form-row">
|
|
41
|
+
<label for="node-config-input-vlow"><i class="fa fa-bolt"></i> RL voltage</label>
|
|
42
|
+
<input type="number" id="node-config-input-vlow" step="any" style="width:80px"> V
|
|
43
|
+
</div>
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<!-- Read node -->
|
|
47
|
+
<script type="text/javascript">
|
|
48
|
+
RED.nodes.registerType('ds3502', {
|
|
49
|
+
category: 'Peripheral',
|
|
50
|
+
color: '#C084FC',
|
|
51
|
+
defaults: {
|
|
52
|
+
name: { value: '' },
|
|
53
|
+
device: { value: '', type: 'ds3502-device', required: true }
|
|
54
|
+
},
|
|
55
|
+
inputs: 1,
|
|
56
|
+
outputs: 1,
|
|
57
|
+
icon: 'font-awesome/fa-sliders',
|
|
58
|
+
label: function() { return this.name || 'DS3502'; },
|
|
59
|
+
paletteLabel: 'DS3502'
|
|
60
|
+
});
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<script type="text/html" data-template-name="ds3502">
|
|
64
|
+
<div class="form-row">
|
|
65
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
66
|
+
<input type="text" id="node-input-name" placeholder="DS3502">
|
|
41
67
|
</div>
|
|
42
68
|
<div class="form-row">
|
|
43
|
-
<label for="node-input-
|
|
44
|
-
<input type="
|
|
69
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
70
|
+
<input type="text" id="node-input-device">
|
|
45
71
|
</div>
|
|
46
72
|
</script>
|
|
47
73
|
|
|
48
|
-
<script type="text/html" data-help-name="
|
|
74
|
+
<script type="text/html" data-help-name="ds3502">
|
|
49
75
|
<p>Sets and reads the 128-position wiper of a DS3502 high-voltage I²C digital potentiometer. Wiper writes go to SRAM only (MODE = 1) and never wear the EEPROM; the wiper powers up at the stored Initial Value Register position (factory default 64, midscale).</p>
|
|
50
76
|
|
|
51
77
|
<h3>Inputs</h3>
|
package/nodes/ds3502/ds3502.js
CHANGED
|
@@ -4,10 +4,9 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { DS3502Full } = require('periph/src/chips/adc_dac/ds3502');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function DS3502DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
|
-
|
|
11
10
|
const vHigh = config.vhigh === '' || config.vhigh === undefined ? 1.0 : parseFloat(config.vhigh);
|
|
12
11
|
const vLow = config.vlow === '' || config.vlow === undefined ? 0.0 : parseFloat(config.vlow);
|
|
13
12
|
const address = parseInt(config.address || '0x28', 16);
|
|
@@ -28,18 +27,35 @@ module.exports = function(RED) {
|
|
|
28
27
|
return Object.assign({ code, ratio, voltage }, extra);
|
|
29
28
|
}
|
|
30
29
|
|
|
30
|
+
node.on('close', async function(removed, done) {
|
|
31
|
+
try {
|
|
32
|
+
if (node.connection) await node.connection.close();
|
|
33
|
+
} catch (e) {
|
|
34
|
+
// bus may already be gone; nothing more to do on close
|
|
35
|
+
} finally {
|
|
36
|
+
done();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
RED.nodes.registerType('ds3502-device', DS3502DeviceNode);
|
|
41
|
+
|
|
42
|
+
function DS3502ReadNode(config) {
|
|
43
|
+
RED.nodes.createNode(this, config);
|
|
44
|
+
const node = this;
|
|
45
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
46
|
+
|
|
31
47
|
node.on('input', async function(msg, send, done) {
|
|
32
|
-
if (!
|
|
48
|
+
if (!deviceNode.driver) { done(); return; }
|
|
33
49
|
try {
|
|
34
|
-
await
|
|
50
|
+
await deviceNode.ready;
|
|
35
51
|
const p = msg.payload;
|
|
36
52
|
let extra;
|
|
37
53
|
if (p && typeof p === 'object') {
|
|
38
|
-
if (typeof p.code === 'number') await
|
|
39
|
-
else if (typeof p.ratio === 'number') await
|
|
40
|
-
else if (typeof p.voltage === 'number') await
|
|
54
|
+
if (typeof p.code === 'number') await deviceNode.driver.setWiper(p.code);
|
|
55
|
+
else if (typeof p.ratio === 'number') await deviceNode.driver.setRatio(p.ratio);
|
|
56
|
+
else if (typeof p.voltage === 'number') await deviceNode.driver.setVoltage(p.voltage);
|
|
41
57
|
if (p.store === true) {
|
|
42
|
-
await
|
|
58
|
+
await deviceNode.driver.storeWiper();
|
|
43
59
|
extra = { stored: true };
|
|
44
60
|
}
|
|
45
61
|
}
|
|
@@ -50,16 +66,6 @@ module.exports = function(RED) {
|
|
|
50
66
|
done(e);
|
|
51
67
|
}
|
|
52
68
|
});
|
|
53
|
-
|
|
54
|
-
node.on('close', async function(removed, done) {
|
|
55
|
-
try {
|
|
56
|
-
if (node.connection) await node.connection.close();
|
|
57
|
-
} catch (e) {
|
|
58
|
-
// bus may already be gone; nothing more to do on close
|
|
59
|
-
} finally {
|
|
60
|
-
done();
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
69
|
}
|
|
64
|
-
RED.nodes.registerType('
|
|
70
|
+
RED.nodes.registerType('ds3502', DS3502ReadNode);
|
|
65
71
|
};
|
package/nodes/es8311/es8311.html
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
|
|
54
54
|
<!-- Control node: volume / mute / mic gain / readback -->
|
|
55
55
|
<script type="text/javascript">
|
|
56
|
-
RED.nodes.registerType('
|
|
56
|
+
RED.nodes.registerType('es8311', {
|
|
57
57
|
category: 'Peripheral',
|
|
58
58
|
color: '#C084FC',
|
|
59
59
|
defaults: {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
});
|
|
69
69
|
</script>
|
|
70
70
|
|
|
71
|
-
<script type="text/html" data-template-name="
|
|
71
|
+
<script type="text/html" data-template-name="es8311">
|
|
72
72
|
<div class="form-row">
|
|
73
73
|
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
74
74
|
<input type="text" id="node-input-device">
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
</div>
|
|
80
80
|
</script>
|
|
81
81
|
|
|
82
|
-
<script type="text/html" data-help-name="
|
|
82
|
+
<script type="text/html" data-help-name="es8311">
|
|
83
83
|
<p>Controls an ES8311 low-power mono audio codec over its I²C control port. The audio stream
|
|
84
84
|
itself (I²S) is not handled by this node.</p>
|
|
85
85
|
|
package/nodes/es8311/es8311.js
CHANGED
package/nodes/hx710a/hx710a.html
CHANGED
|
@@ -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('hx710a-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
gpioChip: { value: '0', required: true, validate: RED.validators.number() },
|
|
@@ -11,49 +11,75 @@
|
|
|
11
11
|
scaleFactor: { value: '1.0' },
|
|
12
12
|
tareOffset: { value: '0' }
|
|
13
13
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
label: function() { return this.name || 'HX710A'; },
|
|
18
|
-
paletteLabel: 'HX710A'
|
|
14
|
+
label: function() {
|
|
15
|
+
return this.name || 'HX710A';
|
|
16
|
+
}
|
|
19
17
|
});
|
|
20
18
|
</script>
|
|
21
19
|
|
|
22
|
-
<script type="text/html" data-template-name="
|
|
20
|
+
<script type="text/html" data-template-name="hx710a-device">
|
|
23
21
|
<div class="form-row">
|
|
24
|
-
<label for="node-input-gpioChip"><i class="fa fa-microchip"></i> GPIO chip</label>
|
|
25
|
-
<input type="number" id="node-input-gpioChip" min="0" style="width:80px"> gpiochip index (e.g. 0 for /dev/gpiochip0)
|
|
22
|
+
<label for="node-config-input-gpioChip"><i class="fa fa-microchip"></i> GPIO chip</label>
|
|
23
|
+
<input type="number" id="node-config-input-gpioChip" min="0" style="width:80px"> gpiochip index (e.g. 0 for /dev/gpiochip0)
|
|
26
24
|
</div>
|
|
27
25
|
<div class="form-row">
|
|
28
|
-
<label for="node-input-doutPin"><i class="fa fa-microchip"></i> DOUT line</label>
|
|
29
|
-
<input type="number" id="node-input-doutPin" min="0" style="width:80px"> gpiod line offset (BCM on Raspberry Pi)
|
|
26
|
+
<label for="node-config-input-doutPin"><i class="fa fa-microchip"></i> DOUT line</label>
|
|
27
|
+
<input type="number" id="node-config-input-doutPin" min="0" style="width:80px"> gpiod line offset (BCM on Raspberry Pi)
|
|
30
28
|
</div>
|
|
31
29
|
<div class="form-row">
|
|
32
|
-
<label for="node-input-pdSckPin"><i class="fa fa-microchip"></i> PD_SCK line</label>
|
|
33
|
-
<input type="number" id="node-input-pdSckPin" min="0" style="width:80px"> gpiod line offset (BCM on Raspberry Pi)
|
|
30
|
+
<label for="node-config-input-pdSckPin"><i class="fa fa-microchip"></i> PD_SCK line</label>
|
|
31
|
+
<input type="number" id="node-config-input-pdSckPin" min="0" style="width:80px"> gpiod line offset (BCM on Raspberry Pi)
|
|
34
32
|
</div>
|
|
35
33
|
<div class="form-row">
|
|
36
|
-
<label for="node-input-rate"><i class="fa fa-tachometer-alt"></i> Rate</label>
|
|
37
|
-
<select id="node-input-rate" style="width:200px">
|
|
34
|
+
<label for="node-config-input-rate"><i class="fa fa-tachometer-alt"></i> Rate</label>
|
|
35
|
+
<select id="node-config-input-rate" style="width:200px">
|
|
38
36
|
<option value="10">10 SPS (default)</option>
|
|
39
37
|
<option value="40">40 SPS</option>
|
|
40
38
|
</select>
|
|
41
39
|
</div>
|
|
42
40
|
<div class="form-row">
|
|
43
|
-
<label for="node-input-scaleFactor"><i class="fa fa-balance-scale"></i> Scale factor</label>
|
|
44
|
-
<input type="text" id="node-input-scaleFactor" style="width:120px"> counts per unit weight
|
|
41
|
+
<label for="node-config-input-scaleFactor"><i class="fa fa-balance-scale"></i> Scale factor</label>
|
|
42
|
+
<input type="text" id="node-config-input-scaleFactor" style="width:120px"> counts per unit weight
|
|
45
43
|
</div>
|
|
46
44
|
<div class="form-row">
|
|
47
|
-
<label for="node-input-tareOffset"><i class="fa fa-crosshairs"></i> Tare offset</label>
|
|
48
|
-
<input type="text" id="node-input-tareOffset" style="width:120px"> or send <code>msg.payload = "tare"</code>
|
|
45
|
+
<label for="node-config-input-tareOffset"><i class="fa fa-crosshairs"></i> Tare offset</label>
|
|
46
|
+
<input type="text" id="node-config-input-tareOffset" style="width:120px"> or send <code>msg.payload = "tare"</code>
|
|
49
47
|
</div>
|
|
48
|
+
<div class="form-row">
|
|
49
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
50
|
+
<input type="text" id="node-config-input-name" placeholder="HX710A">
|
|
51
|
+
</div>
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<!-- Read node -->
|
|
55
|
+
<script type="text/javascript">
|
|
56
|
+
RED.nodes.registerType('hx710a', {
|
|
57
|
+
category: 'Peripheral',
|
|
58
|
+
color: '#C084FC',
|
|
59
|
+
defaults: {
|
|
60
|
+
name: { value: '' },
|
|
61
|
+
device: { value: '', type: 'hx710a-device', required: true }
|
|
62
|
+
},
|
|
63
|
+
inputs: 1,
|
|
64
|
+
outputs: 1,
|
|
65
|
+
icon: 'font-awesome/fa-weight-hanging',
|
|
66
|
+
label: function() { return this.name || 'HX710A'; },
|
|
67
|
+
paletteLabel: 'HX710A'
|
|
68
|
+
});
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<script type="text/html" data-template-name="hx710a">
|
|
50
72
|
<div class="form-row">
|
|
51
73
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
52
74
|
<input type="text" id="node-input-name" placeholder="HX710A">
|
|
53
75
|
</div>
|
|
76
|
+
<div class="form-row">
|
|
77
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
78
|
+
<input type="text" id="node-input-device">
|
|
79
|
+
</div>
|
|
54
80
|
</script>
|
|
55
81
|
|
|
56
|
-
<script type="text/html" data-help-name="
|
|
82
|
+
<script type="text/html" data-help-name="hx710a">
|
|
57
83
|
<p>Reads weight from an HX710A 24-bit ADC connected to a load cell via two GPIO pins.
|
|
58
84
|
Also exposes the chip's on-chip temperature sensor as a raw ADC code.</p>
|
|
59
85
|
|