node-red-contrib-periph-motor 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.
@@ -6,10 +6,9 @@ module.exports = function(RED) {
6
6
 
7
7
  const LIBRARIES = { A: 1, B: 2, C: 3, D: 4, E: 5, LRA: 6 };
8
8
 
9
- function DRV2605Node(config) {
9
+ function DRV2605DeviceNode(config) {
10
10
  RED.nodes.createNode(this, config);
11
11
  const node = this;
12
-
13
12
  try {
14
13
  const lra = config.actuator === 'lra';
15
14
  const connection = new I2CConnection(parseInt(config.bus, 10), DRV2605Full.I2C_ADDRESS);
@@ -22,31 +21,49 @@ module.exports = function(RED) {
22
21
  node.error('DRV2605 init failed: ' + e.message);
23
22
  }
24
23
 
24
+ node.on('close', async function(removed, done) {
25
+ try {
26
+ if (node.driver) await node.driver.stop();
27
+ if (node.connection) await node.connection.close();
28
+ } catch (e) {
29
+ // bus may already be gone; nothing more to do on close
30
+ } finally {
31
+ done();
32
+ }
33
+ });
34
+ }
35
+ RED.nodes.registerType('drv2605-device', DRV2605DeviceNode);
36
+
37
+ function DRV2605ReadNode(config) {
38
+ RED.nodes.createNode(this, config);
39
+ const node = this;
40
+ const deviceNode = RED.nodes.getNode(config.device) || {};
41
+
25
42
  node.on('input', async function(msg, send, done) {
26
- await node.ready;
27
- if (!node.driver) { done(); return; }
43
+ await deviceNode.ready;
44
+ if (!deviceNode.driver) { done(); return; }
28
45
  try {
29
46
  const p = msg.payload;
30
47
  if (typeof p === 'number') {
31
- await node.driver.playEffect(p);
48
+ await deviceNode.driver.playEffect(p);
32
49
  msg.payload = { ok: true };
33
50
  } else if (p && typeof p === 'object') {
34
51
  if (typeof p.effect === 'number') {
35
- await node.driver.playEffect(p.effect);
52
+ await deviceNode.driver.playEffect(p.effect);
36
53
  msg.payload = { ok: true };
37
54
  } else if (Array.isArray(p.sequence)) {
38
- await node.driver.playSequence(p.sequence);
55
+ await deviceNode.driver.playSequence(p.sequence);
39
56
  msg.payload = { ok: true };
40
57
  } else if (typeof p.rtp === 'number') {
41
- await node.driver.rtpLevel(p.rtp);
58
+ await deviceNode.driver.rtpLevel(p.rtp);
42
59
  msg.payload = { ok: true };
43
60
  } else if (p.stop === true) {
44
- await node.driver.stop();
61
+ await deviceNode.driver.stop();
45
62
  msg.payload = { ok: true };
46
63
  } else if (p.status === true) {
47
- const device_id = await node.driver.readDeviceId();
48
- const st = await node.driver.readStatus();
49
- const supply_voltage = await node.driver.readSupplyVoltage();
64
+ const device_id = await deviceNode.driver.readDeviceId();
65
+ const st = await deviceNode.driver.readStatus();
66
+ const supply_voltage = await deviceNode.driver.readSupplyVoltage();
50
67
  msg.payload = { device_id, over_temp: st.overTemp, over_current: st.overCurrent, supply_voltage };
51
68
  } else {
52
69
  done(); return;
@@ -63,17 +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.driver) await node.driver.stop();
70
- if (node.connection) await node.connection.close();
71
- } catch (e) {
72
- // bus may already be gone; nothing more to do on close
73
- } finally {
74
- done();
75
- }
76
- });
77
83
  }
78
- RED.nodes.registerType('periph-drv2605', DRV2605Node);
84
+ RED.nodes.registerType('drv2605', DRV2605ReadNode);
79
85
  };
@@ -1,32 +1,30 @@
1
+ <!-- Config node: one instance per physical device -->
1
2
  <script type="text/javascript">
2
- RED.nodes.registerType('periph-drv8830', {
3
- category: 'Peripheral',
4
- color: '#C084FC',
3
+ RED.nodes.registerType('drv8830-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: '0x60', required: true }
9
9
  },
10
- inputs: 1,
11
- outputs: 1,
12
- icon: 'font-awesome/fa-cog',
13
- label: function() { return this.name || 'DRV8830'; },
14
- paletteLabel: 'DRV8830'
10
+ label: function() {
11
+ return this.name || ('DRV8830 @ ' + this.address + ' (bus ' + this.bus + ')');
12
+ }
15
13
  });
16
14
  </script>
17
15
 
18
- <script type="text/html" data-template-name="periph-drv8830">
16
+ <script type="text/html" data-template-name="drv8830-device">
19
17
  <div class="form-row">
20
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
21
- <input type="text" id="node-input-name" placeholder="DRV8830">
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="DRV8830">
22
20
  </div>
23
21
  <div class="form-row">
24
- <label for="node-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
25
- <input type="number" id="node-input-bus" min="0" style="width:80px"> &nbsp;(Linux /dev/i2c-N)
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"> &nbsp;(Linux /dev/i2c-N)
26
24
  </div>
27
25
  <div class="form-row">
28
- <label for="node-input-address"><i class="fa fa-at"></i> I²C address</label>
29
- <select id="node-input-address" style="width:120px">
26
+ <label for="node-config-input-address"><i class="fa fa-at"></i> I²C address</label>
27
+ <select id="node-config-input-address" style="width:120px">
30
28
  <option value="0x60">0x60</option>
31
29
  <option value="0x61">0x61</option>
32
30
  <option value="0x62">0x62</option>
@@ -41,7 +39,35 @@
41
39
  </div>
42
40
  </script>
43
41
 
44
- <script type="text/html" data-help-name="periph-drv8830">
42
+ <!-- Read node -->
43
+ <script type="text/javascript">
44
+ RED.nodes.registerType('drv8830', {
45
+ category: 'Peripheral',
46
+ color: '#C084FC',
47
+ defaults: {
48
+ name: { value: '' },
49
+ device: { value: '', type: 'drv8830-device', required: true }
50
+ },
51
+ inputs: 1,
52
+ outputs: 1,
53
+ icon: 'font-awesome/fa-cog',
54
+ label: function() { return this.name || 'DRV8830'; },
55
+ paletteLabel: 'DRV8830'
56
+ });
57
+ </script>
58
+
59
+ <script type="text/html" data-template-name="drv8830">
60
+ <div class="form-row">
61
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
62
+ <input type="text" id="node-input-name" placeholder="DRV8830">
63
+ </div>
64
+ <div class="form-row">
65
+ <label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
66
+ <input type="text" id="node-input-device">
67
+ </div>
68
+ </script>
69
+
70
+ <script type="text/html" data-help-name="drv8830">
45
71
  <p>Drives a brushed DC motor through a DRV8830 low-voltage H-bridge over I²C, and reports its fault status. The chip regulates the commanded <em>voltage</em> across the motor, so speed stays constant as the supply sags.</p>
46
72
 
47
73
  <h3>Inputs</h3>
@@ -4,10 +4,9 @@ module.exports = function(RED) {
4
4
  const { I2CConnection } = require('periph/src/connection/i2c');
5
5
  const { DRV8830Full } = require('periph/src/chips/motor/drv8830');
6
6
 
7
- function DRV8830Node(config) {
7
+ function DRV8830DeviceNode(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) || DRV8830Full.I2C_ADDRESS;
13
12
  const connection = new I2CConnection(parseInt(config.bus, 10), address);
@@ -18,34 +17,41 @@ module.exports = function(RED) {
18
17
  node.error('DRV8830 init failed: ' + e.message);
19
18
  }
20
19
 
20
+ node.on('close', async function(removed, done) {
21
+ try {
22
+ if (node.driver) await node.driver.stop();
23
+ if (node.connection) await node.connection.close();
24
+ } catch (e) {
25
+ // bus may already be gone; nothing more to do on close
26
+ } finally {
27
+ done();
28
+ }
29
+ });
30
+ }
31
+ RED.nodes.registerType('drv8830-device', DRV8830DeviceNode);
32
+
33
+ function DRV8830ReadNode(config) {
34
+ RED.nodes.createNode(this, config);
35
+ const node = this;
36
+ const deviceNode = RED.nodes.getNode(config.device) || {};
37
+
21
38
  node.on('input', async function(msg, send, done) {
22
- if (!node.driver) { done(); return; }
39
+ if (!deviceNode.driver) { done(); return; }
23
40
  try {
24
41
  const p = msg.payload;
25
42
  if (p && typeof p === 'object') {
26
- if (p.clear_fault === true) { await node.driver.clearFault(); done(); return; }
27
- if (p.brake === true) { await node.driver.brake(); done(); return; }
28
- if (p.stop === true) { await node.driver.stop(); done(); return; }
29
- if (typeof p.voltage === 'number') { await node.driver.drive(p.voltage); done(); return; }
43
+ if (p.clear_fault === true) { await deviceNode.driver.clearFault(); done(); return; }
44
+ if (p.brake === true) { await deviceNode.driver.brake(); done(); return; }
45
+ if (p.stop === true) { await deviceNode.driver.stop(); done(); return; }
46
+ if (typeof p.voltage === 'number') { await deviceNode.driver.drive(p.voltage); done(); return; }
30
47
  }
31
- msg.payload = await node.driver.readFault();
48
+ msg.payload = await deviceNode.driver.readFault();
32
49
  send(msg);
33
50
  done();
34
51
  } catch (e) {
35
52
  done(e);
36
53
  }
37
54
  });
38
-
39
- node.on('close', async function(removed, done) {
40
- try {
41
- if (node.driver) await node.driver.stop();
42
- if (node.connection) await node.connection.close();
43
- } catch (e) {
44
- // bus may already be gone; nothing more to do on close
45
- } finally {
46
- done();
47
- }
48
- });
49
55
  }
50
- RED.nodes.registerType('periph-drv8830', DRV8830Node);
56
+ RED.nodes.registerType('drv8830', DRV8830ReadNode);
51
57
  };
@@ -1,7 +1,7 @@
1
+ <!-- Config node: one instance per physical device -->
1
2
  <script type="text/javascript">
2
- RED.nodes.registerType('periph-tmc2130', {
3
- category: 'Peripheral',
4
- color: '#C084FC',
3
+ RED.nodes.registerType('tmc2130-device', {
4
+ category: 'config',
5
5
  defaults: {
6
6
  name: { value: '' },
7
7
  bus: { value: '0', required: true, validate: RED.validators.number() },
@@ -15,66 +15,92 @@
15
15
  microsteps: { value: '16' },
16
16
  speed: { value: '200', validate: RED.validators.number() }
17
17
  },
18
- inputs: 1,
19
- outputs: 1,
20
- icon: 'font-awesome/fa-cog',
21
- label: function() { return this.name || 'TMC2130'; },
22
- paletteLabel: 'TMC2130'
18
+ label: function() {
19
+ return this.name || 'TMC2130';
20
+ }
23
21
  });
24
22
  </script>
25
23
 
26
- <script type="text/html" data-template-name="periph-tmc2130">
24
+ <script type="text/html" data-template-name="tmc2130-device">
27
25
  <div class="form-row">
28
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
29
- <input type="text" id="node-input-name" placeholder="TMC2130">
26
+ <label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
27
+ <input type="text" id="node-config-input-name" placeholder="TMC2130">
30
28
  </div>
31
29
  <div class="form-row">
32
- <label for="node-input-bus"><i class="fa fa-plug"></i> SPI bus</label>
33
- <input type="number" id="node-input-bus" min="0" style="width:100px">
30
+ <label for="node-config-input-bus"><i class="fa fa-plug"></i> SPI bus</label>
31
+ <input type="number" id="node-config-input-bus" min="0" style="width:100px">
34
32
  </div>
35
33
  <div class="form-row">
36
- <label for="node-input-device"><i class="fa fa-plug"></i> SPI device (CS)</label>
37
- <input type="number" id="node-input-device" min="0" style="width:100px">
34
+ <label for="node-config-input-device"><i class="fa fa-plug"></i> SPI device (CS)</label>
35
+ <input type="number" id="node-config-input-device" min="0" style="width:100px">
38
36
  </div>
39
37
  <div class="form-row">
40
- <label for="node-input-speedHz"><i class="fa fa-tachometer"></i> SPI clock (Hz)</label>
41
- <input type="number" id="node-input-speedHz" min="100000" max="4000000" style="width:120px">
38
+ <label for="node-config-input-speedHz"><i class="fa fa-tachometer"></i> SPI clock (Hz)</label>
39
+ <input type="number" id="node-config-input-speedHz" min="100000" max="4000000" style="width:120px">
42
40
  </div>
43
41
  <div class="form-row">
44
- <label for="node-input-stepGpio"><i class="fa fa-microchip"></i> STEP GPIO</label>
45
- <input type="text" id="node-input-stepGpio" placeholder="e.g. 0:27" style="width:140px">
42
+ <label for="node-config-input-stepGpio"><i class="fa fa-microchip"></i> STEP GPIO</label>
43
+ <input type="text" id="node-config-input-stepGpio" placeholder="e.g. 0:27" style="width:140px">
46
44
  </div>
47
45
  <div class="form-row">
48
- <label for="node-input-dirGpio"><i class="fa fa-microchip"></i> DIR GPIO</label>
49
- <input type="text" id="node-input-dirGpio" placeholder="e.g. 0:22" style="width:140px">
46
+ <label for="node-config-input-dirGpio"><i class="fa fa-microchip"></i> DIR GPIO</label>
47
+ <input type="text" id="node-config-input-dirGpio" placeholder="e.g. 0:22" style="width:140px">
50
48
  </div>
51
49
  <div class="form-row">
52
- <label for="node-input-enGpio"><i class="fa fa-microchip"></i> ENN GPIO (optional)</label>
53
- <input type="text" id="node-input-enGpio" placeholder="not wired, e.g. 0:17" style="width:140px">
50
+ <label for="node-config-input-enGpio"><i class="fa fa-microchip"></i> ENN GPIO (optional)</label>
51
+ <input type="text" id="node-config-input-enGpio" placeholder="not wired, e.g. 0:17" style="width:140px">
54
52
  </div>
55
53
  <div class="form-row">
56
- <label for="node-input-rsense"><i class="fa fa-bolt"></i> Sense resistor (Ω)</label>
57
- <input type="number" id="node-input-rsense" min="0.01" step="0.01" style="width:100px">
54
+ <label for="node-config-input-rsense"><i class="fa fa-bolt"></i> Sense resistor (Ω)</label>
55
+ <input type="number" id="node-config-input-rsense" min="0.01" step="0.01" style="width:100px">
58
56
  </div>
59
57
  <div class="form-row">
60
- <label for="node-input-current"><i class="fa fa-bolt"></i> Default current (A RMS)</label>
61
- <input type="number" id="node-input-current" min="0" max="1.4" step="0.05" style="width:100px">
58
+ <label for="node-config-input-current"><i class="fa fa-bolt"></i> Default current (A RMS)</label>
59
+ <input type="number" id="node-config-input-current" min="0" max="1.4" step="0.05" style="width:100px">
62
60
  </div>
63
61
  <div class="form-row">
64
- <label for="node-input-microsteps"><i class="fa fa-th"></i> Default microsteps</label>
65
- <select id="node-input-microsteps" style="width:100px">
62
+ <label for="node-config-input-microsteps"><i class="fa fa-th"></i> Default microsteps</label>
63
+ <select id="node-config-input-microsteps" style="width:100px">
66
64
  <option value="1">1</option><option value="2">2</option><option value="4">4</option>
67
65
  <option value="8">8</option><option value="16">16</option><option value="32">32</option>
68
66
  <option value="64">64</option><option value="128">128</option><option value="256">256</option>
69
67
  </select>
70
68
  </div>
71
69
  <div class="form-row">
72
- <label for="node-input-speed"><i class="fa fa-forward"></i> Default speed (full steps/s)</label>
73
- <input type="number" id="node-input-speed" min="1" style="width:100px">
70
+ <label for="node-config-input-speed"><i class="fa fa-forward"></i> Default speed (full steps/s)</label>
71
+ <input type="number" id="node-config-input-speed" min="1" style="width:100px">
72
+ </div>
73
+ </script>
74
+
75
+ <!-- Read node -->
76
+ <script type="text/javascript">
77
+ RED.nodes.registerType('tmc2130', {
78
+ category: 'Peripheral',
79
+ color: '#C084FC',
80
+ defaults: {
81
+ name: { value: '' },
82
+ device: { value: '', type: 'tmc2130-device', required: true }
83
+ },
84
+ inputs: 1,
85
+ outputs: 1,
86
+ icon: 'font-awesome/fa-cog',
87
+ label: function() { return this.name || 'TMC2130'; },
88
+ paletteLabel: 'TMC2130'
89
+ });
90
+ </script>
91
+
92
+ <script type="text/html" data-template-name="tmc2130">
93
+ <div class="form-row">
94
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
95
+ <input type="text" id="node-input-name" placeholder="TMC2130">
96
+ </div>
97
+ <div class="form-row">
98
+ <label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
99
+ <input type="text" id="node-input-device">
74
100
  </div>
75
101
  </script>
76
102
 
77
- <script type="text/html" data-help-name="periph-tmc2130">
103
+ <script type="text/html" data-help-name="tmc2130">
78
104
  <p>Drives a two-phase bipolar stepper motor through a Trinamic TMC2130 over SPI (Mode 3). The chip has no internal step generator, so the node pulses the STEP and DIR GPIOs; moves are blocking.</p>
79
105
 
80
106
  <h3>Inputs</h3>
@@ -12,7 +12,7 @@ module.exports = function(RED) {
12
12
  return new GpioOutputPin(Default.output({ chip, line }));
13
13
  }
14
14
 
15
- function TMC2130Node(config) {
15
+ function TMC2130DeviceNode(config) {
16
16
  RED.nodes.createNode(this, config);
17
17
  const node = this;
18
18
  node.ready = false;
@@ -50,35 +50,53 @@ module.exports = function(RED) {
50
50
  };
51
51
  }
52
52
 
53
+ node.on('close', async function(removed, done) {
54
+ try {
55
+ if (node.driver && node.ready) await node.driver.disable();
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
+ }
64
+ RED.nodes.registerType('tmc2130-device', TMC2130DeviceNode);
65
+
66
+ function TMC2130ReadNode(config) {
67
+ RED.nodes.createNode(this, config);
68
+ const node = this;
69
+ const deviceNode = RED.nodes.getNode(config.device) || {};
70
+
53
71
  node.on('input', async function(msg, send, done) {
54
- if (!node.driver || !node.ready) { done(); return; }
72
+ if (!deviceNode.driver || !deviceNode.ready) { done(); return; }
55
73
  try {
56
74
  const p = msg.payload;
57
75
  let handled = false;
58
76
  if (p && typeof p === 'object') {
59
- if (typeof p.microsteps === 'number') { await node.driver.setMicrosteps(p.microsteps); handled = true; }
60
- if (typeof p.current === 'number') { await node.driver.setCurrent(p.current); handled = true; }
61
- if (typeof p.stall_threshold === 'number') { await node.driver.setStallThreshold(p.stall_threshold); handled = true; }
62
- if (typeof p.spreadcycle === 'boolean') { await node.driver.setChopperMode(p.spreadcycle); handled = true; }
77
+ if (typeof p.microsteps === 'number') { await deviceNode.driver.setMicrosteps(p.microsteps); handled = true; }
78
+ if (typeof p.current === 'number') { await deviceNode.driver.setCurrent(p.current); handled = true; }
79
+ if (typeof p.stall_threshold === 'number') { await deviceNode.driver.setStallThreshold(p.stall_threshold); handled = true; }
80
+ if (typeof p.spreadcycle === 'boolean') { await deviceNode.driver.setChopperMode(p.spreadcycle); handled = true; }
63
81
  if (typeof p.enable === 'boolean') {
64
- if (p.enable) await node.driver.enable(); else await node.driver.disable();
82
+ if (p.enable) await deviceNode.driver.enable(); else await deviceNode.driver.disable();
65
83
  handled = true;
66
84
  }
67
85
  if (typeof p.move === 'number') {
68
- await node.driver.move(p.move, typeof p.speed === 'number' ? p.speed : node.speed);
86
+ await deviceNode.driver.move(p.move, typeof p.speed === 'number' ? p.speed : deviceNode.speed);
69
87
  handled = true;
70
88
  }
71
89
  }
72
90
  if (handled) {
73
91
  msg.payload = await snapshot();
74
92
  } else {
75
- const status = await node.driver.readStatus();
93
+ const status = await deviceNode.driver.readStatus();
76
94
  msg.payload = {
77
95
  standstill: status.stst,
78
- fault: await node.driver.readFault(),
96
+ fault: await deviceNode.driver.readFault(),
79
97
  cs_actual: status.cs_actual,
80
98
  sg_result: status.sg_result,
81
- tstep: await node.driver.readTstep(),
99
+ tstep: await deviceNode.driver.readTstep(),
82
100
  stallguard: status.stallguard,
83
101
  otpw: status.otpw,
84
102
  ot: status.ot,
@@ -90,17 +108,6 @@ module.exports = function(RED) {
90
108
  done(e);
91
109
  }
92
110
  });
93
-
94
- node.on('close', async function(removed, done) {
95
- try {
96
- if (node.driver && node.ready) await node.driver.disable();
97
- if (node.connection) await node.connection.close();
98
- } catch (e) {
99
- // bus may already be gone; nothing more to do on close
100
- } finally {
101
- done();
102
- }
103
- });
104
111
  }
105
- RED.nodes.registerType('periph-tmc2130', TMC2130Node);
112
+ RED.nodes.registerType('tmc2130', TMC2130ReadNode);
106
113
  };
@@ -1,7 +1,7 @@
1
+ <!-- Config node: one instance per physical device -->
1
2
  <script type="text/javascript">
2
- RED.nodes.registerType('periph-tmc2208', {
3
- category: 'Peripheral',
4
- color: '#C084FC',
3
+ RED.nodes.registerType('tmc2208-device', {
4
+ category: 'config',
5
5
  defaults: {
6
6
  name: { value: '' },
7
7
  port: { value: '/dev/ttyS0', required: true },
@@ -11,50 +11,76 @@
11
11
  microsteps: { value: '16' },
12
12
  enGpio: { value: '' }
13
13
  },
14
- inputs: 1,
15
- outputs: 1,
16
- icon: 'font-awesome/fa-cog',
17
- label: function() { return this.name || 'TMC2208'; },
18
- paletteLabel: 'TMC2208'
14
+ label: function() {
15
+ return this.name || 'TMC2208';
16
+ }
19
17
  });
20
18
  </script>
21
19
 
22
- <script type="text/html" data-template-name="periph-tmc2208">
20
+ <script type="text/html" data-template-name="tmc2208-device">
23
21
  <div class="form-row">
24
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
25
- <input type="text" id="node-input-name" placeholder="TMC2208">
22
+ <label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
23
+ <input type="text" id="node-config-input-name" placeholder="TMC2208">
26
24
  </div>
27
25
  <div class="form-row">
28
- <label for="node-input-port"><i class="fa fa-plug"></i> Serial port</label>
29
- <input type="text" id="node-input-port" placeholder="/dev/ttyS0">
26
+ <label for="node-config-input-port"><i class="fa fa-plug"></i> Serial port</label>
27
+ <input type="text" id="node-config-input-port" placeholder="/dev/ttyS0">
30
28
  </div>
31
29
  <div class="form-row">
32
- <label for="node-input-baudrate"><i class="fa fa-tachometer"></i> Baud rate</label>
33
- <input type="number" id="node-input-baudrate" min="9000" style="width:100px">
30
+ <label for="node-config-input-baudrate"><i class="fa fa-tachometer"></i> Baud rate</label>
31
+ <input type="number" id="node-config-input-baudrate" min="9000" style="width:100px">
34
32
  </div>
35
33
  <div class="form-row">
36
- <label for="node-input-rsense"><i class="fa fa-bolt"></i> Sense resistor (Ω)</label>
37
- <input type="number" id="node-input-rsense" min="0.01" step="0.01" style="width:100px">
34
+ <label for="node-config-input-rsense"><i class="fa fa-bolt"></i> Sense resistor (Ω)</label>
35
+ <input type="number" id="node-config-input-rsense" min="0.01" step="0.01" style="width:100px">
38
36
  </div>
39
37
  <div class="form-row">
40
- <label for="node-input-current"><i class="fa fa-bolt"></i> Default current (A RMS)</label>
41
- <input type="number" id="node-input-current" min="0" max="1.2" step="0.05" style="width:100px">
38
+ <label for="node-config-input-current"><i class="fa fa-bolt"></i> Default current (A RMS)</label>
39
+ <input type="number" id="node-config-input-current" min="0" max="1.2" step="0.05" style="width:100px">
42
40
  </div>
43
41
  <div class="form-row">
44
- <label for="node-input-microsteps"><i class="fa fa-th"></i> Default microsteps</label>
45
- <select id="node-input-microsteps" style="width:100px">
42
+ <label for="node-config-input-microsteps"><i class="fa fa-th"></i> Default microsteps</label>
43
+ <select id="node-config-input-microsteps" style="width:100px">
46
44
  <option value="1">1</option><option value="2">2</option><option value="4">4</option>
47
45
  <option value="8">8</option><option value="16">16</option><option value="32">32</option>
48
46
  <option value="64">64</option><option value="128">128</option><option value="256">256</option>
49
47
  </select>
50
48
  </div>
51
49
  <div class="form-row">
52
- <label for="node-input-enGpio"><i class="fa fa-microchip"></i> ENN GPIO (optional)</label>
53
- <input type="text" id="node-input-enGpio" placeholder="not wired, e.g. 0:17" style="width:140px">
50
+ <label for="node-config-input-enGpio"><i class="fa fa-microchip"></i> ENN GPIO (optional)</label>
51
+ <input type="text" id="node-config-input-enGpio" placeholder="not wired, e.g. 0:17" style="width:140px">
52
+ </div>
53
+ </script>
54
+
55
+ <!-- Read node -->
56
+ <script type="text/javascript">
57
+ RED.nodes.registerType('tmc2208', {
58
+ category: 'Peripheral',
59
+ color: '#C084FC',
60
+ defaults: {
61
+ name: { value: '' },
62
+ device: { value: '', type: 'tmc2208-device', required: true }
63
+ },
64
+ inputs: 1,
65
+ outputs: 1,
66
+ icon: 'font-awesome/fa-cog',
67
+ label: function() { return this.name || 'TMC2208'; },
68
+ paletteLabel: 'TMC2208'
69
+ });
70
+ </script>
71
+
72
+ <script type="text/html" data-template-name="tmc2208">
73
+ <div class="form-row">
74
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
75
+ <input type="text" id="node-input-name" placeholder="TMC2208">
76
+ </div>
77
+ <div class="form-row">
78
+ <label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
79
+ <input type="text" id="node-input-device">
54
80
  </div>
55
81
  </script>
56
82
 
57
- <script type="text/html" data-help-name="periph-tmc2208">
83
+ <script type="text/html" data-help-name="tmc2208">
58
84
  <p>Drives a two-phase bipolar stepper motor through a Trinamic TMC2202 / TMC2208 / TMC2224 over its single-wire UART. The chip's internal step generator moves the motor, so no STEP pulses are needed.</p>
59
85
 
60
86
  <h3>Inputs</h3>