node-red-contrib-periph-display 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.
- package/README.md +26 -13
- package/examples/il0373/demo.json +18 -12
- package/examples/pcf8576/demo.json +2 -2
- package/examples/pcf8578/demo.json +2 -2
- package/examples/pcf8579/demo.json +2 -2
- package/examples/sh1106/demo.json +15 -7
- package/examples/ssd1305/demo.json +15 -7
- package/examples/ssd1306/demo.json +14 -7
- package/examples/ssd1331/demo.json +14 -8
- package/examples/st7036/demo.json +15 -9
- package/examples/uc1611s/demo.json +77 -20
- package/examples/uc8159/demo.json +16 -10
- package/examples/uc8276c/demo.json +18 -12
- package/nodes/il0373/il0373.html +58 -32
- package/nodes/il0373/il0373.js +16 -9
- package/nodes/pcf8576/pcf8576.html +3 -3
- package/nodes/pcf8576/pcf8576.js +1 -1
- package/nodes/pcf8578/pcf8578.html +3 -3
- package/nodes/pcf8578/pcf8578.js +1 -1
- package/nodes/pcf8579/pcf8579.html +3 -3
- package/nodes/pcf8579/pcf8579.js +1 -1
- package/nodes/sh1106/sh1106.html +62 -36
- package/nodes/sh1106/sh1106.js +20 -11
- package/nodes/ssd1305/ssd1305.html +62 -36
- package/nodes/ssd1305/ssd1305.js +20 -11
- package/nodes/ssd1306/ssd1306.html +62 -36
- package/nodes/ssd1306/ssd1306.js +18 -11
- package/nodes/ssd1331/ssd1331.html +49 -23
- package/nodes/ssd1331/ssd1331.js +16 -9
- package/nodes/st7036/st7036.html +51 -25
- package/nodes/st7036/st7036.js +15 -9
- package/nodes/uc1611s/uc1611s.html +64 -38
- package/nodes/uc1611s/uc1611s.js +21 -12
- package/nodes/uc8159/uc8159.html +55 -29
- package/nodes/uc8159/uc8159.js +16 -9
- package/nodes/uc8276c/uc8276c.html +58 -32
- package/nodes/uc8276c/uc8276c.js +16 -9
- package/package.json +17 -3
- package/index.js +0 -11
package/nodes/st7036/st7036.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('st7036-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
spiBus: { value: '0', required: true, validate: RED.validators.number() },
|
|
@@ -12,54 +12,80 @@
|
|
|
12
12
|
lines: { value: '2' },
|
|
13
13
|
supply: { value: '3v3' }
|
|
14
14
|
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
label: function() { return this.name || 'ST7036'; },
|
|
19
|
-
paletteLabel: 'ST7036'
|
|
15
|
+
label: function() {
|
|
16
|
+
return this.name || 'ST7036';
|
|
17
|
+
}
|
|
20
18
|
});
|
|
21
19
|
</script>
|
|
22
20
|
|
|
23
|
-
<script type="text/html" data-template-name="
|
|
21
|
+
<script type="text/html" data-template-name="st7036-device">
|
|
24
22
|
<div class="form-row">
|
|
25
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
26
|
-
<input type="text" id="node-input-name" placeholder="ST7036">
|
|
23
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
24
|
+
<input type="text" id="node-config-input-name" placeholder="ST7036">
|
|
27
25
|
</div>
|
|
28
26
|
<div class="form-row">
|
|
29
|
-
<label for="node-input-spiBus"><i class="fa fa-microchip"></i> SPI bus</label>
|
|
30
|
-
<input type="number" id="node-input-spiBus" min="0" style="width:70px">
|
|
31
|
-
chip select <input type="number" id="node-input-spiDevice" min="0" style="width:70px">
|
|
27
|
+
<label for="node-config-input-spiBus"><i class="fa fa-microchip"></i> SPI bus</label>
|
|
28
|
+
<input type="number" id="node-config-input-spiBus" min="0" style="width:70px">
|
|
29
|
+
chip select <input type="number" id="node-config-input-spiDevice" min="0" style="width:70px">
|
|
32
30
|
</div>
|
|
33
31
|
<div class="form-row">
|
|
34
|
-
<label for="node-input-gpioChip">GPIO chip</label>
|
|
35
|
-
<input type="number" id="node-input-gpioChip" min="0" style="width:70px">
|
|
32
|
+
<label for="node-config-input-gpioChip">GPIO chip</label>
|
|
33
|
+
<input type="number" id="node-config-input-gpioChip" min="0" style="width:70px">
|
|
36
34
|
</div>
|
|
37
35
|
<div class="form-row">
|
|
38
|
-
<label for="node-input-rsPin">RS (C/D) line</label>
|
|
39
|
-
<input type="number" id="node-input-rsPin" min="0" style="width:70px">
|
|
36
|
+
<label for="node-config-input-rsPin">RS (C/D) line</label>
|
|
37
|
+
<input type="number" id="node-config-input-rsPin" min="0" style="width:70px">
|
|
40
38
|
</div>
|
|
41
39
|
<div class="form-row">
|
|
42
|
-
<label for="node-input-resPin">RESET line</label>
|
|
43
|
-
<input type="number" id="node-input-resPin" min="0" style="width:70px">
|
|
40
|
+
<label for="node-config-input-resPin">RESET line</label>
|
|
41
|
+
<input type="number" id="node-config-input-resPin" min="0" style="width:70px">
|
|
44
42
|
</div>
|
|
45
43
|
<div class="form-row">
|
|
46
|
-
<label for="node-input-lines">Module</label>
|
|
47
|
-
<select id="node-input-lines" style="width:auto">
|
|
44
|
+
<label for="node-config-input-lines">Module</label>
|
|
45
|
+
<select id="node-config-input-lines" style="width:auto">
|
|
48
46
|
<option value="1">DOGM081 (1 x 8)</option>
|
|
49
47
|
<option value="2">DOGM162 (2 x 16)</option>
|
|
50
48
|
<option value="3">DOGM163 (3 x 16)</option>
|
|
51
49
|
</select>
|
|
52
50
|
</div>
|
|
53
51
|
<div class="form-row">
|
|
54
|
-
<label for="node-input-supply">Supply</label>
|
|
55
|
-
<select id="node-input-supply" style="width:auto">
|
|
52
|
+
<label for="node-config-input-supply">Supply</label>
|
|
53
|
+
<select id="node-config-input-supply" style="width:auto">
|
|
56
54
|
<option value="3v3">3.3 V (booster on)</option>
|
|
57
55
|
<option value="5v">5 V</option>
|
|
58
56
|
</select>
|
|
59
57
|
</div>
|
|
60
58
|
</script>
|
|
61
59
|
|
|
62
|
-
|
|
60
|
+
<!-- Read node -->
|
|
61
|
+
<script type="text/javascript">
|
|
62
|
+
RED.nodes.registerType('st7036', {
|
|
63
|
+
category: 'Peripheral',
|
|
64
|
+
color: '#C084FC',
|
|
65
|
+
defaults: {
|
|
66
|
+
name: { value: '' },
|
|
67
|
+
device: { value: '', type: 'st7036-device', required: true }
|
|
68
|
+
},
|
|
69
|
+
inputs: 1,
|
|
70
|
+
outputs: 0,
|
|
71
|
+
icon: 'font-awesome/fa-television',
|
|
72
|
+
label: function() { return this.name || 'ST7036'; },
|
|
73
|
+
paletteLabel: 'ST7036'
|
|
74
|
+
});
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<script type="text/html" data-template-name="st7036">
|
|
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="ST7036">
|
|
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>
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<script type="text/html" data-help-name="st7036">
|
|
63
89
|
<p>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.</p>
|
|
64
90
|
<p>A string payload is written at the current cursor position. Characters other than ASCII <code>0x20..0x7D</code> become <code>?</code>.</p>
|
|
65
91
|
|
package/nodes/st7036/st7036.js
CHANGED
|
@@ -6,10 +6,9 @@ module.exports = function(RED) {
|
|
|
6
6
|
const { GpioOutputPin } = require('periph/src/connection/output_pin');
|
|
7
7
|
const S = require('periph/src/chips/display/st7036');
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function ST7036DeviceNode(config) {
|
|
10
10
|
RED.nodes.createNode(this, config);
|
|
11
11
|
const node = this;
|
|
12
|
-
|
|
13
12
|
try {
|
|
14
13
|
const chip = parseInt(config.gpioChip || 0, 10);
|
|
15
14
|
const dc = new GpioOutputPin(Default.output({ chip, line: parseInt(config.rsPin, 10) }));
|
|
@@ -27,6 +26,17 @@ module.exports = function(RED) {
|
|
|
27
26
|
node.error('ST7036 init failed: ' + e.message);
|
|
28
27
|
}
|
|
29
28
|
|
|
29
|
+
node.on('close', function() {
|
|
30
|
+
if (node.connection) node.connection.close();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
RED.nodes.registerType('st7036-device', ST7036DeviceNode);
|
|
34
|
+
|
|
35
|
+
function ST7036ReadNode(config) {
|
|
36
|
+
RED.nodes.createNode(this, config);
|
|
37
|
+
const node = this;
|
|
38
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
39
|
+
|
|
30
40
|
// Messages are handled one at a time: two overlapping command streams would corrupt each other.
|
|
31
41
|
let queue = Promise.resolve();
|
|
32
42
|
node.on('input', function(msg, send, done) {
|
|
@@ -34,8 +44,8 @@ module.exports = function(RED) {
|
|
|
34
44
|
});
|
|
35
45
|
|
|
36
46
|
async function handle(msg, send, done) {
|
|
37
|
-
if (!
|
|
38
|
-
const d =
|
|
47
|
+
if (!deviceNode.driver) { done(); return; }
|
|
48
|
+
const d = deviceNode.driver;
|
|
39
49
|
let p = msg.payload;
|
|
40
50
|
try {
|
|
41
51
|
if (typeof p === 'string') p = { text: p };
|
|
@@ -66,10 +76,6 @@ module.exports = function(RED) {
|
|
|
66
76
|
done(e);
|
|
67
77
|
}
|
|
68
78
|
}
|
|
69
|
-
|
|
70
|
-
node.on('close', function() {
|
|
71
|
-
if (node.connection) node.connection.close();
|
|
72
|
-
});
|
|
73
79
|
}
|
|
74
|
-
RED.nodes.registerType('
|
|
80
|
+
RED.nodes.registerType('st7036', ST7036ReadNode);
|
|
75
81
|
};
|
|
@@ -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('uc1611s-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
transport: { value: 'i2c' },
|
|
@@ -15,62 +15,59 @@
|
|
|
15
15
|
width: { value: '240', required: true, validate: RED.validators.number() },
|
|
16
16
|
height: { value: '128', required: true, validate: RED.validators.number() },
|
|
17
17
|
topView: { value: false },
|
|
18
|
-
contrast: { value: '143', required: true, validate: RED.validators.number() }
|
|
19
|
-
|
|
18
|
+
contrast: { value: '143', required: true, validate: RED.validators.number() }
|
|
19
|
+
},
|
|
20
|
+
label: function() {
|
|
21
|
+
return this.name || 'UC1611S';
|
|
20
22
|
},
|
|
21
|
-
inputs: 1,
|
|
22
|
-
outputs: 1,
|
|
23
|
-
icon: 'font-awesome/fa-television',
|
|
24
|
-
label: function() { return this.name || 'UC1611s'; },
|
|
25
|
-
paletteLabel: 'UC1611s',
|
|
26
23
|
oneditprepare: function() {
|
|
27
24
|
function show() {
|
|
28
|
-
const spi = $('#node-input-transport').val() === 'spi';
|
|
25
|
+
const spi = $('#node-config-input-transport').val() === 'spi';
|
|
29
26
|
$('.uc1611s-i2c').toggle(!spi);
|
|
30
27
|
$('.uc1611s-spi').toggle(spi);
|
|
31
28
|
}
|
|
32
|
-
$('#node-input-transport').on('change', show);
|
|
29
|
+
$('#node-config-input-transport').on('change', show);
|
|
33
30
|
show();
|
|
34
31
|
}
|
|
35
32
|
});
|
|
36
33
|
</script>
|
|
37
34
|
|
|
38
|
-
<script type="text/html" data-template-name="
|
|
35
|
+
<script type="text/html" data-template-name="uc1611s-device">
|
|
39
36
|
<div class="form-row">
|
|
40
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
41
|
-
<input type="text" id="node-input-name" placeholder="
|
|
37
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
38
|
+
<input type="text" id="node-config-input-name" placeholder="UC1611S">
|
|
42
39
|
</div>
|
|
43
40
|
<div class="form-row">
|
|
44
|
-
<label for="node-input-transport"><i class="fa fa-exchange"></i> Interface</label>
|
|
45
|
-
<select id="node-input-transport" style="width:auto">
|
|
41
|
+
<label for="node-config-input-transport"><i class="fa fa-exchange"></i> Interface</label>
|
|
42
|
+
<select id="node-config-input-transport" style="width:auto">
|
|
46
43
|
<option value="i2c">I2C</option>
|
|
47
44
|
<option value="spi">4-wire SPI</option>
|
|
48
45
|
</select>
|
|
49
46
|
</div>
|
|
50
47
|
<div class="form-row uc1611s-spi">
|
|
51
|
-
<label for="node-input-spiBus"><i class="fa fa-microchip"></i> SPI bus / device</label>
|
|
52
|
-
<input type="number" id="node-input-spiBus" min="0" style="width:70px"> /
|
|
53
|
-
<input type="number" id="node-input-spiDevice" min="0" style="width:70px">
|
|
48
|
+
<label for="node-config-input-spiBus"><i class="fa fa-microchip"></i> SPI bus / device</label>
|
|
49
|
+
<input type="number" id="node-config-input-spiBus" min="0" style="width:70px"> /
|
|
50
|
+
<input type="number" id="node-config-input-spiDevice" min="0" style="width:70px">
|
|
54
51
|
</div>
|
|
55
52
|
<div class="form-row uc1611s-spi">
|
|
56
|
-
<label for="node-input-gpioChip">GPIO chip</label>
|
|
57
|
-
<input type="number" id="node-input-gpioChip" min="0" style="width:70px">
|
|
53
|
+
<label for="node-config-input-gpioChip">GPIO chip</label>
|
|
54
|
+
<input type="number" id="node-config-input-gpioChip" min="0" style="width:70px">
|
|
58
55
|
</div>
|
|
59
56
|
<div class="form-row uc1611s-spi">
|
|
60
|
-
<label for="node-input-cdPin">CD (D/C) line</label>
|
|
61
|
-
<input type="number" id="node-input-cdPin" min="0" style="width:70px">
|
|
57
|
+
<label for="node-config-input-cdPin">CD (D/C) line</label>
|
|
58
|
+
<input type="number" id="node-config-input-cdPin" min="0" style="width:70px">
|
|
62
59
|
</div>
|
|
63
60
|
<div class="form-row uc1611s-spi">
|
|
64
|
-
<label for="node-input-resPin">RST line</label>
|
|
65
|
-
<input type="number" id="node-input-resPin" min="0" style="width:70px">
|
|
61
|
+
<label for="node-config-input-resPin">RST line</label>
|
|
62
|
+
<input type="number" id="node-config-input-resPin" min="0" style="width:70px">
|
|
66
63
|
</div>
|
|
67
64
|
<div class="form-row uc1611s-i2c">
|
|
68
|
-
<label for="node-input-i2cBus"><i class="fa fa-microchip"></i> I2C bus</label>
|
|
69
|
-
<input type="number" id="node-input-i2cBus" min="0" style="width:70px">
|
|
65
|
+
<label for="node-config-input-i2cBus"><i class="fa fa-microchip"></i> I2C bus</label>
|
|
66
|
+
<input type="number" id="node-config-input-i2cBus" min="0" style="width:70px">
|
|
70
67
|
</div>
|
|
71
68
|
<div class="form-row uc1611s-i2c">
|
|
72
|
-
<label for="node-input-address">Command address</label>
|
|
73
|
-
<select id="node-input-address" style="width:auto">
|
|
69
|
+
<label for="node-config-input-address">Command address</label>
|
|
70
|
+
<select id="node-config-input-address" style="width:auto">
|
|
74
71
|
<option value="0x38">0x38 (A3 = A2 = low, data 0x39)</option>
|
|
75
72
|
<option value="0x3A">0x3A (A2 high, data 0x3B)</option>
|
|
76
73
|
<option value="0x3C">0x3C (A3 high, data 0x3D)</option>
|
|
@@ -78,17 +75,46 @@
|
|
|
78
75
|
</select>
|
|
79
76
|
</div>
|
|
80
77
|
<div class="form-row">
|
|
81
|
-
<label for="node-input-width">Size</label>
|
|
82
|
-
<input type="number" id="node-input-width" min="1" max="240" style="width:70px"> x
|
|
83
|
-
<input type="number" id="node-input-height" min="8" max="128" step="8" style="width:70px">
|
|
78
|
+
<label for="node-config-input-width">Size</label>
|
|
79
|
+
<input type="number" id="node-config-input-width" min="1" max="240" style="width:70px"> x
|
|
80
|
+
<input type="number" id="node-config-input-height" min="8" max="128" step="8" style="width:70px">
|
|
81
|
+
</div>
|
|
82
|
+
<div class="form-row">
|
|
83
|
+
<label for="node-config-input-contrast">Contrast (PM)</label>
|
|
84
|
+
<input type="number" id="node-config-input-contrast" min="0" max="255" style="width:70px">
|
|
84
85
|
</div>
|
|
85
86
|
<div class="form-row">
|
|
86
|
-
<label for="node-input-
|
|
87
|
-
<input type="
|
|
87
|
+
<label for="node-config-input-topView">Top view</label>
|
|
88
|
+
<input type="checkbox" id="node-config-input-topView" style="width:auto; vertical-align:top">
|
|
89
|
+
</div>
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<!-- Read node -->
|
|
93
|
+
<script type="text/javascript">
|
|
94
|
+
RED.nodes.registerType('uc1611s', {
|
|
95
|
+
category: 'Peripheral',
|
|
96
|
+
color: '#C084FC',
|
|
97
|
+
defaults: {
|
|
98
|
+
name: { value: '' },
|
|
99
|
+
device: { value: '', type: 'uc1611s-device', required: true },
|
|
100
|
+
autoShow: { value: true }
|
|
101
|
+
},
|
|
102
|
+
inputs: 1,
|
|
103
|
+
outputs: 1,
|
|
104
|
+
icon: 'font-awesome/fa-television',
|
|
105
|
+
label: function() { return this.name || 'UC1611S'; },
|
|
106
|
+
paletteLabel: 'UC1611S'
|
|
107
|
+
});
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<script type="text/html" data-template-name="uc1611s">
|
|
111
|
+
<div class="form-row">
|
|
112
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
113
|
+
<input type="text" id="node-input-name" placeholder="UC1611S">
|
|
88
114
|
</div>
|
|
89
115
|
<div class="form-row">
|
|
90
|
-
<label for="node-input-
|
|
91
|
-
<input type="
|
|
116
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
117
|
+
<input type="text" id="node-input-device">
|
|
92
118
|
</div>
|
|
93
119
|
<div class="form-row">
|
|
94
120
|
<label for="node-input-autoShow">Auto-show</label>
|
|
@@ -96,7 +122,7 @@
|
|
|
96
122
|
</div>
|
|
97
123
|
</script>
|
|
98
124
|
|
|
99
|
-
<script type="text/html" data-help-name="
|
|
125
|
+
<script type="text/html" data-help-name="uc1611s">
|
|
100
126
|
<p>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 (<code>0x38 + 2n</code>) 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 <code>payload.status</code> is not available. The module runs from 3.3 V only.</p>
|
|
101
127
|
<p>Drawing commands change a framebuffer; with <em>Auto-show</em> the framebuffer is sent after every message that draws, otherwise send <code>{ show: true }</code>. NACKs of the chip are retried by the driver.</p>
|
|
102
128
|
|
package/nodes/uc1611s/uc1611s.js
CHANGED
|
@@ -6,10 +6,10 @@ module.exports = function(RED) {
|
|
|
6
6
|
const { GpioOutputPin } = require('periph/src/connection/output_pin');
|
|
7
7
|
const U = require('periph/src/chips/display/uc1611s');
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function UC1611sDeviceNode(config) {
|
|
10
10
|
RED.nodes.createNode(this, config);
|
|
11
11
|
const node = this;
|
|
12
|
-
|
|
12
|
+
node.transport = config.transport;
|
|
13
13
|
|
|
14
14
|
try {
|
|
15
15
|
const width = parseInt(config.width || 240, 10);
|
|
@@ -40,6 +40,21 @@ module.exports = function(RED) {
|
|
|
40
40
|
node.error('UC1611s init failed: ' + e.message);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
node.on('close', function() {
|
|
44
|
+
if (node.command) node.command.close();
|
|
45
|
+
if (node.data) node.data.close();
|
|
46
|
+
if (node.connection) node.connection.close();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
RED.nodes.registerType('uc1611s-device', UC1611sDeviceNode);
|
|
50
|
+
|
|
51
|
+
function UC1611sReadNode(config) {
|
|
52
|
+
RED.nodes.createNode(this, config);
|
|
53
|
+
const node = this;
|
|
54
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
55
|
+
|
|
56
|
+
const autoShow = config.autoShow !== false && config.autoShow !== 'false';
|
|
57
|
+
|
|
43
58
|
// Messages are handled one at a time: two overlapping transfers would corrupt each other.
|
|
44
59
|
let queue = Promise.resolve();
|
|
45
60
|
node.on('input', function(msg, send, done) {
|
|
@@ -47,8 +62,8 @@ module.exports = function(RED) {
|
|
|
47
62
|
});
|
|
48
63
|
|
|
49
64
|
async function handle(msg, send, done) {
|
|
50
|
-
if (!
|
|
51
|
-
const d =
|
|
65
|
+
if (!deviceNode.driver) { done(); return; }
|
|
66
|
+
const d = deviceNode.driver;
|
|
52
67
|
let p = msg.payload;
|
|
53
68
|
try {
|
|
54
69
|
await d.ready();
|
|
@@ -66,7 +81,7 @@ module.exports = function(RED) {
|
|
|
66
81
|
if (p.flip) await d.setFlip(!!p.flip.x, !!p.flip.y);
|
|
67
82
|
if (p.show || (draw && autoShow)) await d.show();
|
|
68
83
|
if (p.status) {
|
|
69
|
-
if (
|
|
84
|
+
if (deviceNode.transport === 'spi') throw new Error('status read is not available over SPI');
|
|
70
85
|
const s = await d.readStatus();
|
|
71
86
|
send({ payload: { status: [s[0], s[1], s[2]] } });
|
|
72
87
|
}
|
|
@@ -77,12 +92,6 @@ module.exports = function(RED) {
|
|
|
77
92
|
done(e);
|
|
78
93
|
}
|
|
79
94
|
}
|
|
80
|
-
|
|
81
|
-
node.on('close', function() {
|
|
82
|
-
if (node.command) node.command.close();
|
|
83
|
-
if (node.data) node.data.close();
|
|
84
|
-
if (node.connection) node.connection.close();
|
|
85
|
-
});
|
|
86
95
|
}
|
|
87
|
-
RED.nodes.registerType('
|
|
96
|
+
RED.nodes.registerType('uc1611s', UC1611sReadNode);
|
|
88
97
|
};
|
package/nodes/uc8159/uc8159.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('uc8159-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
spiBus: { value: '0', required: true, validate: RED.validators.number() },
|
|
@@ -14,58 +14,84 @@
|
|
|
14
14
|
busyTimeout: { value: '60000', required: true, validate: RED.validators.number() },
|
|
15
15
|
autoShow: { value: false }
|
|
16
16
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
label: function() { return this.name || 'UC8159'; },
|
|
21
|
-
paletteLabel: 'UC8159'
|
|
17
|
+
label: function() {
|
|
18
|
+
return this.name || 'UC8159';
|
|
19
|
+
}
|
|
22
20
|
});
|
|
23
21
|
</script>
|
|
24
22
|
|
|
25
|
-
<script type="text/html" data-template-name="
|
|
23
|
+
<script type="text/html" data-template-name="uc8159-device">
|
|
26
24
|
<div class="form-row">
|
|
27
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
28
|
-
<input type="text" id="node-input-name" placeholder="UC8159">
|
|
25
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
26
|
+
<input type="text" id="node-config-input-name" placeholder="UC8159">
|
|
29
27
|
</div>
|
|
30
28
|
<div class="form-row">
|
|
31
|
-
<label for="node-input-spiBus"><i class="fa fa-microchip"></i> SPI bus</label>
|
|
32
|
-
<input type="number" id="node-input-spiBus" min="0" style="width:70px">
|
|
33
|
-
chip select <input type="number" id="node-input-spiDevice" min="0" style="width:70px">
|
|
29
|
+
<label for="node-config-input-spiBus"><i class="fa fa-microchip"></i> SPI bus</label>
|
|
30
|
+
<input type="number" id="node-config-input-spiBus" min="0" style="width:70px">
|
|
31
|
+
chip select <input type="number" id="node-config-input-spiDevice" min="0" style="width:70px">
|
|
34
32
|
</div>
|
|
35
33
|
<div class="form-row">
|
|
36
|
-
<label for="node-input-gpioChip">GPIO chip</label>
|
|
37
|
-
<input type="number" id="node-input-gpioChip" min="0" style="width:70px">
|
|
34
|
+
<label for="node-config-input-gpioChip">GPIO chip</label>
|
|
35
|
+
<input type="number" id="node-config-input-gpioChip" min="0" style="width:70px">
|
|
38
36
|
</div>
|
|
39
37
|
<div class="form-row">
|
|
40
|
-
<label for="node-input-dcPin">D/C# line</label>
|
|
41
|
-
<input type="number" id="node-input-dcPin" min="0" style="width:70px">
|
|
38
|
+
<label for="node-config-input-dcPin">D/C# line</label>
|
|
39
|
+
<input type="number" id="node-config-input-dcPin" min="0" style="width:70px">
|
|
42
40
|
</div>
|
|
43
41
|
<div class="form-row">
|
|
44
|
-
<label for="node-input-resPin">RES# line</label>
|
|
45
|
-
<input type="number" id="node-input-resPin" min="0" style="width:70px">
|
|
42
|
+
<label for="node-config-input-resPin">RES# line</label>
|
|
43
|
+
<input type="number" id="node-config-input-resPin" min="0" style="width:70px">
|
|
46
44
|
</div>
|
|
47
45
|
<div class="form-row">
|
|
48
|
-
<label for="node-input-busyPin">BUSY line</label>
|
|
49
|
-
<input type="number" id="node-input-busyPin" min="0" style="width:70px">
|
|
46
|
+
<label for="node-config-input-busyPin">BUSY line</label>
|
|
47
|
+
<input type="number" id="node-config-input-busyPin" min="0" style="width:70px">
|
|
50
48
|
</div>
|
|
51
49
|
<div class="form-row">
|
|
52
|
-
<label for="node-input-wireMode">Wire mode</label>
|
|
53
|
-
<select id="node-input-wireMode" style="width:260px">
|
|
50
|
+
<label for="node-config-input-wireMode">Wire mode</label>
|
|
51
|
+
<select id="node-config-input-wireMode" style="width:260px">
|
|
54
52
|
<option value="simplex">Simplex (MOSI to DIN, write only)</option>
|
|
55
53
|
<option value="pin">Half-duplex pin (MOSI-resistor-MISO)</option>
|
|
56
54
|
</select>
|
|
57
55
|
</div>
|
|
58
56
|
<div class="form-row">
|
|
59
|
-
<label for="node-input-busyTimeout">BUSY timeout (ms)</label>
|
|
60
|
-
<input type="number" id="node-input-busyTimeout" min="0" style="width:100px">
|
|
57
|
+
<label for="node-config-input-busyTimeout">BUSY timeout (ms)</label>
|
|
58
|
+
<input type="number" id="node-config-input-busyTimeout" min="0" style="width:100px">
|
|
59
|
+
</div>
|
|
60
|
+
<div class="form-row">
|
|
61
|
+
<label for="node-config-input-autoShow">Auto-show</label>
|
|
62
|
+
<input type="checkbox" id="node-config-input-autoShow" style="width:auto"> refresh after every drawing message
|
|
63
|
+
</div>
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<!-- Read node -->
|
|
67
|
+
<script type="text/javascript">
|
|
68
|
+
RED.nodes.registerType('uc8159', {
|
|
69
|
+
category: 'Peripheral',
|
|
70
|
+
color: '#C084FC',
|
|
71
|
+
defaults: {
|
|
72
|
+
name: { value: '' },
|
|
73
|
+
device: { value: '', type: 'uc8159-device', required: true }
|
|
74
|
+
},
|
|
75
|
+
inputs: 1,
|
|
76
|
+
outputs: 1,
|
|
77
|
+
icon: 'font-awesome/fa-television',
|
|
78
|
+
label: function() { return this.name || 'UC8159'; },
|
|
79
|
+
paletteLabel: 'UC8159'
|
|
80
|
+
});
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<script type="text/html" data-template-name="uc8159">
|
|
84
|
+
<div class="form-row">
|
|
85
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
86
|
+
<input type="text" id="node-input-name" placeholder="UC8159">
|
|
61
87
|
</div>
|
|
62
88
|
<div class="form-row">
|
|
63
|
-
<label for="node-input-
|
|
64
|
-
<input type="
|
|
89
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
90
|
+
<input type="text" id="node-input-device">
|
|
65
91
|
</div>
|
|
66
92
|
</script>
|
|
67
93
|
|
|
68
|
-
<script type="text/html" data-help-name="
|
|
94
|
+
<script type="text/html" data-help-name="uc8159">
|
|
69
95
|
<p>Draws on a UC8159 seven-colour e-paper panel (600 x 448, e.g. Waveshare 5.65inch e-Paper (F)) over SPI. Drawing messages change the framebuffer only; <code>show</code> sends it and refreshes the panel, which blocks the node for about 30 seconds.</p>
|
|
70
96
|
|
|
71
97
|
<h3>Inputs</h3>
|
package/nodes/uc8159/uc8159.js
CHANGED
|
@@ -18,7 +18,7 @@ module.exports = function(RED) {
|
|
|
18
18
|
return c;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function
|
|
21
|
+
function UC8159DeviceNode(config) {
|
|
22
22
|
RED.nodes.createNode(this, config);
|
|
23
23
|
const node = this;
|
|
24
24
|
node.autoShow = !!config.autoShow;
|
|
@@ -43,9 +43,20 @@ module.exports = function(RED) {
|
|
|
43
43
|
node.error('UC8159 init failed: ' + e.message);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
node.on('close', function() {
|
|
47
|
+
if (node.connection) node.connection.close();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
RED.nodes.registerType('uc8159-device', UC8159DeviceNode);
|
|
51
|
+
|
|
52
|
+
function UC8159ReadNode(config) {
|
|
53
|
+
RED.nodes.createNode(this, config);
|
|
54
|
+
const node = this;
|
|
55
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
56
|
+
|
|
46
57
|
node.on('input', async function(msg, send, done) {
|
|
47
|
-
if (!
|
|
48
|
-
const d =
|
|
58
|
+
if (!deviceNode.driver) { done(); return; }
|
|
59
|
+
const d = deviceNode.driver;
|
|
49
60
|
const p = msg.payload || {};
|
|
50
61
|
try {
|
|
51
62
|
if (p.clear !== undefined) d.clear(color(p.clear, WHITE));
|
|
@@ -63,7 +74,7 @@ module.exports = function(RED) {
|
|
|
63
74
|
d.blit(b.x, b.y, Buffer.from(b.data), b.w, b.h, color(b.color));
|
|
64
75
|
}
|
|
65
76
|
if (p.wake) await d.wake();
|
|
66
|
-
if (p.show || (
|
|
77
|
+
if (p.show || (deviceNode.autoShow && (p.clear !== undefined || p.pixel || p.line || p.rect || p.bitmap))) {
|
|
67
78
|
node.status({ fill: 'yellow', shape: 'ring', text: 'refreshing' });
|
|
68
79
|
await d.show();
|
|
69
80
|
node.status({});
|
|
@@ -87,10 +98,6 @@ module.exports = function(RED) {
|
|
|
87
98
|
done(e);
|
|
88
99
|
}
|
|
89
100
|
});
|
|
90
|
-
|
|
91
|
-
node.on('close', function() {
|
|
92
|
-
if (node.connection) node.connection.close();
|
|
93
|
-
});
|
|
94
101
|
}
|
|
95
|
-
RED.nodes.registerType('
|
|
102
|
+
RED.nodes.registerType('uc8159', UC8159ReadNode);
|
|
96
103
|
};
|