node-red-contrib-periph-imu 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 +10 -3
- package/examples/bno055/demo.json +11 -5
- package/examples/icm20948/demo.json +13 -6
- package/examples/mpu9250/demo.json +32 -17
- package/examples/mpu9255/demo.json +59 -26
- package/examples/qmi8658a/demo.json +13 -7
- package/nodes/bno055/bno055.html +41 -16
- package/nodes/bno055/bno055.js +17 -10
- package/nodes/icm20948/icm20948.html +49 -19
- package/nodes/icm20948/icm20948.js +17 -10
- package/nodes/mpu9250/mpu9250.html +65 -15
- package/nodes/mpu9250/mpu9250.js +50 -17
- package/nodes/mpu9255/mpu9255.html +71 -20
- package/nodes/mpu9255/mpu9255.js +49 -43
- package/nodes/qmi8658a/qmi8658a.html +52 -28
- package/nodes/qmi8658a/qmi8658a.js +16 -9
- package/package.json +1 -1
- package/index.js +0 -11
package/README.md
CHANGED
|
@@ -16,11 +16,18 @@ npm install node-red-contrib-periph-imu
|
|
|
16
16
|
|
|
17
17
|
| Node | Kind | Description |
|
|
18
18
|
|------|------|-------------|
|
|
19
|
-
| `
|
|
20
|
-
| `
|
|
19
|
+
| `bno055-device` | config | I²C bus and address for a BNO055 |
|
|
20
|
+
| `bno055` | input | Reads the fused absolute orientation of a Bosch BNO055 9-axis sensor over I²C (0x29 with COM3 high, 0x28 with COM3 low). The chip stretches the I²C clock, so the host bus must support clock stretching. Allow up to about one second after deploying for the chip to boot. |
|
|
21
|
+
| `icm20948-device` | config | I²C bus and address for an ICM20948 |
|
|
22
|
+
| `icm20948` | input | Reads acceleration, angular rate, die temperature and (optionally) the magnetic field from a TDK InvenSense ICM-20948 9-axis MotionTracking device over I²C. The AK09916 magnetometer is read through the chip's own I²C master, so only one I²C address is needed. VDDIO must be 1.71–1.95 V. |
|
|
21
23
|
| `mpu6050-device` | config | I²C bus and address for a MPU6050 |
|
|
22
24
|
| `mpu6050` | input | Reads 3-axis acceleration and 3-axis angular rate from an MPU6050 IMU over I²C. |
|
|
23
|
-
| `
|
|
25
|
+
| `mpu9250-device` | config | Bus configuration for a MPU9250 |
|
|
26
|
+
| `mpu9250` | input | Reads bus voltage, load current, and power from an MPU-9250 9-axis MotionTracking device. |
|
|
27
|
+
| `mpu9255-device` | config | Bus configuration for a MPU9255 |
|
|
28
|
+
| `mpu9255` | input | Reads acceleration and angular rate from an MPU-9255 9-axis MotionTracking device. |
|
|
29
|
+
| `qmi8658a-device` | config | I²C bus and address for a QMI8658A |
|
|
30
|
+
| `qmi8658a` | input | Reads acceleration, angular rate and die temperature from a QST QMI8658A 6-axis IMU over I²C (0x6B with SA0 = GND, 0x6A with SA0 = VDDIO) or 4-wire SPI. The three values come from one 14-byte burst, so they belong to the same sample. |
|
|
24
31
|
|
|
25
32
|
## Links
|
|
26
33
|
|
|
@@ -31,20 +31,26 @@
|
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
|
-
"id": "bno055-
|
|
35
|
-
"type": "
|
|
36
|
-
"z": "bno055-tab",
|
|
34
|
+
"id": "bno055-device-1",
|
|
35
|
+
"type": "bno055-device",
|
|
37
36
|
"name": "BNO055",
|
|
38
37
|
"bus": "1",
|
|
39
38
|
"address": "0x29",
|
|
40
|
-
"mode": "12"
|
|
39
|
+
"mode": "12"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "bno055-node",
|
|
43
|
+
"type": "bno055",
|
|
44
|
+
"z": "bno055-tab",
|
|
45
|
+
"name": "BNO055",
|
|
41
46
|
"x": 400,
|
|
42
47
|
"y": 160,
|
|
43
48
|
"wires": [
|
|
44
49
|
[
|
|
45
50
|
"bno055-format"
|
|
46
51
|
]
|
|
47
|
-
]
|
|
52
|
+
],
|
|
53
|
+
"device": "bno055-device-1"
|
|
48
54
|
},
|
|
49
55
|
{
|
|
50
56
|
"id": "bno055-format",
|
|
@@ -30,15 +30,21 @@
|
|
|
30
30
|
]
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
|
+
{
|
|
34
|
+
"id": "icm20948-device-1",
|
|
35
|
+
"type": "icm20948-device",
|
|
36
|
+
"name": "ICM20948",
|
|
37
|
+
"mag": true,
|
|
38
|
+
"gyroRange": "1",
|
|
39
|
+
"bus": "1",
|
|
40
|
+
"address": "0x68",
|
|
41
|
+
"accelRange": "1"
|
|
42
|
+
},
|
|
33
43
|
{
|
|
34
44
|
"id": "icm20948-node",
|
|
35
|
-
"type": "
|
|
45
|
+
"type": "icm20948",
|
|
36
46
|
"z": "icm20948-tab",
|
|
37
47
|
"name": "ICM-20948",
|
|
38
|
-
"bus": "1",
|
|
39
|
-
"address": "0x68",
|
|
40
|
-
"accelRange": "1",
|
|
41
|
-
"gyroRange": "1",
|
|
42
48
|
"mag": true,
|
|
43
49
|
"x": 400,
|
|
44
50
|
"y": 160,
|
|
@@ -46,7 +52,8 @@
|
|
|
46
52
|
[
|
|
47
53
|
"icm20948-compass"
|
|
48
54
|
]
|
|
49
|
-
]
|
|
55
|
+
],
|
|
56
|
+
"device": "icm20948-device-1"
|
|
50
57
|
},
|
|
51
58
|
{
|
|
52
59
|
"id": "icm20948-compass",
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
"type": "inject",
|
|
5
5
|
"z": "mpu9250-demo",
|
|
6
6
|
"name": "100ms timer",
|
|
7
|
-
"props": [
|
|
7
|
+
"props": [
|
|
8
|
+
{
|
|
9
|
+
"p": "payload"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
8
12
|
"repeat": "100",
|
|
9
13
|
"crontab": "",
|
|
10
14
|
"once": false,
|
|
@@ -13,21 +17,35 @@
|
|
|
13
17
|
"payloadType": "date",
|
|
14
18
|
"x": 180,
|
|
15
19
|
"y": 160,
|
|
16
|
-
"wires": [
|
|
20
|
+
"wires": [
|
|
21
|
+
[
|
|
22
|
+
"mpu9250-node"
|
|
23
|
+
]
|
|
24
|
+
]
|
|
17
25
|
},
|
|
18
26
|
{
|
|
19
|
-
"id": "mpu9250-
|
|
20
|
-
"type": "
|
|
21
|
-
"z": "mpu9250-demo",
|
|
27
|
+
"id": "mpu9250-device-1",
|
|
28
|
+
"type": "mpu9250-device",
|
|
22
29
|
"name": "MPU9250",
|
|
23
|
-
"
|
|
30
|
+
"bus": "1",
|
|
24
31
|
"addr": "0x68",
|
|
25
32
|
"gyroFs": "1",
|
|
26
33
|
"accelFs": "1",
|
|
27
|
-
"enableMag": true
|
|
34
|
+
"enableMag": true
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "mpu9250-node",
|
|
38
|
+
"type": "mpu9250",
|
|
39
|
+
"z": "mpu9250-demo",
|
|
40
|
+
"name": "MPU9250",
|
|
28
41
|
"x": 400,
|
|
29
42
|
"y": 160,
|
|
30
|
-
"wires": [
|
|
43
|
+
"wires": [
|
|
44
|
+
[
|
|
45
|
+
"function-tilt"
|
|
46
|
+
]
|
|
47
|
+
],
|
|
48
|
+
"device": "mpu9250-device-1"
|
|
31
49
|
},
|
|
32
50
|
{
|
|
33
51
|
"id": "function-tilt",
|
|
@@ -42,7 +60,11 @@
|
|
|
42
60
|
"libs": [],
|
|
43
61
|
"x": 650,
|
|
44
62
|
"y": 160,
|
|
45
|
-
"wires": [
|
|
63
|
+
"wires": [
|
|
64
|
+
[
|
|
65
|
+
"debug-out"
|
|
66
|
+
]
|
|
67
|
+
]
|
|
46
68
|
},
|
|
47
69
|
{
|
|
48
70
|
"id": "debug-out",
|
|
@@ -60,12 +82,5 @@
|
|
|
60
82
|
"x": 900,
|
|
61
83
|
"y": 160,
|
|
62
84
|
"wires": []
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"id": "i2c-conn-1",
|
|
66
|
-
"type": "periph-i2c-connection",
|
|
67
|
-
"z": "",
|
|
68
|
-
"name": "I2C bus 1",
|
|
69
|
-
"bus": "1"
|
|
70
85
|
}
|
|
71
|
-
]
|
|
86
|
+
]
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
"type": "inject",
|
|
5
5
|
"z": "mpu9255-demo",
|
|
6
6
|
"name": "100ms timer",
|
|
7
|
-
"props": [
|
|
7
|
+
"props": [
|
|
8
|
+
{
|
|
9
|
+
"p": "payload"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
8
12
|
"repeat": "100",
|
|
9
13
|
"crontab": "",
|
|
10
14
|
"once": false,
|
|
@@ -13,30 +17,48 @@
|
|
|
13
17
|
"payloadType": "date",
|
|
14
18
|
"x": 180,
|
|
15
19
|
"y": 160,
|
|
16
|
-
"wires": [
|
|
20
|
+
"wires": [
|
|
21
|
+
[
|
|
22
|
+
"mpu9255-node"
|
|
23
|
+
]
|
|
24
|
+
]
|
|
17
25
|
},
|
|
18
26
|
{
|
|
19
|
-
"id": "mpu9255-
|
|
20
|
-
"type": "
|
|
21
|
-
"z": "mpu9255-demo",
|
|
27
|
+
"id": "mpu9255-device-1",
|
|
28
|
+
"type": "mpu9255-device",
|
|
22
29
|
"name": "MPU9255",
|
|
23
|
-
"
|
|
30
|
+
"bus": "1",
|
|
24
31
|
"addr": "0x68",
|
|
25
32
|
"gyroFs": "1",
|
|
26
33
|
"accelFs": "1",
|
|
27
34
|
"enableMag": true,
|
|
28
35
|
"enableWom": false,
|
|
29
|
-
"womThreshold": "64"
|
|
36
|
+
"womThreshold": "64"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "mpu9255-node",
|
|
40
|
+
"type": "mpu9255",
|
|
41
|
+
"z": "mpu9255-demo",
|
|
42
|
+
"name": "MPU9255",
|
|
30
43
|
"x": 400,
|
|
31
44
|
"y": 160,
|
|
32
|
-
"wires": [
|
|
45
|
+
"wires": [
|
|
46
|
+
[
|
|
47
|
+
"function-tilt"
|
|
48
|
+
]
|
|
49
|
+
],
|
|
50
|
+
"device": "mpu9255-device-1"
|
|
33
51
|
},
|
|
34
52
|
{
|
|
35
53
|
"id": "inject-1s",
|
|
36
54
|
"type": "inject",
|
|
37
55
|
"z": "mpu9255-demo",
|
|
38
56
|
"name": "1s timer (WoM)",
|
|
39
|
-
"props": [
|
|
57
|
+
"props": [
|
|
58
|
+
{
|
|
59
|
+
"p": "payload"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
40
62
|
"repeat": "1",
|
|
41
63
|
"crontab": "",
|
|
42
64
|
"once": false,
|
|
@@ -45,23 +67,37 @@
|
|
|
45
67
|
"payloadType": "date",
|
|
46
68
|
"x": 180,
|
|
47
69
|
"y": 240,
|
|
48
|
-
"wires": [
|
|
70
|
+
"wires": [
|
|
71
|
+
[
|
|
72
|
+
"mpu9255-node-wom"
|
|
73
|
+
]
|
|
74
|
+
]
|
|
49
75
|
},
|
|
50
76
|
{
|
|
51
|
-
"id": "mpu9255-
|
|
52
|
-
"type": "
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"connection": "i2c-conn-1",
|
|
77
|
+
"id": "mpu9255-device-2",
|
|
78
|
+
"type": "mpu9255-device",
|
|
79
|
+
"name": "MPU9255",
|
|
80
|
+
"bus": "1",
|
|
56
81
|
"addr": "0x68",
|
|
57
82
|
"gyroFs": "0",
|
|
58
83
|
"accelFs": "0",
|
|
59
84
|
"enableMag": false,
|
|
60
85
|
"enableWom": true,
|
|
61
|
-
"womThreshold": "64"
|
|
86
|
+
"womThreshold": "64"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": "mpu9255-node-wom",
|
|
90
|
+
"type": "mpu9255",
|
|
91
|
+
"z": "mpu9255-demo",
|
|
92
|
+
"name": "MPU9255 (WoM)",
|
|
62
93
|
"x": 400,
|
|
63
94
|
"y": 240,
|
|
64
|
-
"wires": [
|
|
95
|
+
"wires": [
|
|
96
|
+
[
|
|
97
|
+
"debug-wom"
|
|
98
|
+
]
|
|
99
|
+
],
|
|
100
|
+
"device": "mpu9255-device-2"
|
|
65
101
|
},
|
|
66
102
|
{
|
|
67
103
|
"id": "function-tilt",
|
|
@@ -76,7 +112,11 @@
|
|
|
76
112
|
"libs": [],
|
|
77
113
|
"x": 650,
|
|
78
114
|
"y": 160,
|
|
79
|
-
"wires": [
|
|
115
|
+
"wires": [
|
|
116
|
+
[
|
|
117
|
+
"debug-out"
|
|
118
|
+
]
|
|
119
|
+
]
|
|
80
120
|
},
|
|
81
121
|
{
|
|
82
122
|
"id": "debug-out",
|
|
@@ -111,12 +151,5 @@
|
|
|
111
151
|
"x": 650,
|
|
112
152
|
"y": 240,
|
|
113
153
|
"wires": []
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"id": "i2c-conn-1",
|
|
117
|
-
"type": "periph-i2c-connection",
|
|
118
|
-
"z": "",
|
|
119
|
-
"name": "I2C bus 1",
|
|
120
|
-
"bus": "1"
|
|
121
154
|
}
|
|
122
|
-
]
|
|
155
|
+
]
|
|
@@ -31,17 +31,23 @@
|
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
|
-
"id": "qmi8658a-
|
|
35
|
-
"type": "
|
|
36
|
-
"z": "qmi8658a-tab",
|
|
34
|
+
"id": "qmi8658a-device-1",
|
|
35
|
+
"type": "qmi8658a-device",
|
|
37
36
|
"name": "QMI8658A",
|
|
38
|
-
"transport": "i2c",
|
|
39
37
|
"bus": "1",
|
|
40
|
-
"
|
|
41
|
-
"address": "0x6B",
|
|
38
|
+
"odr": "5",
|
|
42
39
|
"accelRange": "1",
|
|
40
|
+
"address": "0x6B",
|
|
43
41
|
"gyroRange": "4",
|
|
44
|
-
"
|
|
42
|
+
"transport": "i2c",
|
|
43
|
+
"device": "0"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"id": "qmi8658a-node",
|
|
47
|
+
"type": "qmi8658a",
|
|
48
|
+
"z": "qmi8658a-tab",
|
|
49
|
+
"name": "QMI8658A",
|
|
50
|
+
"device": "qmi8658a-device-1",
|
|
45
51
|
"x": 400,
|
|
46
52
|
"y": 160,
|
|
47
53
|
"wires": [
|
package/nodes/bno055/bno055.html
CHANGED
|
@@ -1,41 +1,38 @@
|
|
|
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('bno055-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: '0x29' },
|
|
9
9
|
mode: { value: '12', required: true, validate: RED.validators.number() }
|
|
10
10
|
},
|
|
11
|
-
inputs: 1,
|
|
12
|
-
outputs: 1,
|
|
13
|
-
icon: 'bridge.svg',
|
|
14
11
|
label: function() {
|
|
15
12
|
return this.name || ('BNO055 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
16
13
|
}
|
|
17
14
|
});
|
|
18
15
|
</script>
|
|
19
16
|
|
|
20
|
-
<script type="text/html" data-template-name="
|
|
17
|
+
<script type="text/html" data-template-name="bno055-device">
|
|
21
18
|
<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="BNO055">
|
|
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="BNO055">
|
|
24
21
|
</div>
|
|
25
22
|
<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)
|
|
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)
|
|
28
25
|
</div>
|
|
29
26
|
<div class="form-row">
|
|
30
|
-
<label for="node-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
31
|
-
<select id="node-input-address" style="width:160px">
|
|
27
|
+
<label for="node-config-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
28
|
+
<select id="node-config-input-address" style="width:160px">
|
|
32
29
|
<option value="0x29" selected>0x29 (COM3 = high)</option>
|
|
33
30
|
<option value="0x28">0x28 (COM3 = low)</option>
|
|
34
31
|
</select>
|
|
35
32
|
</div>
|
|
36
33
|
<div class="form-row">
|
|
37
|
-
<label for="node-input-mode"><i class="fa fa-cog"></i> Operation mode</label>
|
|
38
|
-
<select id="node-input-mode" style="width:260px">
|
|
34
|
+
<label for="node-config-input-mode"><i class="fa fa-cog"></i> Operation mode</label>
|
|
35
|
+
<select id="node-config-input-mode" style="width:260px">
|
|
39
36
|
<option value="12" selected>NDOF (9-DOF absolute orientation)</option>
|
|
40
37
|
<option value="11">NDOF, fast magnetometer calibration off</option>
|
|
41
38
|
<option value="8">IMU (relative orientation)</option>
|
|
@@ -45,7 +42,35 @@
|
|
|
45
42
|
</div>
|
|
46
43
|
</script>
|
|
47
44
|
|
|
48
|
-
|
|
45
|
+
<!-- Read node -->
|
|
46
|
+
<script type="text/javascript">
|
|
47
|
+
RED.nodes.registerType('bno055', {
|
|
48
|
+
category: 'Peripheral',
|
|
49
|
+
color: '#C084FC',
|
|
50
|
+
defaults: {
|
|
51
|
+
name: { value: '' },
|
|
52
|
+
device: { value: '', type: 'bno055-device', required: true }
|
|
53
|
+
},
|
|
54
|
+
inputs: 1,
|
|
55
|
+
outputs: 1,
|
|
56
|
+
icon: 'bridge.svg',
|
|
57
|
+
label: function() { return this.name || 'BNO055'; },
|
|
58
|
+
paletteLabel: 'BNO055'
|
|
59
|
+
});
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<script type="text/html" data-template-name="bno055">
|
|
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="BNO055">
|
|
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="bno055">
|
|
49
74
|
<p>Reads the fused absolute orientation of a Bosch BNO055 9-axis sensor over I²C (0x29 with COM3 high,
|
|
50
75
|
0x28 with COM3 low). The chip stretches the I²C clock, so the host bus must support clock stretching.
|
|
51
76
|
Allow up to about one second after deploying for the chip to boot.</p>
|
package/nodes/bno055/bno055.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { BNO055Full } = require('periph/src/chips/imu/bno055');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function BNO055DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
10
|
try {
|
|
@@ -25,16 +25,27 @@ module.exports = function(RED) {
|
|
|
25
25
|
node.error('BNO055 init failed: ' + e.message);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
node.on('close', function() {
|
|
29
|
+
if (node.connection) node.connection.close();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
RED.nodes.registerType('bno055-device', BNO055DeviceNode);
|
|
33
|
+
|
|
34
|
+
function BNO055ReadNode(config) {
|
|
35
|
+
RED.nodes.createNode(this, config);
|
|
36
|
+
const node = this;
|
|
37
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
38
|
+
|
|
28
39
|
node.on('input', async function(msg, send, done) {
|
|
29
|
-
if (!
|
|
40
|
+
if (!deviceNode.driver) {
|
|
30
41
|
node.error('BNO055 not initialised', msg);
|
|
31
42
|
done();
|
|
32
43
|
return;
|
|
33
44
|
}
|
|
34
45
|
try {
|
|
35
|
-
await
|
|
36
|
-
const [heading, roll, pitch] = await
|
|
37
|
-
const [sys, gyr, acc, mag] = await
|
|
46
|
+
await deviceNode.ready;
|
|
47
|
+
const [heading, roll, pitch] = await deviceNode.driver.euler();
|
|
48
|
+
const [sys, gyr, acc, mag] = await deviceNode.driver.calibrationStatus();
|
|
38
49
|
msg.payload = { heading, roll, pitch, calibration: { sys, gyr, acc, mag } };
|
|
39
50
|
send(msg);
|
|
40
51
|
done();
|
|
@@ -42,10 +53,6 @@ module.exports = function(RED) {
|
|
|
42
53
|
done(e);
|
|
43
54
|
}
|
|
44
55
|
});
|
|
45
|
-
|
|
46
|
-
node.on('close', function() {
|
|
47
|
-
if (node.connection) node.connection.close();
|
|
48
|
-
});
|
|
49
56
|
}
|
|
50
|
-
RED.nodes.registerType('
|
|
57
|
+
RED.nodes.registerType('bno055', BNO055ReadNode);
|
|
51
58
|
};
|
|
@@ -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('icm20948-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
@@ -10,34 +10,31 @@
|
|
|
10
10
|
gyroRange: { value: '0', required: true, validate: RED.validators.number() },
|
|
11
11
|
mag: { value: true }
|
|
12
12
|
},
|
|
13
|
-
inputs: 1,
|
|
14
|
-
outputs: 1,
|
|
15
|
-
icon: 'bridge.svg',
|
|
16
13
|
label: function() {
|
|
17
|
-
return this.name || ('
|
|
14
|
+
return this.name || ('ICM20948 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
18
15
|
}
|
|
19
16
|
});
|
|
20
17
|
</script>
|
|
21
18
|
|
|
22
|
-
<script type="text/html" data-template-name="
|
|
19
|
+
<script type="text/html" data-template-name="icm20948-device">
|
|
23
20
|
<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="
|
|
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="ICM20948">
|
|
26
23
|
</div>
|
|
27
24
|
<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"> (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)
|
|
30
27
|
</div>
|
|
31
28
|
<div class="form-row">
|
|
32
|
-
<label for="node-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
33
|
-
<select id="node-input-address" style="width:160px">
|
|
29
|
+
<label for="node-config-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
30
|
+
<select id="node-config-input-address" style="width:160px">
|
|
34
31
|
<option value="0x68" selected>0x68 (AD0 = GND)</option>
|
|
35
32
|
<option value="0x69">0x69 (AD0 = VDDIO)</option>
|
|
36
33
|
</select>
|
|
37
34
|
</div>
|
|
38
35
|
<div class="form-row">
|
|
39
|
-
<label for="node-input-accelRange"><i class="fa fa-cog"></i> Accelerometer range</label>
|
|
40
|
-
<select id="node-input-accelRange" style="width:120px">
|
|
36
|
+
<label for="node-config-input-accelRange"><i class="fa fa-cog"></i> Accelerometer range</label>
|
|
37
|
+
<select id="node-config-input-accelRange" style="width:120px">
|
|
41
38
|
<option value="0" selected>±2 g</option>
|
|
42
39
|
<option value="1">±4 g</option>
|
|
43
40
|
<option value="2">±8 g</option>
|
|
@@ -45,21 +42,54 @@
|
|
|
45
42
|
</select>
|
|
46
43
|
</div>
|
|
47
44
|
<div class="form-row">
|
|
48
|
-
<label for="node-input-gyroRange"><i class="fa fa-cog"></i> Gyroscope range</label>
|
|
49
|
-
<select id="node-input-gyroRange" style="width:120px">
|
|
45
|
+
<label for="node-config-input-gyroRange"><i class="fa fa-cog"></i> Gyroscope range</label>
|
|
46
|
+
<select id="node-config-input-gyroRange" style="width:120px">
|
|
50
47
|
<option value="0" selected>±250 dps</option>
|
|
51
48
|
<option value="1">±500 dps</option>
|
|
52
49
|
<option value="2">±1000 dps</option>
|
|
53
50
|
<option value="3">±2000 dps</option>
|
|
54
51
|
</select>
|
|
55
52
|
</div>
|
|
53
|
+
<div class="form-row">
|
|
54
|
+
<label for="node-config-input-mag"><i class="fa fa-magnet"></i> Magnetometer</label>
|
|
55
|
+
<input type="checkbox" id="node-config-input-mag" style="width:auto">
|
|
56
|
+
</div>
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<!-- Read node -->
|
|
60
|
+
<script type="text/javascript">
|
|
61
|
+
RED.nodes.registerType('icm20948', {
|
|
62
|
+
category: 'Peripheral',
|
|
63
|
+
color: '#C084FC',
|
|
64
|
+
defaults: {
|
|
65
|
+
name: { value: '' },
|
|
66
|
+
device: { value: '', type: 'icm20948-device', required: true },
|
|
67
|
+
mag: { value: true }
|
|
68
|
+
},
|
|
69
|
+
inputs: 1,
|
|
70
|
+
outputs: 1,
|
|
71
|
+
icon: 'bridge.svg',
|
|
72
|
+
label: function() { return this.name || 'ICM20948'; },
|
|
73
|
+
paletteLabel: 'ICM20948'
|
|
74
|
+
});
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<script type="text/html" data-template-name="icm20948">
|
|
78
|
+
<div class="form-row">
|
|
79
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
80
|
+
<input type="text" id="node-input-name" placeholder="ICM20948">
|
|
81
|
+
</div>
|
|
82
|
+
<div class="form-row">
|
|
83
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
84
|
+
<input type="text" id="node-input-device">
|
|
85
|
+
</div>
|
|
56
86
|
<div class="form-row">
|
|
57
87
|
<label for="node-input-mag"><i class="fa fa-magnet"></i> Magnetometer</label>
|
|
58
88
|
<input type="checkbox" id="node-input-mag" style="width:auto">
|
|
59
89
|
</div>
|
|
60
90
|
</script>
|
|
61
91
|
|
|
62
|
-
<script type="text/html" data-help-name="
|
|
92
|
+
<script type="text/html" data-help-name="icm20948">
|
|
63
93
|
<p>Reads acceleration, angular rate, die temperature and (optionally) the magnetic field from a TDK InvenSense
|
|
64
94
|
ICM-20948 9-axis MotionTracking device over I²C. The AK09916 magnetometer is read through the chip's own
|
|
65
95
|
I²C master, so only one I²C address is needed. VDDIO must be 1.71–1.95 V.</p>
|
|
@@ -4,7 +4,7 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { ICM20948Full } = require('periph/src/chips/imu/icm20948');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function ICM20948DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
10
|
try {
|
|
@@ -26,22 +26,33 @@ module.exports = function(RED) {
|
|
|
26
26
|
node.error('ICM20948 init failed: ' + e.message);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
node.on('close', function() {
|
|
30
|
+
if (node.connection) node.connection.close();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
RED.nodes.registerType('icm20948-device', ICM20948DeviceNode);
|
|
34
|
+
|
|
35
|
+
function ICM20948ReadNode(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.driver) {
|
|
31
42
|
node.error('ICM20948 not initialised', msg);
|
|
32
43
|
done();
|
|
33
44
|
return;
|
|
34
45
|
}
|
|
35
46
|
try {
|
|
36
|
-
await
|
|
37
|
-
const [accel, gyro, temperature] = await
|
|
47
|
+
await deviceNode.ready;
|
|
48
|
+
const [accel, gyro, temperature] = await deviceNode.driver.readAll();
|
|
38
49
|
const payload = {
|
|
39
50
|
accel: { x: accel[0], y: accel[1], z: accel[2] },
|
|
40
51
|
gyro: { x: gyro[0], y: gyro[1], z: gyro[2] },
|
|
41
52
|
temperature,
|
|
42
53
|
};
|
|
43
54
|
if (config.mag) {
|
|
44
|
-
const [x, y, z] = await
|
|
55
|
+
const [x, y, z] = await deviceNode.driver.mag();
|
|
45
56
|
payload.mag = { x, y, z };
|
|
46
57
|
}
|
|
47
58
|
msg.payload = payload;
|
|
@@ -51,10 +62,6 @@ module.exports = function(RED) {
|
|
|
51
62
|
done(e);
|
|
52
63
|
}
|
|
53
64
|
});
|
|
54
|
-
|
|
55
|
-
node.on('close', function() {
|
|
56
|
-
if (node.connection) node.connection.close();
|
|
57
|
-
});
|
|
58
65
|
}
|
|
59
|
-
RED.nodes.registerType('
|
|
66
|
+
RED.nodes.registerType('icm20948', ICM20948ReadNode);
|
|
60
67
|
};
|