node-red-contrib-periph-display 1.3.2 → 1.3.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 +4 -0
- package/examples/pcf8578/demo.json +119 -0
- package/examples/pcf8579/demo.json +121 -0
- package/nodes/pcf8578/pcf8578.html +97 -0
- package/nodes/pcf8578/pcf8578.js +80 -0
- package/nodes/pcf8579/pcf8579.html +110 -0
- package/nodes/pcf8579/pcf8579.js +81 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -19,6 +19,10 @@ npm install node-red-contrib-periph-display
|
|
|
19
19
|
| `periph-il0373` | input | Draws on an IL0373 black/white e-paper panel (104 x 212, e.g. Waveshare 2.13inch e-Paper (D)) over SPI. Drawing messages change the framebuffer only; show sends it and refreshes the panel, which blocks the node until the controller is ready again. |
|
|
20
20
|
| `pcf8576-device` | config | I²C bus and address for a PCF8576 |
|
|
21
21
|
| `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. |
|
|
22
|
+
| `pcf8578-device` | config | I²C bus and address for a PCF8578 |
|
|
23
|
+
| `periph-pcf8578` | input | Draws on a PCF8578 row/column LCD dot-matrix driver over I²C (stand-alone mixed mode). Any incoming message triggers the writes described below. The device is configured via a pcf8578-device config node. |
|
|
24
|
+
| `pcf8579-device` | config | I²C bus and address for a PCF8579 |
|
|
25
|
+
| `periph-pcf8579` | input | Draws into the display RAM of a PCF8579 LCD column driver over I²C. The PCF8579 cannot run alone: a PCF8578 (or an equivalent source) must supply the clock, frame sync and row waveforms. Any incoming message triggers the writes described below. The device is configured via a pcf8579-device config node. |
|
|
22
26
|
| `periph-ssd1331` | input | Draws on an SSD1331 96 x 64 RGB OLED (e.g. Waveshare 0.95inch RGB OLED) over SPI. The chip has no BUSY line. Drawing messages change the framebuffer only; show sends it to the display. The hw* messages use the controller's own drawing engine on the display RAM. |
|
|
23
27
|
| `periph-st7036` | output | Writes text on an ST7036 character LCD (EA DOGM081 / DOGM162 / DOGM163) in 4-wire serial mode over SPI. The serial mode is write-only; the chip has no BUSY line. Strapping: PSB = GND, E = 3V3, booster capacitors for 3.3 V. |
|
|
24
28
|
| `periph-uc1611s` | input | Draws on a UC1611s graphic LCD (EA DOGXL240-7, 240 x 128, black/white) over I2C or 4-wire SPI. On I2C the chip has two addresses, command ( 0x38 + 2n ) and data (one higher); the node opens both. On SPI the node needs the SPI bus / chip-select device and the GPIO lines for CD (D/C) and RST; the module must be strapped for 4-wire SPI (BM0 = D13 = VSS), and payload.status is not available. The module runs from 3.3 V only. |
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab-pcf8578-demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "PCF8578 Bouncing Pixel",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Drives a 16-row x 24-column dot-matrix LCD from a PCF8578 over I2C. An inject node fires every 500 ms; a function node computes a bouncing pixel position, first clearing the previous position and then lighting the new one, and sends both to the periph-pcf8578 node. A second inject toggles inverse video on and off every 2 seconds to show the display status control. The RAM contents survive status changes, so the bouncing pixel keeps moving while the panel flips between normal and inverse."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "cfg-pcf8578",
|
|
11
|
+
"type": "pcf8578-device",
|
|
12
|
+
"name": "PCF8578",
|
|
13
|
+
"bus": "1",
|
|
14
|
+
"address": "3C",
|
|
15
|
+
"rows": "16"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "inj-tick",
|
|
19
|
+
"type": "inject",
|
|
20
|
+
"name": "every 500 ms",
|
|
21
|
+
"repeat": "0.5",
|
|
22
|
+
"crontab": "",
|
|
23
|
+
"once": true,
|
|
24
|
+
"onceDelay": 0.1,
|
|
25
|
+
"topic": "",
|
|
26
|
+
"payload": "",
|
|
27
|
+
"payloadType": "date",
|
|
28
|
+
"z": "tab-pcf8578-demo",
|
|
29
|
+
"x": 130,
|
|
30
|
+
"y": 120,
|
|
31
|
+
"wires": [
|
|
32
|
+
[
|
|
33
|
+
"fn-bounce"
|
|
34
|
+
]
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "fn-bounce",
|
|
39
|
+
"type": "function",
|
|
40
|
+
"name": "bouncing pixel",
|
|
41
|
+
"func": " const n = context.get('n') || 0;\n context.set('n', n + 1);\n const cols = 24, rows = 16;\n // triangle-wave bounce across the panel\n const px = Math.abs(((n % (2 * (cols - 1))) - (cols - 1)));\n const py = Math.abs(((n % (2 * (rows - 1))) - (rows - 1)));\n const prev = context.get('prev');\n const out = [];\n if (prev) out.push({ payload: { pixel: { x: prev.x, y: prev.y, on: false } } });\n out.push({ payload: { pixel: { x: px, y: py, on: true } } });\n context.set('prev', { x: px, y: py });\n return [out];",
|
|
42
|
+
"outputs": 1,
|
|
43
|
+
"noerr": 0,
|
|
44
|
+
"z": "tab-pcf8578-demo",
|
|
45
|
+
"x": 330,
|
|
46
|
+
"y": 120,
|
|
47
|
+
"wires": [
|
|
48
|
+
[
|
|
49
|
+
"lcd-node"
|
|
50
|
+
]
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "inj-invert",
|
|
55
|
+
"type": "inject",
|
|
56
|
+
"name": "inverse",
|
|
57
|
+
"repeat": "4",
|
|
58
|
+
"crontab": "",
|
|
59
|
+
"once": true,
|
|
60
|
+
"onceDelay": 2,
|
|
61
|
+
"topic": "",
|
|
62
|
+
"payload": "{\"display\":\"inverse\"}",
|
|
63
|
+
"payloadType": "json",
|
|
64
|
+
"z": "tab-pcf8578-demo",
|
|
65
|
+
"x": 120,
|
|
66
|
+
"y": 200,
|
|
67
|
+
"wires": [
|
|
68
|
+
[
|
|
69
|
+
"lcd-node"
|
|
70
|
+
]
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"id": "inj-normal",
|
|
75
|
+
"type": "inject",
|
|
76
|
+
"name": "normal",
|
|
77
|
+
"repeat": "4",
|
|
78
|
+
"crontab": "",
|
|
79
|
+
"once": true,
|
|
80
|
+
"onceDelay": 4,
|
|
81
|
+
"topic": "",
|
|
82
|
+
"payload": "{\"display\":\"normal\"}",
|
|
83
|
+
"payloadType": "json",
|
|
84
|
+
"z": "tab-pcf8578-demo",
|
|
85
|
+
"x": 120,
|
|
86
|
+
"y": 260,
|
|
87
|
+
"wires": [
|
|
88
|
+
[
|
|
89
|
+
"lcd-node"
|
|
90
|
+
]
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"id": "lcd-node",
|
|
95
|
+
"type": "periph-pcf8578",
|
|
96
|
+
"name": "PCF8578",
|
|
97
|
+
"device": "cfg-pcf8578",
|
|
98
|
+
"z": "tab-pcf8578-demo",
|
|
99
|
+
"x": 560,
|
|
100
|
+
"y": 160,
|
|
101
|
+
"wires": [
|
|
102
|
+
[
|
|
103
|
+
"dbg"
|
|
104
|
+
]
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "dbg",
|
|
109
|
+
"type": "debug",
|
|
110
|
+
"name": "result",
|
|
111
|
+
"active": true,
|
|
112
|
+
"tosidebar": true,
|
|
113
|
+
"complete": "payload",
|
|
114
|
+
"z": "tab-pcf8578-demo",
|
|
115
|
+
"x": 740,
|
|
116
|
+
"y": 160,
|
|
117
|
+
"wires": []
|
|
118
|
+
}
|
|
119
|
+
]
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab-pcf8579-demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "PCF8579 Bouncing Pixel",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Drives a 16-row x 40-column LCD from a PCF8579 (subaddress 0, PCF8578 in row mode supplying rows and clock) over I2C. An inject node fires every 500 ms; a function node computes a bouncing pixel position, first clearing the previous position and then lighting the new one, and sends both to the periph-pcf8579 node. A second inject toggles inverse video on and off every 2 seconds to show the display status control. The RAM contents survive status changes, so the bouncing pixel keeps moving while the panel flips between normal and inverse."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "cfg-pcf8579",
|
|
11
|
+
"type": "pcf8579-device",
|
|
12
|
+
"name": "PCF8579",
|
|
13
|
+
"bus": "1",
|
|
14
|
+
"address": "3C",
|
|
15
|
+
"rows": "16",
|
|
16
|
+
"subaddress": "0",
|
|
17
|
+
"mixed": "false"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "inj-tick",
|
|
21
|
+
"type": "inject",
|
|
22
|
+
"name": "every 500 ms",
|
|
23
|
+
"repeat": "0.5",
|
|
24
|
+
"crontab": "",
|
|
25
|
+
"once": true,
|
|
26
|
+
"onceDelay": 0.1,
|
|
27
|
+
"topic": "",
|
|
28
|
+
"payload": "",
|
|
29
|
+
"payloadType": "date",
|
|
30
|
+
"z": "tab-pcf8579-demo",
|
|
31
|
+
"x": 130,
|
|
32
|
+
"y": 120,
|
|
33
|
+
"wires": [
|
|
34
|
+
[
|
|
35
|
+
"fn-bounce"
|
|
36
|
+
]
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": "fn-bounce",
|
|
41
|
+
"type": "function",
|
|
42
|
+
"name": "bouncing pixel",
|
|
43
|
+
"func": " const n = context.get('n') || 0;\n context.set('n', n + 1);\n const cols = 40, rows = 16;\n // triangle-wave bounce across the panel\n const px = Math.abs(((n % (2 * (cols - 1))) - (cols - 1)));\n const py = Math.abs(((n % (2 * (rows - 1))) - (rows - 1)));\n const prev = context.get('prev');\n const out = [];\n if (prev) out.push({ payload: { pixel: { x: prev.x, y: prev.y, on: false } } });\n out.push({ payload: { pixel: { x: px, y: py, on: true } } });\n context.set('prev', { x: px, y: py });\n return [out];",
|
|
44
|
+
"outputs": 1,
|
|
45
|
+
"noerr": 0,
|
|
46
|
+
"z": "tab-pcf8579-demo",
|
|
47
|
+
"x": 330,
|
|
48
|
+
"y": 120,
|
|
49
|
+
"wires": [
|
|
50
|
+
[
|
|
51
|
+
"lcd-node"
|
|
52
|
+
]
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"id": "inj-invert",
|
|
57
|
+
"type": "inject",
|
|
58
|
+
"name": "inverse",
|
|
59
|
+
"repeat": "4",
|
|
60
|
+
"crontab": "",
|
|
61
|
+
"once": true,
|
|
62
|
+
"onceDelay": 2,
|
|
63
|
+
"topic": "",
|
|
64
|
+
"payload": "{\"display\":\"inverse\"}",
|
|
65
|
+
"payloadType": "json",
|
|
66
|
+
"z": "tab-pcf8579-demo",
|
|
67
|
+
"x": 120,
|
|
68
|
+
"y": 200,
|
|
69
|
+
"wires": [
|
|
70
|
+
[
|
|
71
|
+
"lcd-node"
|
|
72
|
+
]
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "inj-normal",
|
|
77
|
+
"type": "inject",
|
|
78
|
+
"name": "normal",
|
|
79
|
+
"repeat": "4",
|
|
80
|
+
"crontab": "",
|
|
81
|
+
"once": true,
|
|
82
|
+
"onceDelay": 4,
|
|
83
|
+
"topic": "",
|
|
84
|
+
"payload": "{\"display\":\"normal\"}",
|
|
85
|
+
"payloadType": "json",
|
|
86
|
+
"z": "tab-pcf8579-demo",
|
|
87
|
+
"x": 120,
|
|
88
|
+
"y": 260,
|
|
89
|
+
"wires": [
|
|
90
|
+
[
|
|
91
|
+
"lcd-node"
|
|
92
|
+
]
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "lcd-node",
|
|
97
|
+
"type": "periph-pcf8579",
|
|
98
|
+
"name": "PCF8579",
|
|
99
|
+
"device": "cfg-pcf8579",
|
|
100
|
+
"z": "tab-pcf8579-demo",
|
|
101
|
+
"x": 560,
|
|
102
|
+
"y": 160,
|
|
103
|
+
"wires": [
|
|
104
|
+
[
|
|
105
|
+
"dbg"
|
|
106
|
+
]
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"id": "dbg",
|
|
111
|
+
"type": "debug",
|
|
112
|
+
"name": "result",
|
|
113
|
+
"active": true,
|
|
114
|
+
"tosidebar": true,
|
|
115
|
+
"complete": "payload",
|
|
116
|
+
"z": "tab-pcf8579-demo",
|
|
117
|
+
"x": 740,
|
|
118
|
+
"y": 160,
|
|
119
|
+
"wires": []
|
|
120
|
+
}
|
|
121
|
+
]
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('pcf8578-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '3C', required: true },
|
|
9
|
+
rows: { value: '16', required: true, validate: RED.validators.number() }
|
|
10
|
+
},
|
|
11
|
+
label: function() {
|
|
12
|
+
return this.name || ('PCF8578 @ 0x' + this.address + ' (bus ' + this.bus + ')');
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script type="text/html" data-template-name="pcf8578-device">
|
|
18
|
+
<div class="form-row">
|
|
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="PCF8578">
|
|
21
|
+
</div>
|
|
22
|
+
<div class="form-row">
|
|
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)
|
|
25
|
+
</div>
|
|
26
|
+
<div class="form-row">
|
|
27
|
+
<label for="node-config-input-address">I²C address (hex)</label>
|
|
28
|
+
<select id="node-config-input-address" style="width:100px">
|
|
29
|
+
<option value="3C">0x3C (SA0 = VSS)</option>
|
|
30
|
+
<option value="3D">0x3D (SA0 = VDD)</option>
|
|
31
|
+
</select>
|
|
32
|
+
</div>
|
|
33
|
+
<div class="form-row">
|
|
34
|
+
<label for="node-config-input-rows">Rows</label>
|
|
35
|
+
<select id="node-config-input-rows" style="width:180px">
|
|
36
|
+
<option value="8">8 rows x 32 columns (1:8)</option>
|
|
37
|
+
<option value="16" selected>16 rows x 24 columns (1:16)</option>
|
|
38
|
+
<option value="24">24 rows x 16 columns (1:24)</option>
|
|
39
|
+
<option value="32">32 rows x 8 columns (1:32)</option>
|
|
40
|
+
</select>
|
|
41
|
+
</div>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<!-- Input node: message → draw on the display -->
|
|
45
|
+
<script type="text/javascript">
|
|
46
|
+
RED.nodes.registerType('periph-pcf8578', {
|
|
47
|
+
category: 'Peripheral',
|
|
48
|
+
color: '#C084FC',
|
|
49
|
+
defaults: {
|
|
50
|
+
name: { value: '' },
|
|
51
|
+
device: { value: '', type: 'pcf8578-device', required: true }
|
|
52
|
+
},
|
|
53
|
+
inputs: 1,
|
|
54
|
+
outputs: 1,
|
|
55
|
+
icon: 'font-awesome/fa-th',
|
|
56
|
+
label: function() { return this.name || 'PCF8578'; },
|
|
57
|
+
paletteLabel: 'PCF8578'
|
|
58
|
+
});
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<script type="text/html" data-template-name="periph-pcf8578">
|
|
62
|
+
<div class="form-row">
|
|
63
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
64
|
+
<input type="text" id="node-input-device">
|
|
65
|
+
</div>
|
|
66
|
+
<div class="form-row">
|
|
67
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
68
|
+
<input type="text" id="node-input-name" placeholder="PCF8578">
|
|
69
|
+
</div>
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<script type="text/html" data-help-name="periph-pcf8578">
|
|
73
|
+
<p>Draws on a PCF8578 row/column LCD dot-matrix driver over I²C (stand-alone mixed mode). Any incoming message triggers the writes described below. The device is configured via a <b>pcf8578-device</b> config node.</p>
|
|
74
|
+
|
|
75
|
+
<h3>Inputs</h3>
|
|
76
|
+
<dl class="message-properties">
|
|
77
|
+
<dt>payload.clear <span class="property-type">boolean</span></dt>
|
|
78
|
+
<dd>When true, clears the display RAM.</dd>
|
|
79
|
+
<dt>payload.pixel <span class="property-type">object</span></dt>
|
|
80
|
+
<dd><code>{ x, y, on }</code> sets (<code>on</code> true or omitted) or clears one pixel at display column <code>x</code>, row <code>y</code>.</dd>
|
|
81
|
+
<dt>payload.columns <span class="property-type">object</span></dt>
|
|
82
|
+
<dd><code>{ x, bank, data: [b0, b1, …] }</code> writes column bytes in character mode at display column <code>x</code> of display bank <code>bank</code> (bit 0 = top row of the bank).</dd>
|
|
83
|
+
<dt>payload.display <span class="property-type">string</span></dt>
|
|
84
|
+
<dd><code>"blank"</code>, <code>"normal"</code>, <code>"all_on"</code> or <code>"inverse"</code>; the RAM is preserved.</dd>
|
|
85
|
+
<dt>payload.scroll <span class="property-type">number</span></dt>
|
|
86
|
+
<dd>Adds N (may be negative) to the start bank for hardware vertical scrolling in 8-row steps.</dd>
|
|
87
|
+
</dl>
|
|
88
|
+
|
|
89
|
+
<h3>Outputs</h3>
|
|
90
|
+
<dl class="message-properties">
|
|
91
|
+
<dt>payload <span class="property-type">any</span></dt>
|
|
92
|
+
<dd>Pass-through of the original incoming message after the writes succeed.</dd>
|
|
93
|
+
</dl>
|
|
94
|
+
|
|
95
|
+
<h3>Configuration</h3>
|
|
96
|
+
<p>Set the I²C bus number, the 7-bit address (0x3C for SA0=VSS or 0x3D for SA0=VDD) and the number of rows (8, 16, 24 or 32; columns = 40 − rows) in the device config node. The chip supports 100 kHz at most.</p>
|
|
97
|
+
</script>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { PCF8578Full } = require('periph/src/chips/display/pcf8578');
|
|
6
|
+
|
|
7
|
+
const DISPLAY = {
|
|
8
|
+
blank: PCF8578Full.DISPLAY_BLANK,
|
|
9
|
+
normal: PCF8578Full.DISPLAY_NORMAL,
|
|
10
|
+
all_on: PCF8578Full.DISPLAY_ALL_ON,
|
|
11
|
+
inverse: PCF8578Full.DISPLAY_INVERSE,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function PCF8578DeviceNode(config) {
|
|
15
|
+
RED.nodes.createNode(this, config);
|
|
16
|
+
const node = this;
|
|
17
|
+
try {
|
|
18
|
+
const connection = new I2CConnection(parseInt(config.bus), parseInt(config.address, 16));
|
|
19
|
+
node.driver = new PCF8578Full(connection, parseInt(config.rows) || 16);
|
|
20
|
+
node.connection = connection;
|
|
21
|
+
} catch (e) {
|
|
22
|
+
node.error('PCF8578 init failed: ' + e.message);
|
|
23
|
+
}
|
|
24
|
+
node.on('close', function() {
|
|
25
|
+
if (node.connection) node.connection.close();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
RED.nodes.registerType('pcf8578-device', PCF8578DeviceNode);
|
|
29
|
+
|
|
30
|
+
function PCF8578Node(config) {
|
|
31
|
+
RED.nodes.createNode(this, config);
|
|
32
|
+
const node = this;
|
|
33
|
+
node.device = RED.nodes.getNode(config.device);
|
|
34
|
+
|
|
35
|
+
node.on('input', async function(msg, send, done) {
|
|
36
|
+
if (!node.device || !node.device.driver) {
|
|
37
|
+
node.error('No PCF8578 device configured', msg);
|
|
38
|
+
done();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const d = node.device.driver;
|
|
43
|
+
const p = msg.payload || {};
|
|
44
|
+
let handled = false;
|
|
45
|
+
if (p.clear) {
|
|
46
|
+
await d.clear();
|
|
47
|
+
handled = true;
|
|
48
|
+
}
|
|
49
|
+
if (p.pixel) {
|
|
50
|
+
await d.setPixel(p.pixel.x, p.pixel.y, p.pixel.on !== false);
|
|
51
|
+
handled = true;
|
|
52
|
+
}
|
|
53
|
+
if (p.columns) {
|
|
54
|
+
await d.writeColumns(p.columns.x, p.columns.bank, p.columns.data);
|
|
55
|
+
handled = true;
|
|
56
|
+
}
|
|
57
|
+
if (typeof p.display === 'string') {
|
|
58
|
+
if (!(p.display in DISPLAY)) {
|
|
59
|
+
throw new Error('display must be blank, normal, all_on or inverse');
|
|
60
|
+
}
|
|
61
|
+
await d.setDisplay(DISPLAY[p.display]);
|
|
62
|
+
handled = true;
|
|
63
|
+
}
|
|
64
|
+
if (typeof p.scroll === 'number') {
|
|
65
|
+
await d.scroll(p.scroll);
|
|
66
|
+
handled = true;
|
|
67
|
+
}
|
|
68
|
+
if (!handled) {
|
|
69
|
+
node.error('Payload must contain clear, pixel, columns, display or scroll', msg);
|
|
70
|
+
} else {
|
|
71
|
+
send(msg);
|
|
72
|
+
}
|
|
73
|
+
done();
|
|
74
|
+
} catch (e) {
|
|
75
|
+
done(e);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
RED.nodes.registerType('periph-pcf8578', PCF8578Node);
|
|
80
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('pcf8579-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '3C', required: true },
|
|
9
|
+
subaddress: { value: '0', required: true, validate: RED.validators.number() },
|
|
10
|
+
rows: { value: '16', required: true, validate: RED.validators.number() },
|
|
11
|
+
mixed: { value: 'false' }
|
|
12
|
+
},
|
|
13
|
+
label: function() {
|
|
14
|
+
return this.name || ('PCF8579 @ 0x' + this.address + ' (bus ' + this.bus + ')');
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script type="text/html" data-template-name="pcf8579-device">
|
|
20
|
+
<div class="form-row">
|
|
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="PCF8579">
|
|
23
|
+
</div>
|
|
24
|
+
<div class="form-row">
|
|
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)
|
|
27
|
+
</div>
|
|
28
|
+
<div class="form-row">
|
|
29
|
+
<label for="node-config-input-address">I²C address (hex)</label>
|
|
30
|
+
<select id="node-config-input-address" style="width:100px">
|
|
31
|
+
<option value="3C">0x3C (SA0 = VSS)</option>
|
|
32
|
+
<option value="3D">0x3D (SA0 = VDD)</option>
|
|
33
|
+
</select>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="form-row">
|
|
36
|
+
<label for="node-config-input-subaddress">Subaddress (A3:A0)</label>
|
|
37
|
+
<input type="number" id="node-config-input-subaddress" min="0" max="15" style="width:80px">
|
|
38
|
+
</div>
|
|
39
|
+
<div class="form-row">
|
|
40
|
+
<label for="node-config-input-rows">Rows</label>
|
|
41
|
+
<select id="node-config-input-rows" style="width:180px">
|
|
42
|
+
<option value="8">8 rows (1:8)</option>
|
|
43
|
+
<option value="16" selected>16 rows (1:16)</option>
|
|
44
|
+
<option value="24">24 rows (1:24)</option>
|
|
45
|
+
<option value="32">32 rows (1:32)</option>
|
|
46
|
+
</select>
|
|
47
|
+
</div>
|
|
48
|
+
<div class="form-row">
|
|
49
|
+
<label for="node-config-input-mixed">PCF8578 mode</label>
|
|
50
|
+
<select id="node-config-input-mixed" style="width:180px">
|
|
51
|
+
<option value="false" selected>Row driver</option>
|
|
52
|
+
<option value="true">Mixed mode</option>
|
|
53
|
+
</select>
|
|
54
|
+
</div>
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<!-- Input node: message → draw on the display -->
|
|
58
|
+
<script type="text/javascript">
|
|
59
|
+
RED.nodes.registerType('periph-pcf8579', {
|
|
60
|
+
category: 'Peripheral',
|
|
61
|
+
color: '#C084FC',
|
|
62
|
+
defaults: {
|
|
63
|
+
name: { value: '' },
|
|
64
|
+
device: { value: '', type: 'pcf8579-device', required: true }
|
|
65
|
+
},
|
|
66
|
+
inputs: 1,
|
|
67
|
+
outputs: 1,
|
|
68
|
+
icon: 'font-awesome/fa-th',
|
|
69
|
+
label: function() { return this.name || 'PCF8579'; },
|
|
70
|
+
paletteLabel: 'PCF8579'
|
|
71
|
+
});
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<script type="text/html" data-template-name="periph-pcf8579">
|
|
75
|
+
<div class="form-row">
|
|
76
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
77
|
+
<input type="text" id="node-input-device">
|
|
78
|
+
</div>
|
|
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="PCF8579">
|
|
82
|
+
</div>
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<script type="text/html" data-help-name="periph-pcf8579">
|
|
86
|
+
<p>Draws into the display RAM of a PCF8579 LCD column driver over I²C. The PCF8579 cannot run alone: a PCF8578 (or an equivalent source) must supply the clock, frame sync and row waveforms. Any incoming message triggers the writes described below. The device is configured via a <b>pcf8579-device</b> config node.</p>
|
|
87
|
+
|
|
88
|
+
<h3>Inputs</h3>
|
|
89
|
+
<dl class="message-properties">
|
|
90
|
+
<dt>payload.clear <span class="property-type">boolean</span></dt>
|
|
91
|
+
<dd>When true, clears this device's display RAM.</dd>
|
|
92
|
+
<dt>payload.pixel <span class="property-type">object</span></dt>
|
|
93
|
+
<dd><code>{ x, y, on }</code> sets (<code>on</code> true or omitted) or clears one pixel at column <code>x</code> (0–39), row <code>y</code>.</dd>
|
|
94
|
+
<dt>payload.columns <span class="property-type">object</span></dt>
|
|
95
|
+
<dd><code>{ x, bank, data: [b0, b1, …] }</code> writes column bytes in character mode at column <code>x</code> (0–39) of bank <code>bank</code> (bit 0 = top row of the bank).</dd>
|
|
96
|
+
<dt>payload.display <span class="property-type">string</span></dt>
|
|
97
|
+
<dd><code>"blank"</code>, <code>"normal"</code>, <code>"all_on"</code> or <code>"inverse"</code>; the RAM is preserved. Affects every device on the I²C address.</dd>
|
|
98
|
+
<dt>payload.scroll <span class="property-type">number</span></dt>
|
|
99
|
+
<dd>Adds N (may be negative) to the start bank for hardware vertical scrolling in 8-row steps.</dd>
|
|
100
|
+
</dl>
|
|
101
|
+
|
|
102
|
+
<h3>Outputs</h3>
|
|
103
|
+
<dl class="message-properties">
|
|
104
|
+
<dt>payload <span class="property-type">any</span></dt>
|
|
105
|
+
<dd>Pass-through of the original incoming message after the writes succeed.</dd>
|
|
106
|
+
</dl>
|
|
107
|
+
|
|
108
|
+
<h3>Configuration</h3>
|
|
109
|
+
<p>Set the I²C bus number, the 7-bit address (0x3C for SA0=VSS or 0x3D for SA0=VDD), the hardware subaddress set on pins A3:A0 (0–15), the number of rows (8, 16, 24 or 32) and the PCF8578 mode (row driver or mixed mode) in the device config node. All devices on one bus must use the same rows and mode. The chip supports 100 kHz at most.</p>
|
|
110
|
+
</script>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { PCF8579Full } = require('periph/src/chips/display/pcf8579');
|
|
6
|
+
|
|
7
|
+
const DISPLAY = {
|
|
8
|
+
blank: PCF8579Full.DISPLAY_BLANK,
|
|
9
|
+
normal: PCF8579Full.DISPLAY_NORMAL,
|
|
10
|
+
all_on: PCF8579Full.DISPLAY_ALL_ON,
|
|
11
|
+
inverse: PCF8579Full.DISPLAY_INVERSE,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function PCF8579DeviceNode(config) {
|
|
15
|
+
RED.nodes.createNode(this, config);
|
|
16
|
+
const node = this;
|
|
17
|
+
try {
|
|
18
|
+
const connection = new I2CConnection(parseInt(config.bus), parseInt(config.address, 16));
|
|
19
|
+
node.driver = new PCF8579Full(connection, parseInt(config.subaddress) || 0,
|
|
20
|
+
parseInt(config.rows) || 16, config.mixed === 'true' || config.mixed === true);
|
|
21
|
+
node.connection = connection;
|
|
22
|
+
} catch (e) {
|
|
23
|
+
node.error('PCF8579 init failed: ' + e.message);
|
|
24
|
+
}
|
|
25
|
+
node.on('close', function() {
|
|
26
|
+
if (node.connection) node.connection.close();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
RED.nodes.registerType('pcf8579-device', PCF8579DeviceNode);
|
|
30
|
+
|
|
31
|
+
function PCF8579Node(config) {
|
|
32
|
+
RED.nodes.createNode(this, config);
|
|
33
|
+
const node = this;
|
|
34
|
+
node.device = RED.nodes.getNode(config.device);
|
|
35
|
+
|
|
36
|
+
node.on('input', async function(msg, send, done) {
|
|
37
|
+
if (!node.device || !node.device.driver) {
|
|
38
|
+
node.error('No PCF8579 device configured', msg);
|
|
39
|
+
done();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const d = node.device.driver;
|
|
44
|
+
const p = msg.payload || {};
|
|
45
|
+
let handled = false;
|
|
46
|
+
if (p.clear) {
|
|
47
|
+
await d.clear();
|
|
48
|
+
handled = true;
|
|
49
|
+
}
|
|
50
|
+
if (p.pixel) {
|
|
51
|
+
await d.setPixel(p.pixel.x, p.pixel.y, p.pixel.on !== false);
|
|
52
|
+
handled = true;
|
|
53
|
+
}
|
|
54
|
+
if (p.columns) {
|
|
55
|
+
await d.writeColumns(p.columns.x, p.columns.bank, p.columns.data);
|
|
56
|
+
handled = true;
|
|
57
|
+
}
|
|
58
|
+
if (typeof p.display === 'string') {
|
|
59
|
+
if (!(p.display in DISPLAY)) {
|
|
60
|
+
throw new Error('display must be blank, normal, all_on or inverse');
|
|
61
|
+
}
|
|
62
|
+
await d.setDisplay(DISPLAY[p.display]);
|
|
63
|
+
handled = true;
|
|
64
|
+
}
|
|
65
|
+
if (typeof p.scroll === 'number') {
|
|
66
|
+
await d.scroll(p.scroll);
|
|
67
|
+
handled = true;
|
|
68
|
+
}
|
|
69
|
+
if (!handled) {
|
|
70
|
+
node.error('Payload must contain clear, pixel, columns, display or scroll', msg);
|
|
71
|
+
} else {
|
|
72
|
+
send(msg);
|
|
73
|
+
}
|
|
74
|
+
done();
|
|
75
|
+
} catch (e) {
|
|
76
|
+
done(e);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
RED.nodes.registerType('periph-pcf8579', PCF8579Node);
|
|
81
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-periph-display",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Node-RED nodes for display driver chips",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
"nodes": {
|
|
15
15
|
"il0373": "nodes/il0373/il0373.js",
|
|
16
16
|
"pcf8576": "nodes/pcf8576/pcf8576.js",
|
|
17
|
+
"pcf8578": "nodes/pcf8578/pcf8578.js",
|
|
18
|
+
"pcf8579": "nodes/pcf8579/pcf8579.js",
|
|
17
19
|
"ssd1331": "nodes/ssd1331/ssd1331.js",
|
|
18
20
|
"st7036": "nodes/st7036/st7036.js",
|
|
19
21
|
"uc1611s": "nodes/uc1611s/uc1611s.js",
|