node-red-contrib-periph-display 1.5.0 → 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 +21 -12
- 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 +1 -1
- package/index.js +0 -11
|
@@ -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('ssd1305-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
transport: { value: 'i2c' },
|
|
@@ -14,74 +14,100 @@
|
|
|
14
14
|
resPin: { value: '17', validate: RED.validators.number() },
|
|
15
15
|
width: { value: '128', required: true, validate: RED.validators.number() },
|
|
16
16
|
height: { value: '64', required: true, validate: RED.validators.number() },
|
|
17
|
-
columnOffset: { value: '4', required: true, validate: RED.validators.number() }
|
|
18
|
-
|
|
17
|
+
columnOffset: { value: '4', required: true, validate: RED.validators.number() }
|
|
18
|
+
},
|
|
19
|
+
label: function() {
|
|
20
|
+
return this.name || 'SSD1305';
|
|
19
21
|
},
|
|
20
|
-
inputs: 1,
|
|
21
|
-
outputs: 1,
|
|
22
|
-
icon: 'font-awesome/fa-television',
|
|
23
|
-
label: function() { return this.name || 'SSD1305'; },
|
|
24
|
-
paletteLabel: 'SSD1305',
|
|
25
22
|
oneditprepare: function() {
|
|
26
23
|
function show() {
|
|
27
|
-
const spi = $('#node-input-transport').val() === 'spi';
|
|
24
|
+
const spi = $('#node-config-input-transport').val() === 'spi';
|
|
28
25
|
$('.ssd1305-i2c').toggle(!spi);
|
|
29
26
|
$('.ssd1305-spi').toggle(spi);
|
|
30
27
|
}
|
|
31
|
-
$('#node-input-transport').on('change', show);
|
|
28
|
+
$('#node-config-input-transport').on('change', show);
|
|
32
29
|
show();
|
|
33
30
|
}
|
|
34
31
|
});
|
|
35
32
|
</script>
|
|
36
33
|
|
|
37
|
-
<script type="text/html" data-template-name="
|
|
34
|
+
<script type="text/html" data-template-name="ssd1305-device">
|
|
38
35
|
<div class="form-row">
|
|
39
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
40
|
-
<input type="text" id="node-input-name" placeholder="SSD1305">
|
|
36
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
37
|
+
<input type="text" id="node-config-input-name" placeholder="SSD1305">
|
|
41
38
|
</div>
|
|
42
39
|
<div class="form-row">
|
|
43
|
-
<label for="node-input-transport"><i class="fa fa-exchange"></i> Interface</label>
|
|
44
|
-
<select id="node-input-transport" style="width:auto">
|
|
40
|
+
<label for="node-config-input-transport"><i class="fa fa-exchange"></i> Interface</label>
|
|
41
|
+
<select id="node-config-input-transport" style="width:auto">
|
|
45
42
|
<option value="i2c">I2C</option>
|
|
46
43
|
<option value="spi">4-wire SPI</option>
|
|
47
44
|
</select>
|
|
48
45
|
</div>
|
|
49
46
|
<div class="form-row ssd1305-i2c">
|
|
50
|
-
<label for="node-input-i2cBus"><i class="fa fa-microchip"></i> I2C bus</label>
|
|
51
|
-
<input type="number" id="node-input-i2cBus" min="0" style="width:70px">
|
|
47
|
+
<label for="node-config-input-i2cBus"><i class="fa fa-microchip"></i> I2C bus</label>
|
|
48
|
+
<input type="number" id="node-config-input-i2cBus" min="0" style="width:70px">
|
|
52
49
|
</div>
|
|
53
50
|
<div class="form-row ssd1305-i2c">
|
|
54
|
-
<label for="node-input-address">Address</label>
|
|
55
|
-
<select id="node-input-address" style="width:auto">
|
|
51
|
+
<label for="node-config-input-address">Address</label>
|
|
52
|
+
<select id="node-config-input-address" style="width:auto">
|
|
56
53
|
<option value="0x3C">0x3C (SA0 = low)</option>
|
|
57
54
|
<option value="0x3D">0x3D (SA0 = high)</option>
|
|
58
55
|
</select>
|
|
59
56
|
</div>
|
|
60
57
|
<div class="form-row ssd1305-spi">
|
|
61
|
-
<label for="node-input-spiBus"><i class="fa fa-microchip"></i> SPI bus / device</label>
|
|
62
|
-
<input type="number" id="node-input-spiBus" min="0" style="width:70px"> /
|
|
63
|
-
<input type="number" id="node-input-spiDevice" min="0" style="width:70px">
|
|
58
|
+
<label for="node-config-input-spiBus"><i class="fa fa-microchip"></i> SPI bus / device</label>
|
|
59
|
+
<input type="number" id="node-config-input-spiBus" min="0" style="width:70px"> /
|
|
60
|
+
<input type="number" id="node-config-input-spiDevice" min="0" style="width:70px">
|
|
64
61
|
</div>
|
|
65
62
|
<div class="form-row ssd1305-spi">
|
|
66
|
-
<label for="node-input-gpioChip">GPIO chip</label>
|
|
67
|
-
<input type="number" id="node-input-gpioChip" min="0" style="width:70px">
|
|
63
|
+
<label for="node-config-input-gpioChip">GPIO chip</label>
|
|
64
|
+
<input type="number" id="node-config-input-gpioChip" min="0" style="width:70px">
|
|
68
65
|
</div>
|
|
69
66
|
<div class="form-row ssd1305-spi">
|
|
70
|
-
<label for="node-input-dcPin">D/C line</label>
|
|
71
|
-
<input type="number" id="node-input-dcPin" min="0" style="width:70px">
|
|
67
|
+
<label for="node-config-input-dcPin">D/C line</label>
|
|
68
|
+
<input type="number" id="node-config-input-dcPin" min="0" style="width:70px">
|
|
72
69
|
</div>
|
|
73
70
|
<div class="form-row ssd1305-spi">
|
|
74
|
-
<label for="node-input-resPin">RES line</label>
|
|
75
|
-
<input type="number" id="node-input-resPin" min="0" style="width:70px">
|
|
71
|
+
<label for="node-config-input-resPin">RES line</label>
|
|
72
|
+
<input type="number" id="node-config-input-resPin" min="0" style="width:70px">
|
|
73
|
+
</div>
|
|
74
|
+
<div class="form-row">
|
|
75
|
+
<label for="node-config-input-width">Size</label>
|
|
76
|
+
<input type="number" id="node-config-input-width" min="1" max="132" style="width:70px"> x
|
|
77
|
+
<input type="number" id="node-config-input-height" min="16" max="64" step="8" style="width:70px">
|
|
76
78
|
</div>
|
|
77
79
|
<div class="form-row">
|
|
78
|
-
<label for="node-input-
|
|
79
|
-
<input type="number" id="node-input-
|
|
80
|
-
|
|
80
|
+
<label for="node-config-input-columnOffset">Column offset</label>
|
|
81
|
+
<input type="number" id="node-config-input-columnOffset" min="0" max="131" style="width:70px">
|
|
82
|
+
</div>
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<!-- Read node -->
|
|
86
|
+
<script type="text/javascript">
|
|
87
|
+
RED.nodes.registerType('ssd1305', {
|
|
88
|
+
category: 'Peripheral',
|
|
89
|
+
color: '#C084FC',
|
|
90
|
+
defaults: {
|
|
91
|
+
name: { value: '' },
|
|
92
|
+
device: { value: '', type: 'ssd1305-device', required: true },
|
|
93
|
+
autoShow: { value: true }
|
|
94
|
+
},
|
|
95
|
+
inputs: 1,
|
|
96
|
+
outputs: 1,
|
|
97
|
+
icon: 'font-awesome/fa-television',
|
|
98
|
+
label: function() { return this.name || 'SSD1305'; },
|
|
99
|
+
paletteLabel: 'SSD1305'
|
|
100
|
+
});
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<script type="text/html" data-template-name="ssd1305">
|
|
104
|
+
<div class="form-row">
|
|
105
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
106
|
+
<input type="text" id="node-input-name" placeholder="SSD1305">
|
|
81
107
|
</div>
|
|
82
108
|
<div class="form-row">
|
|
83
|
-
<label for="node-input-
|
|
84
|
-
<input type="
|
|
109
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
110
|
+
<input type="text" id="node-input-device">
|
|
85
111
|
</div>
|
|
86
112
|
<div class="form-row">
|
|
87
113
|
<label for="node-input-autoShow">Auto-show</label>
|
|
@@ -89,7 +115,7 @@
|
|
|
89
115
|
</div>
|
|
90
116
|
</script>
|
|
91
117
|
|
|
92
|
-
<script type="text/html" data-help-name="
|
|
118
|
+
<script type="text/html" data-help-name="ssd1305">
|
|
93
119
|
<p>Draws on an SSD1305 monochrome OLED (132 x 64 RAM, typically a 1.3" 128 x 64 module) over I2C (<code>0x3C</code> / <code>0x3D</code>) or 4-wire SPI. On SPI the node needs the SPI bus / chip-select device and the GPIO lines for D/C and RES; <code>payload.status</code> is not available. 128-pixel-wide modules usually show RAM columns 4..131, hence the default column offset of 4 (use 0 for a true 132-column panel, 2 for some panels).</p>
|
|
94
120
|
<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>.</p>
|
|
95
121
|
|
package/nodes/ssd1305/ssd1305.js
CHANGED
|
@@ -6,10 +6,10 @@ module.exports = function(RED) {
|
|
|
6
6
|
const { GpioOutputPin } = require('periph/src/connection/output_pin');
|
|
7
7
|
const S = require('periph/src/chips/display/ssd1305');
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function SSD1305DeviceNode(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 || 128, 10);
|
|
@@ -38,6 +38,20 @@ module.exports = function(RED) {
|
|
|
38
38
|
node.error('SSD1305 init failed: ' + e.message);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
node.on('close', function() {
|
|
42
|
+
if (node.i2c) node.i2c.close();
|
|
43
|
+
if (node.connection) node.connection.close();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
RED.nodes.registerType('ssd1305-device', SSD1305DeviceNode);
|
|
47
|
+
|
|
48
|
+
function SSD1305ReadNode(config) {
|
|
49
|
+
RED.nodes.createNode(this, config);
|
|
50
|
+
const node = this;
|
|
51
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
52
|
+
|
|
53
|
+
const autoShow = config.autoShow !== false && config.autoShow !== 'false';
|
|
54
|
+
|
|
41
55
|
// Messages are handled one at a time: two overlapping transfers would corrupt each other.
|
|
42
56
|
let queue = Promise.resolve();
|
|
43
57
|
node.on('input', function(msg, send, done) {
|
|
@@ -45,8 +59,8 @@ module.exports = function(RED) {
|
|
|
45
59
|
});
|
|
46
60
|
|
|
47
61
|
async function handle(msg, send, done) {
|
|
48
|
-
if (!
|
|
49
|
-
const d =
|
|
62
|
+
if (!deviceNode.driver) { done(); return; }
|
|
63
|
+
const d = deviceNode.driver;
|
|
50
64
|
let p = msg.payload;
|
|
51
65
|
try {
|
|
52
66
|
await d.ready();
|
|
@@ -78,7 +92,7 @@ module.exports = function(RED) {
|
|
|
78
92
|
}
|
|
79
93
|
if (p.show || (draw && autoShow)) await d.show();
|
|
80
94
|
if (p.status) {
|
|
81
|
-
if (
|
|
95
|
+
if (deviceNode.transport === 'spi') throw new Error('status read is not available over SPI');
|
|
82
96
|
send({ payload: { status: await d.readStatus() } });
|
|
83
97
|
}
|
|
84
98
|
node.status({ fill: 'green', shape: 'dot', text: 'ready' });
|
|
@@ -88,11 +102,6 @@ module.exports = function(RED) {
|
|
|
88
102
|
done(e);
|
|
89
103
|
}
|
|
90
104
|
}
|
|
91
|
-
|
|
92
|
-
node.on('close', function() {
|
|
93
|
-
if (node.i2c) node.i2c.close();
|
|
94
|
-
if (node.connection) node.connection.close();
|
|
95
|
-
});
|
|
96
105
|
}
|
|
97
|
-
RED.nodes.registerType('
|
|
106
|
+
RED.nodes.registerType('ssd1305', SSD1305ReadNode);
|
|
98
107
|
};
|
|
@@ -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('ssd1306-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
transport: { value: 'i2c' },
|
|
@@ -14,74 +14,100 @@
|
|
|
14
14
|
resPin: { value: '17', validate: RED.validators.number() },
|
|
15
15
|
width: { value: '128', required: true, validate: RED.validators.number() },
|
|
16
16
|
height: { value: '64', required: true, validate: RED.validators.number() },
|
|
17
|
-
externalVcc: { value: false }
|
|
18
|
-
|
|
17
|
+
externalVcc: { value: false }
|
|
18
|
+
},
|
|
19
|
+
label: function() {
|
|
20
|
+
return this.name || 'SSD1306';
|
|
19
21
|
},
|
|
20
|
-
inputs: 1,
|
|
21
|
-
outputs: 0,
|
|
22
|
-
icon: 'font-awesome/fa-television',
|
|
23
|
-
label: function() { return this.name || 'SSD1306'; },
|
|
24
|
-
paletteLabel: 'SSD1306',
|
|
25
22
|
oneditprepare: function() {
|
|
26
23
|
function show() {
|
|
27
|
-
const spi = $('#node-input-transport').val() === 'spi';
|
|
24
|
+
const spi = $('#node-config-input-transport').val() === 'spi';
|
|
28
25
|
$('.ssd1306-i2c').toggle(!spi);
|
|
29
26
|
$('.ssd1306-spi').toggle(spi);
|
|
30
27
|
}
|
|
31
|
-
$('#node-input-transport').on('change', show);
|
|
28
|
+
$('#node-config-input-transport').on('change', show);
|
|
32
29
|
show();
|
|
33
30
|
}
|
|
34
31
|
});
|
|
35
32
|
</script>
|
|
36
33
|
|
|
37
|
-
<script type="text/html" data-template-name="
|
|
34
|
+
<script type="text/html" data-template-name="ssd1306-device">
|
|
38
35
|
<div class="form-row">
|
|
39
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
40
|
-
<input type="text" id="node-input-name" placeholder="SSD1306">
|
|
36
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
37
|
+
<input type="text" id="node-config-input-name" placeholder="SSD1306">
|
|
41
38
|
</div>
|
|
42
39
|
<div class="form-row">
|
|
43
|
-
<label for="node-input-transport"><i class="fa fa-exchange"></i> Interface</label>
|
|
44
|
-
<select id="node-input-transport" style="width:auto">
|
|
40
|
+
<label for="node-config-input-transport"><i class="fa fa-exchange"></i> Interface</label>
|
|
41
|
+
<select id="node-config-input-transport" style="width:auto">
|
|
45
42
|
<option value="i2c">I2C</option>
|
|
46
43
|
<option value="spi">4-wire SPI</option>
|
|
47
44
|
</select>
|
|
48
45
|
</div>
|
|
49
46
|
<div class="form-row ssd1306-i2c">
|
|
50
|
-
<label for="node-input-i2cBus"><i class="fa fa-microchip"></i> I2C bus</label>
|
|
51
|
-
<input type="number" id="node-input-i2cBus" min="0" style="width:70px">
|
|
47
|
+
<label for="node-config-input-i2cBus"><i class="fa fa-microchip"></i> I2C bus</label>
|
|
48
|
+
<input type="number" id="node-config-input-i2cBus" min="0" style="width:70px">
|
|
52
49
|
</div>
|
|
53
50
|
<div class="form-row ssd1306-i2c">
|
|
54
|
-
<label for="node-input-address">Address</label>
|
|
55
|
-
<select id="node-input-address" style="width:auto">
|
|
51
|
+
<label for="node-config-input-address">Address</label>
|
|
52
|
+
<select id="node-config-input-address" style="width:auto">
|
|
56
53
|
<option value="0x3C">0x3C (SA0 = low)</option>
|
|
57
54
|
<option value="0x3D">0x3D (SA0 = high)</option>
|
|
58
55
|
</select>
|
|
59
56
|
</div>
|
|
60
57
|
<div class="form-row ssd1306-spi">
|
|
61
|
-
<label for="node-input-spiBus"><i class="fa fa-microchip"></i> SPI bus / device</label>
|
|
62
|
-
<input type="number" id="node-input-spiBus" min="0" style="width:70px"> /
|
|
63
|
-
<input type="number" id="node-input-spiDevice" min="0" style="width:70px">
|
|
58
|
+
<label for="node-config-input-spiBus"><i class="fa fa-microchip"></i> SPI bus / device</label>
|
|
59
|
+
<input type="number" id="node-config-input-spiBus" min="0" style="width:70px"> /
|
|
60
|
+
<input type="number" id="node-config-input-spiDevice" min="0" style="width:70px">
|
|
64
61
|
</div>
|
|
65
62
|
<div class="form-row ssd1306-spi">
|
|
66
|
-
<label for="node-input-gpioChip">GPIO chip</label>
|
|
67
|
-
<input type="number" id="node-input-gpioChip" min="0" style="width:70px">
|
|
63
|
+
<label for="node-config-input-gpioChip">GPIO chip</label>
|
|
64
|
+
<input type="number" id="node-config-input-gpioChip" min="0" style="width:70px">
|
|
68
65
|
</div>
|
|
69
66
|
<div class="form-row ssd1306-spi">
|
|
70
|
-
<label for="node-input-dcPin">D/C line</label>
|
|
71
|
-
<input type="number" id="node-input-dcPin" min="0" style="width:70px">
|
|
67
|
+
<label for="node-config-input-dcPin">D/C line</label>
|
|
68
|
+
<input type="number" id="node-config-input-dcPin" min="0" style="width:70px">
|
|
72
69
|
</div>
|
|
73
70
|
<div class="form-row ssd1306-spi">
|
|
74
|
-
<label for="node-input-resPin">RES line</label>
|
|
75
|
-
<input type="number" id="node-input-resPin" min="0" style="width:70px">
|
|
71
|
+
<label for="node-config-input-resPin">RES line</label>
|
|
72
|
+
<input type="number" id="node-config-input-resPin" min="0" style="width:70px">
|
|
73
|
+
</div>
|
|
74
|
+
<div class="form-row">
|
|
75
|
+
<label for="node-config-input-width">Size</label>
|
|
76
|
+
<input type="number" id="node-config-input-width" min="1" max="128" style="width:70px"> x
|
|
77
|
+
<input type="number" id="node-config-input-height" min="16" max="64" step="8" style="width:70px">
|
|
76
78
|
</div>
|
|
77
79
|
<div class="form-row">
|
|
78
|
-
<label for="node-input-
|
|
79
|
-
<input type="
|
|
80
|
-
|
|
80
|
+
<label for="node-config-input-externalVcc">External VCC</label>
|
|
81
|
+
<input type="checkbox" id="node-config-input-externalVcc" style="width:auto; vertical-align:top">
|
|
82
|
+
</div>
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<!-- Read node -->
|
|
86
|
+
<script type="text/javascript">
|
|
87
|
+
RED.nodes.registerType('ssd1306', {
|
|
88
|
+
category: 'Peripheral',
|
|
89
|
+
color: '#C084FC',
|
|
90
|
+
defaults: {
|
|
91
|
+
name: { value: '' },
|
|
92
|
+
device: { value: '', type: 'ssd1306-device', required: true },
|
|
93
|
+
autoShow: { value: true }
|
|
94
|
+
},
|
|
95
|
+
inputs: 1,
|
|
96
|
+
outputs: 0,
|
|
97
|
+
icon: 'font-awesome/fa-television',
|
|
98
|
+
label: function() { return this.name || 'SSD1306'; },
|
|
99
|
+
paletteLabel: 'SSD1306'
|
|
100
|
+
});
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<script type="text/html" data-template-name="ssd1306">
|
|
104
|
+
<div class="form-row">
|
|
105
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
106
|
+
<input type="text" id="node-input-name" placeholder="SSD1306">
|
|
81
107
|
</div>
|
|
82
108
|
<div class="form-row">
|
|
83
|
-
<label for="node-input-
|
|
84
|
-
<input type="
|
|
109
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
110
|
+
<input type="text" id="node-input-device">
|
|
85
111
|
</div>
|
|
86
112
|
<div class="form-row">
|
|
87
113
|
<label for="node-input-autoShow">Auto-show</label>
|
|
@@ -89,7 +115,7 @@
|
|
|
89
115
|
</div>
|
|
90
116
|
</script>
|
|
91
117
|
|
|
92
|
-
<script type="text/html" data-help-name="
|
|
118
|
+
<script type="text/html" data-help-name="ssd1306">
|
|
93
119
|
<p>Draws on an SSD1306 monochrome OLED (128 x 64 RAM, typically a 0.96" 128 x 64 or 128 x 32 module) over I2C (<code>0x3C</code> / <code>0x3D</code>) or 4-wire SPI. On SPI the node needs the SPI bus / chip-select device and the GPIO lines for D/C and RES. The chip cannot be read, so there is no status output. <em>External VCC</em> keeps the internal charge pump off for boards that supply the OLED voltage themselves.</p>
|
|
94
120
|
<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>.</p>
|
|
95
121
|
|
package/nodes/ssd1306/ssd1306.js
CHANGED
|
@@ -6,11 +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/ssd1306');
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function SSD1306DeviceNode(config) {
|
|
10
10
|
RED.nodes.createNode(this, config);
|
|
11
11
|
const node = this;
|
|
12
|
-
const autoShow = config.autoShow !== false && config.autoShow !== 'false';
|
|
13
|
-
|
|
14
12
|
try {
|
|
15
13
|
const width = parseInt(config.width || 128, 10);
|
|
16
14
|
const height = parseInt(config.height || 64, 10);
|
|
@@ -38,6 +36,20 @@ module.exports = function(RED) {
|
|
|
38
36
|
node.error('SSD1306 init failed: ' + e.message);
|
|
39
37
|
}
|
|
40
38
|
|
|
39
|
+
node.on('close', function() {
|
|
40
|
+
if (node.i2c) node.i2c.close();
|
|
41
|
+
if (node.connection) node.connection.close();
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
RED.nodes.registerType('ssd1306-device', SSD1306DeviceNode);
|
|
45
|
+
|
|
46
|
+
function SSD1306ReadNode(config) {
|
|
47
|
+
RED.nodes.createNode(this, config);
|
|
48
|
+
const node = this;
|
|
49
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
50
|
+
|
|
51
|
+
const autoShow = config.autoShow !== false && config.autoShow !== 'false';
|
|
52
|
+
|
|
41
53
|
// Messages are handled one at a time: two overlapping transfers would corrupt each other.
|
|
42
54
|
let queue = Promise.resolve();
|
|
43
55
|
node.on('input', function(msg, send, done) {
|
|
@@ -45,8 +57,8 @@ module.exports = function(RED) {
|
|
|
45
57
|
});
|
|
46
58
|
|
|
47
59
|
async function handle(msg, send, done) {
|
|
48
|
-
if (!
|
|
49
|
-
const d =
|
|
60
|
+
if (!deviceNode.driver) { done(); return; }
|
|
61
|
+
const d = deviceNode.driver;
|
|
50
62
|
let p = msg.payload;
|
|
51
63
|
try {
|
|
52
64
|
await d.ready();
|
|
@@ -82,11 +94,6 @@ module.exports = function(RED) {
|
|
|
82
94
|
done(e);
|
|
83
95
|
}
|
|
84
96
|
}
|
|
85
|
-
|
|
86
|
-
node.on('close', function() {
|
|
87
|
-
if (node.i2c) node.i2c.close();
|
|
88
|
-
if (node.connection) node.connection.close();
|
|
89
|
-
});
|
|
90
97
|
}
|
|
91
|
-
RED.nodes.registerType('
|
|
98
|
+
RED.nodes.registerType('ssd1306', SSD1306ReadNode);
|
|
92
99
|
};
|
|
@@ -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('ssd1331-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
spiBus: { value: '0', required: true, validate: RED.validators.number() },
|
|
@@ -11,43 +11,69 @@
|
|
|
11
11
|
resPin: { value: '17', required: true, validate: RED.validators.number() },
|
|
12
12
|
autoShow: { value: false }
|
|
13
13
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
label: function() { return this.name || 'SSD1331'; },
|
|
18
|
-
paletteLabel: 'SSD1331'
|
|
14
|
+
label: function() {
|
|
15
|
+
return this.name || 'SSD1331';
|
|
16
|
+
}
|
|
19
17
|
});
|
|
20
18
|
</script>
|
|
21
19
|
|
|
22
|
-
<script type="text/html" data-template-name="
|
|
20
|
+
<script type="text/html" data-template-name="ssd1331-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="SSD1331">
|
|
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="SSD1331">
|
|
24
|
+
</div>
|
|
25
|
+
<div class="form-row">
|
|
26
|
+
<label for="node-config-input-spiBus"><i class="fa fa-microchip"></i> SPI bus</label>
|
|
27
|
+
<input type="number" id="node-config-input-spiBus" min="0" style="width:70px">
|
|
28
|
+
chip select <input type="number" id="node-config-input-spiDevice" min="0" style="width:70px">
|
|
26
29
|
</div>
|
|
27
30
|
<div class="form-row">
|
|
28
|
-
<label for="node-input-
|
|
29
|
-
<input type="number" id="node-input-
|
|
30
|
-
chip select <input type="number" id="node-input-spiDevice" min="0" style="width:70px">
|
|
31
|
+
<label for="node-config-input-gpioChip">GPIO chip</label>
|
|
32
|
+
<input type="number" id="node-config-input-gpioChip" min="0" style="width:70px">
|
|
31
33
|
</div>
|
|
32
34
|
<div class="form-row">
|
|
33
|
-
<label for="node-input-
|
|
34
|
-
<input type="number" id="node-input-
|
|
35
|
+
<label for="node-config-input-dcPin">D/C# line</label>
|
|
36
|
+
<input type="number" id="node-config-input-dcPin" min="0" style="width:70px">
|
|
35
37
|
</div>
|
|
36
38
|
<div class="form-row">
|
|
37
|
-
<label for="node-input-
|
|
38
|
-
<input type="number" id="node-input-
|
|
39
|
+
<label for="node-config-input-resPin">RES# line</label>
|
|
40
|
+
<input type="number" id="node-config-input-resPin" min="0" style="width:70px">
|
|
39
41
|
</div>
|
|
40
42
|
<div class="form-row">
|
|
41
|
-
<label for="node-input-
|
|
42
|
-
<input type="
|
|
43
|
+
<label for="node-config-input-autoShow">Auto-show</label>
|
|
44
|
+
<input type="checkbox" id="node-config-input-autoShow" style="width:auto"> send the framebuffer after every drawing message
|
|
45
|
+
</div>
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<!-- Read node -->
|
|
49
|
+
<script type="text/javascript">
|
|
50
|
+
RED.nodes.registerType('ssd1331', {
|
|
51
|
+
category: 'Peripheral',
|
|
52
|
+
color: '#C084FC',
|
|
53
|
+
defaults: {
|
|
54
|
+
name: { value: '' },
|
|
55
|
+
device: { value: '', type: 'ssd1331-device', required: true }
|
|
56
|
+
},
|
|
57
|
+
inputs: 1,
|
|
58
|
+
outputs: 1,
|
|
59
|
+
icon: 'font-awesome/fa-television',
|
|
60
|
+
label: function() { return this.name || 'SSD1331'; },
|
|
61
|
+
paletteLabel: 'SSD1331'
|
|
62
|
+
});
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<script type="text/html" data-template-name="ssd1331">
|
|
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="SSD1331">
|
|
43
69
|
</div>
|
|
44
70
|
<div class="form-row">
|
|
45
|
-
<label for="node-input-
|
|
46
|
-
<input type="
|
|
71
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
72
|
+
<input type="text" id="node-input-device">
|
|
47
73
|
</div>
|
|
48
74
|
</script>
|
|
49
75
|
|
|
50
|
-
<script type="text/html" data-help-name="
|
|
76
|
+
<script type="text/html" data-help-name="ssd1331">
|
|
51
77
|
<p>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; <code>show</code> sends it to the display. The <code>hw*</code> messages use the controller's own drawing engine on the display RAM.</p>
|
|
52
78
|
<p>A colour is a name (<code>black</code>, <code>white</code>, <code>red</code>, <code>green</code>, <code>blue</code>, <code>yellow</code>, <code>cyan</code>, <code>magenta</code>), an RGB565 number, or <code>[r, g, b]</code> with 0..255 components.</p>
|
|
53
79
|
|
package/nodes/ssd1331/ssd1331.js
CHANGED
|
@@ -22,7 +22,7 @@ module.exports = function(RED) {
|
|
|
22
22
|
return v;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
function
|
|
25
|
+
function SSD1331DeviceNode(config) {
|
|
26
26
|
RED.nodes.createNode(this, config);
|
|
27
27
|
const node = this;
|
|
28
28
|
node.autoShow = !!config.autoShow;
|
|
@@ -42,6 +42,17 @@ module.exports = function(RED) {
|
|
|
42
42
|
node.error('SSD1331 init failed: ' + e.message);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
node.on('close', function() {
|
|
46
|
+
if (node.connection) node.connection.close();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
RED.nodes.registerType('ssd1331-device', SSD1331DeviceNode);
|
|
50
|
+
|
|
51
|
+
function SSD1331ReadNode(config) {
|
|
52
|
+
RED.nodes.createNode(this, config);
|
|
53
|
+
const node = this;
|
|
54
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
55
|
+
|
|
45
56
|
// Messages are handled one at a time: two overlapping command streams would corrupt each other.
|
|
46
57
|
let queue = Promise.resolve();
|
|
47
58
|
node.on('input', function(msg, send, done) {
|
|
@@ -49,8 +60,8 @@ module.exports = function(RED) {
|
|
|
49
60
|
});
|
|
50
61
|
|
|
51
62
|
async function handle(msg, send, done) {
|
|
52
|
-
if (!
|
|
53
|
-
const d =
|
|
63
|
+
if (!deviceNode.driver) { done(); return; }
|
|
64
|
+
const d = deviceNode.driver;
|
|
54
65
|
const p = msg.payload || {};
|
|
55
66
|
try {
|
|
56
67
|
if (p.clear !== undefined) d.clear(color(p.clear, S.BLACK));
|
|
@@ -67,7 +78,7 @@ module.exports = function(RED) {
|
|
|
67
78
|
const b = p.bitmap;
|
|
68
79
|
d.blit(b.x, b.y, b.data, b.w, b.h);
|
|
69
80
|
}
|
|
70
|
-
if (p.show || (
|
|
81
|
+
if (p.show || (deviceNode.autoShow && (p.clear !== undefined || p.pixel || p.line || p.rect || p.bitmap))) {
|
|
71
82
|
await d.show();
|
|
72
83
|
msg.payload = { updated: true };
|
|
73
84
|
send(msg);
|
|
@@ -98,10 +109,6 @@ module.exports = function(RED) {
|
|
|
98
109
|
done(e);
|
|
99
110
|
}
|
|
100
111
|
}
|
|
101
|
-
|
|
102
|
-
node.on('close', function() {
|
|
103
|
-
if (node.connection) node.connection.close();
|
|
104
|
-
});
|
|
105
112
|
}
|
|
106
|
-
RED.nodes.registerType('
|
|
113
|
+
RED.nodes.registerType('ssd1331', SSD1331ReadNode);
|
|
107
114
|
};
|