node-red-contrib-periph-display 1.1.0 → 1.2.1

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 CHANGED
@@ -2,15 +2,24 @@
2
2
 
3
3
  Node-RED nodes for display driver chips — part of the [Periph](https://github.com/tuhde/Periph) library.
4
4
 
5
- > **Coming soon.** Nodes will be added as chips in this category are implemented.
6
-
7
5
  ## Install
8
6
 
7
+ Open Node-RED, go to **Manage Palette → Install** and search for `node-red-contrib-periph-display`.
8
+
9
+ Or from the command line in your Node-RED user directory:
10
+
9
11
  ```sh
10
12
  npm install node-red-contrib-periph-display
11
13
  ```
12
14
 
15
+ ## Nodes
16
+
17
+ | Node | Kind | Description |
18
+ |------|------|-------------|
19
+ | `pcf8576-device` | config | I²C bus and address for a PCF8576 |
20
+ | `periph-pcf8576` | input | Writes 7-segment digits or raw data to a PCF8576 40x4 universal LCD segment driver over I²C. The chip is write-only; any incoming message triggers a single write to display RAM. |
21
+
13
22
  ## Links
14
23
 
15
24
  - [GitHub](https://github.com/tuhde/Periph)
16
- - [All supported chips](https://github.com/tuhde/Periph#supported-chips)
25
+ - [periph JS driver](https://www.npmjs.com/package/periph)
@@ -53,7 +53,7 @@
53
53
  <script type="text/javascript">
54
54
  RED.nodes.registerType('periph-pcf8576', {
55
55
  category: 'Peripheral',
56
- color: '#a6bbcf',
56
+ color: '#C084FC',
57
57
  defaults: {
58
58
  name: { value: '' },
59
59
  device: { value: '', type: 'pcf8576-device', required: true }
@@ -97,5 +97,5 @@
97
97
 
98
98
  <h3>Configuration</h3>
99
99
  <p>Set the I²C bus number, the chip's 7-bit address (0x38 for SA0=VSS or 0x39 for SA0=VDD), the drive mode (1-4 backplanes), and the bias in the device config node.</p>
100
- <p>The PCF8576 has no read-back — there is no status output. The driver only uses <code>transport.write()</code>.</p>
100
+ <p>The PCF8576 has no read-back — there is no status output. The driver only uses <code>connection.write()</code>.</p>
101
101
  </script>
@@ -1,22 +1,22 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports = function(RED) {
4
- const { I2CTransport } = require('periph/src/transport/i2c');
4
+ const { I2CConnection } = require('periph/src/connection/i2c');
5
5
  const { PCF8576Full } = require('periph/src/chips/display/pcf8576');
6
6
 
7
7
  function PCF8576DeviceNode(config) {
8
8
  RED.nodes.createNode(this, config);
9
9
  const node = this;
10
10
  try {
11
- const transport = new I2CTransport(parseInt(config.bus), parseInt(config.address, 16));
12
- node.driver = new PCF8576Full(transport);
11
+ const connection = new I2CConnection(parseInt(config.bus), parseInt(config.address, 16));
12
+ node.driver = new PCF8576Full(connection);
13
13
  node.driver.setMode(parseInt(config.backplanes) || 4, parseInt(config.bias) || 0);
14
- node.transport = transport;
14
+ node.connection = connection;
15
15
  } catch (e) {
16
16
  node.error('PCF8576 init failed: ' + e.message);
17
17
  }
18
18
  node.on('close', function() {
19
- if (node.transport) node.transport.close();
19
+ if (node.connection) node.connection.close();
20
20
  });
21
21
  }
22
22
  RED.nodes.registerType('pcf8576-device', PCF8576DeviceNode);
@@ -26,7 +26,7 @@ module.exports = function(RED) {
26
26
  const node = this;
27
27
  node.device = RED.nodes.getNode(config.device);
28
28
 
29
- node.on('input', function(msg, send, done) {
29
+ node.on('input', async function(msg, send, done) {
30
30
  if (!node.device || !node.device.driver) {
31
31
  node.error('No PCF8576 device configured', msg);
32
32
  done();
@@ -38,10 +38,10 @@ module.exports = function(RED) {
38
38
  if (payload && Array.isArray(payload.digits)) {
39
39
  const digits = payload.digits;
40
40
  const out = digits.map(v => (v == null) ? 0x00 : PCF8576Full.SEVEN_SEG[Math.max(0, Math.min(9, v))]);
41
- d.writeRaw(0, out);
41
+ await d.writeRaw(0, out);
42
42
  send(msg);
43
43
  } else if (payload && typeof payload.address === 'number' && Array.isArray(payload.data)) {
44
- d.writeRaw(payload.address, payload.data);
44
+ await d.writeRaw(payload.address, payload.data);
45
45
  send(msg);
46
46
  } else {
47
47
  node.error('Payload must have digits[] or {address, data[]}', msg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-periph-display",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "Node-RED nodes for display driver chips",
5
5
  "keywords": [
6
6
  "node-red",