node-red-contrib-periph-io-expander 1.4.0 → 1.5.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 +5 -0
- package/examples/pca6408a/demo.json +167 -0
- package/examples/pca6416a/demo.json +167 -0
- package/examples/pca9536/demo.json +161 -0
- package/examples/pca9539/demo.json +167 -0
- package/examples/tca9554/demo.json +167 -0
- package/nodes/pca6408a/pca6408a.html +77 -0
- package/nodes/pca6408a/pca6408a.js +68 -0
- package/nodes/pca6416a/pca6416a.html +78 -0
- package/nodes/pca6416a/pca6416a.js +72 -0
- package/nodes/pca9536/pca9536.html +65 -0
- package/nodes/pca9536/pca9536.js +62 -0
- package/nodes/pca9539/pca9539.html +78 -0
- package/nodes/pca9539/pca9539.js +72 -0
- package/nodes/tca9554/tca9554.html +77 -0
- package/nodes/tca9554/tca9554.js +68 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -18,8 +18,13 @@ npm install node-red-contrib-periph-io-expander
|
|
|
18
18
|
|------|------|-------------|
|
|
19
19
|
| `periph-mcp23008` | input | Controls and reads an 8-bit MCP23008 (I²C) or MCP23S08 (SPI) I/O expander. Both chips share one register map and one node. |
|
|
20
20
|
| `periph-mcp23017` | input | Controls and reads a 16-bit MCP23017 I/O expander over I²C. |
|
|
21
|
+
| `periph-pca6408a` | input | Controls and reads an 8-bit PCA6408A I/O expander (I²C / SMBus, NXP). The chip has no internal pull-ups: inputs need external pull-up resistors. |
|
|
22
|
+
| `periph-pca6416a` | input | Controls and reads a 16-bit PCA6416A I/O expander (I²C / SMBus, NXP). The chip has no internal pull-ups: inputs need external pull-up resistors. |
|
|
23
|
+
| `periph-pca9536` | input | Controls and reads a 4-bit PCA9536 I/O expander (I²C / SMBus, TI). The chip has the fixed address 0x41 , no interrupt pin, and a weak (about 100 kΩ) pull-up that is always on each pin, so an open input reads 1. |
|
|
24
|
+
| `periph-pca9539` | input | Controls and reads a 16-bit PCA9539 I/O expander (I²C / SMBus, NXP). The chip has no internal pull-ups: inputs need external pull-up resistors. |
|
|
21
25
|
| `periph-pcf8574` | input | Controls and reads an 8-bit PCF8574 I/O expander over I²C. |
|
|
22
26
|
| `periph-pcf8575` | input | Controls and reads a 16-bit PCF8575 I/O expander over I²C. |
|
|
27
|
+
| `periph-tca9554` | input | Controls and reads an 8-bit TCA9554 I/O expander (I²C / SMBus, TI). Every input has a fixed internal 100 kΩ pull-up (always on). |
|
|
23
28
|
| `periph-tpic6b595` | input | Drives a Texas Instruments TPIC6B595 8-bit power SIPO shift register (or multiple cascaded devices) through a SiPo (serial-in/parallel-out) connection. SER IN / SRCK may be either an SPI bus (hardware mode) or two plain GPIO lines (software / bit-bang mode); RCK is always a plain GPIO. Optional SRCLR and G lines add shift-register-clear and global output enable (PWM-style dimming). |
|
|
24
29
|
|
|
25
30
|
## Links
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab_pca6408a_demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "PCA6408A Demo",
|
|
6
|
+
"info": "Output control and input polling on the PCA6408A 8-bit I²C / SMBus IO expander.\n\nHardware:\n- P0–P3: four LEDs (anode through 220 Ω, cathode to GND; active-high)\n- P4–P7: push buttons to GND (external pull-ups required: the chip has none)\n\nHow it works:\n1. An Inject node every 200 ms feeds a Function node that writes a rotating one-hot pattern to the LEDs (P0→P3), one pin at a time.\n2. A second Inject node reads the full 8-bit port every second; a Function node formats the hex value for a Debug node.\n3. A third Inject node reads P4 (a button input); a Debug node shows the 0/1 level.\n\nWith the INT line wired (set the INT GPIO line in the node's config panel) the node also emits { port: 0, changed, value } whenever a button on P4–P7 changes.\n\nTo observe: watch the LEDs chase and press the buttons; the port value changes in the debug sidebar."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"id": "inj_rotate",
|
|
10
|
+
"type": "inject",
|
|
11
|
+
"z": "tab_pca6408a_demo",
|
|
12
|
+
"name": "Rotate 200ms",
|
|
13
|
+
"repeat": "0.2",
|
|
14
|
+
"payload": "",
|
|
15
|
+
"payloadType": "date",
|
|
16
|
+
"topic": "",
|
|
17
|
+
"once": false,
|
|
18
|
+
"x": 120,
|
|
19
|
+
"y": 60,
|
|
20
|
+
"wires": [
|
|
21
|
+
[
|
|
22
|
+
"fn_rotate"
|
|
23
|
+
]
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "fn_rotate",
|
|
28
|
+
"type": "function",
|
|
29
|
+
"z": "tab_pca6408a_demo",
|
|
30
|
+
"name": "One-hot pattern",
|
|
31
|
+
"func": "const i = Math.floor(Date.now() / 200) % 4;\nconst prev = (i + 3) % 4;\nreturn [[{ payload: { pin: prev, value: 0 } }, { payload: { pin: i, value: 1 } }]];",
|
|
32
|
+
"outputs": 1,
|
|
33
|
+
"noerr": 0,
|
|
34
|
+
"x": 330,
|
|
35
|
+
"y": 60,
|
|
36
|
+
"wires": [
|
|
37
|
+
[
|
|
38
|
+
"mcp_write"
|
|
39
|
+
]
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "mcp_write",
|
|
44
|
+
"type": "periph-pca6408a",
|
|
45
|
+
"z": "tab_pca6408a_demo",
|
|
46
|
+
"name": "Write LEDs",
|
|
47
|
+
"bus": "1",
|
|
48
|
+
"address": "20",
|
|
49
|
+
"gpioChip": "0",
|
|
50
|
+
"intPin": "",
|
|
51
|
+
"x": 560,
|
|
52
|
+
"y": 60,
|
|
53
|
+
"wires": [
|
|
54
|
+
[]
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "inj_port",
|
|
59
|
+
"type": "inject",
|
|
60
|
+
"z": "tab_pca6408a_demo",
|
|
61
|
+
"name": "Read port 1s",
|
|
62
|
+
"repeat": "1",
|
|
63
|
+
"payload": "{\"port\":0}",
|
|
64
|
+
"payloadType": "json",
|
|
65
|
+
"topic": "",
|
|
66
|
+
"once": false,
|
|
67
|
+
"x": 120,
|
|
68
|
+
"y": 160,
|
|
69
|
+
"wires": [
|
|
70
|
+
[
|
|
71
|
+
"mcp_port"
|
|
72
|
+
]
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "mcp_port",
|
|
77
|
+
"type": "periph-pca6408a",
|
|
78
|
+
"z": "tab_pca6408a_demo",
|
|
79
|
+
"name": "Read port",
|
|
80
|
+
"bus": "1",
|
|
81
|
+
"address": "20",
|
|
82
|
+
"gpioChip": "0",
|
|
83
|
+
"intPin": "",
|
|
84
|
+
"x": 330,
|
|
85
|
+
"y": 160,
|
|
86
|
+
"wires": [
|
|
87
|
+
[
|
|
88
|
+
"fn_hex"
|
|
89
|
+
]
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"id": "fn_hex",
|
|
94
|
+
"type": "function",
|
|
95
|
+
"z": "tab_pca6408a_demo",
|
|
96
|
+
"name": "Format hex",
|
|
97
|
+
"func": "msg.payload = 'PIO=0x' + msg.payload.value.toString(16).padStart(2, '0');\nreturn msg;",
|
|
98
|
+
"outputs": 1,
|
|
99
|
+
"noerr": 0,
|
|
100
|
+
"x": 540,
|
|
101
|
+
"y": 160,
|
|
102
|
+
"wires": [
|
|
103
|
+
[
|
|
104
|
+
"dbg_port"
|
|
105
|
+
]
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"id": "dbg_port",
|
|
110
|
+
"type": "debug",
|
|
111
|
+
"z": "tab_pca6408a_demo",
|
|
112
|
+
"name": "Port value",
|
|
113
|
+
"active": true,
|
|
114
|
+
"tosidebar": true,
|
|
115
|
+
"complete": "payload",
|
|
116
|
+
"x": 740,
|
|
117
|
+
"y": 160,
|
|
118
|
+
"wires": []
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"id": "inj_btn",
|
|
122
|
+
"type": "inject",
|
|
123
|
+
"z": "tab_pca6408a_demo",
|
|
124
|
+
"name": "Read P4 500ms",
|
|
125
|
+
"repeat": "0.5",
|
|
126
|
+
"payload": "{\"pin\":4}",
|
|
127
|
+
"payloadType": "json",
|
|
128
|
+
"topic": "",
|
|
129
|
+
"once": false,
|
|
130
|
+
"x": 120,
|
|
131
|
+
"y": 260,
|
|
132
|
+
"wires": [
|
|
133
|
+
[
|
|
134
|
+
"mcp_btn"
|
|
135
|
+
]
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"id": "mcp_btn",
|
|
140
|
+
"type": "periph-pca6408a",
|
|
141
|
+
"z": "tab_pca6408a_demo",
|
|
142
|
+
"name": "Read P4",
|
|
143
|
+
"bus": "1",
|
|
144
|
+
"address": "20",
|
|
145
|
+
"gpioChip": "0",
|
|
146
|
+
"intPin": "",
|
|
147
|
+
"x": 330,
|
|
148
|
+
"y": 260,
|
|
149
|
+
"wires": [
|
|
150
|
+
[
|
|
151
|
+
"dbg_btn"
|
|
152
|
+
]
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": "dbg_btn",
|
|
157
|
+
"type": "debug",
|
|
158
|
+
"z": "tab_pca6408a_demo",
|
|
159
|
+
"name": "P4 level",
|
|
160
|
+
"active": true,
|
|
161
|
+
"tosidebar": true,
|
|
162
|
+
"complete": "payload",
|
|
163
|
+
"x": 540,
|
|
164
|
+
"y": 260,
|
|
165
|
+
"wires": []
|
|
166
|
+
}
|
|
167
|
+
]
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab_pca6416a_demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "PCA6416A Demo",
|
|
6
|
+
"info": "Output control and input polling on the PCA6416A 16-bit I²C / SMBus IO expander.\n\nHardware:\n- P0_0–P0_7 (port 0): eight LEDs (anode through 220 Ω, cathode to GND; active-high)\n- P1_0–P1_7 (port 1): push buttons to GND (external pull-ups required: the chip has none)\n\nHow it works:\n1. An Inject node every 200 ms feeds a Function node that writes a rotating one-hot pattern to the LEDs (P0_0→P0_7), one pin at a time.\n2. A second Inject node reads all 16 pins every second; a Function node formats the 16-bit hex value for a Debug node.\n3. A third Inject node reads pin 8 (P1_0, a button input); a Debug node shows the 0/1 level.\n\nWith the INT line wired (set the INT GPIO line in the node's config panel) the node also emits { changed, value } whenever a button on port 1 changes.\n\nTo observe: watch the LEDs chase and press the buttons; the pin values change in the debug sidebar."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"id": "inj_rotate",
|
|
10
|
+
"type": "inject",
|
|
11
|
+
"z": "tab_pca6416a_demo",
|
|
12
|
+
"name": "Rotate 200ms",
|
|
13
|
+
"repeat": "0.2",
|
|
14
|
+
"payload": "",
|
|
15
|
+
"payloadType": "date",
|
|
16
|
+
"topic": "",
|
|
17
|
+
"once": false,
|
|
18
|
+
"x": 120,
|
|
19
|
+
"y": 60,
|
|
20
|
+
"wires": [
|
|
21
|
+
[
|
|
22
|
+
"fn_rotate"
|
|
23
|
+
]
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "fn_rotate",
|
|
28
|
+
"type": "function",
|
|
29
|
+
"z": "tab_pca6416a_demo",
|
|
30
|
+
"name": "One-hot pattern",
|
|
31
|
+
"func": "const i = Math.floor(Date.now() / 200) % 8;\nconst prev = (i + 7) % 8;\nreturn [[{ payload: { pin: prev, value: 0 } }, { payload: { pin: i, value: 1 } }]];",
|
|
32
|
+
"outputs": 1,
|
|
33
|
+
"noerr": 0,
|
|
34
|
+
"x": 330,
|
|
35
|
+
"y": 60,
|
|
36
|
+
"wires": [
|
|
37
|
+
[
|
|
38
|
+
"mcp_write"
|
|
39
|
+
]
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "mcp_write",
|
|
44
|
+
"type": "periph-pca6416a",
|
|
45
|
+
"z": "tab_pca6416a_demo",
|
|
46
|
+
"name": "Write LEDs",
|
|
47
|
+
"bus": "1",
|
|
48
|
+
"address": "20",
|
|
49
|
+
"gpioChip": "0",
|
|
50
|
+
"intPin": "",
|
|
51
|
+
"x": 560,
|
|
52
|
+
"y": 60,
|
|
53
|
+
"wires": [
|
|
54
|
+
[]
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "inj_port",
|
|
59
|
+
"type": "inject",
|
|
60
|
+
"z": "tab_pca6416a_demo",
|
|
61
|
+
"name": "Read all 1s",
|
|
62
|
+
"repeat": "1",
|
|
63
|
+
"payload": "{}",
|
|
64
|
+
"payloadType": "json",
|
|
65
|
+
"topic": "",
|
|
66
|
+
"once": false,
|
|
67
|
+
"x": 120,
|
|
68
|
+
"y": 160,
|
|
69
|
+
"wires": [
|
|
70
|
+
[
|
|
71
|
+
"mcp_port"
|
|
72
|
+
]
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "mcp_port",
|
|
77
|
+
"type": "periph-pca6416a",
|
|
78
|
+
"z": "tab_pca6416a_demo",
|
|
79
|
+
"name": "Read all pins",
|
|
80
|
+
"bus": "1",
|
|
81
|
+
"address": "20",
|
|
82
|
+
"gpioChip": "0",
|
|
83
|
+
"intPin": "",
|
|
84
|
+
"x": 330,
|
|
85
|
+
"y": 160,
|
|
86
|
+
"wires": [
|
|
87
|
+
[
|
|
88
|
+
"fn_hex"
|
|
89
|
+
]
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"id": "fn_hex",
|
|
94
|
+
"type": "function",
|
|
95
|
+
"z": "tab_pca6416a_demo",
|
|
96
|
+
"name": "Format hex",
|
|
97
|
+
"func": "msg.payload = 'PIO=0x' + msg.payload.value.toString(16).padStart(4, '0');\nreturn msg;",
|
|
98
|
+
"outputs": 1,
|
|
99
|
+
"noerr": 0,
|
|
100
|
+
"x": 540,
|
|
101
|
+
"y": 160,
|
|
102
|
+
"wires": [
|
|
103
|
+
[
|
|
104
|
+
"dbg_port"
|
|
105
|
+
]
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"id": "dbg_port",
|
|
110
|
+
"type": "debug",
|
|
111
|
+
"z": "tab_pca6416a_demo",
|
|
112
|
+
"name": "All pins",
|
|
113
|
+
"active": true,
|
|
114
|
+
"tosidebar": true,
|
|
115
|
+
"complete": "payload",
|
|
116
|
+
"x": 740,
|
|
117
|
+
"y": 160,
|
|
118
|
+
"wires": []
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"id": "inj_btn",
|
|
122
|
+
"type": "inject",
|
|
123
|
+
"z": "tab_pca6416a_demo",
|
|
124
|
+
"name": "Read P1_0 500ms",
|
|
125
|
+
"repeat": "0.5",
|
|
126
|
+
"payload": "{\"pin\":8}",
|
|
127
|
+
"payloadType": "json",
|
|
128
|
+
"topic": "",
|
|
129
|
+
"once": false,
|
|
130
|
+
"x": 120,
|
|
131
|
+
"y": 260,
|
|
132
|
+
"wires": [
|
|
133
|
+
[
|
|
134
|
+
"mcp_btn"
|
|
135
|
+
]
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"id": "mcp_btn",
|
|
140
|
+
"type": "periph-pca6416a",
|
|
141
|
+
"z": "tab_pca6416a_demo",
|
|
142
|
+
"name": "Read P1_0",
|
|
143
|
+
"bus": "1",
|
|
144
|
+
"address": "20",
|
|
145
|
+
"gpioChip": "0",
|
|
146
|
+
"intPin": "",
|
|
147
|
+
"x": 330,
|
|
148
|
+
"y": 260,
|
|
149
|
+
"wires": [
|
|
150
|
+
[
|
|
151
|
+
"dbg_btn"
|
|
152
|
+
]
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": "dbg_btn",
|
|
157
|
+
"type": "debug",
|
|
158
|
+
"z": "tab_pca6416a_demo",
|
|
159
|
+
"name": "P1_0 level",
|
|
160
|
+
"active": true,
|
|
161
|
+
"tosidebar": true,
|
|
162
|
+
"complete": "payload",
|
|
163
|
+
"x": 540,
|
|
164
|
+
"y": 260,
|
|
165
|
+
"wires": []
|
|
166
|
+
}
|
|
167
|
+
]
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab_pca9536_demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "PCA9536 Demo",
|
|
6
|
+
"info": "Output control, input reading and change polling on the PCA9536 4-bit I²C / SMBus IO expander.\n\nHardware:\n- P0–P1: two LEDs (anode through 220 Ω, cathode to GND; active-high)\n- P2–P3: push buttons to GND (the chip's built-in weak pull-up holds an open input high; no external resistor needed)\n\nHow it works:\n1. An Inject node every 200 ms feeds a Function node that writes a rotating one-hot pattern to the LEDs (P0→P1), one pin at a time.\n2. A second Inject node reads the 4-bit port every second; a Function node formats the hex value for a Debug node.\n3. A third Inject node reads P2 (a button input); a Debug node shows the 0/1 level.\n\nThe chip has no INT pin. Set a poll interval (ms) in the node's config panel and the node also emits { port: 0, changed, value } whenever a button on P2–P3 changes.\n\nTo observe: watch the LEDs chase and press the buttons; the port value changes in the debug sidebar."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"id": "inj_rotate",
|
|
10
|
+
"type": "inject",
|
|
11
|
+
"z": "tab_pca9536_demo",
|
|
12
|
+
"name": "Rotate 200ms",
|
|
13
|
+
"repeat": "0.2",
|
|
14
|
+
"payload": "",
|
|
15
|
+
"payloadType": "date",
|
|
16
|
+
"topic": "",
|
|
17
|
+
"once": false,
|
|
18
|
+
"x": 120,
|
|
19
|
+
"y": 60,
|
|
20
|
+
"wires": [
|
|
21
|
+
[
|
|
22
|
+
"fn_rotate"
|
|
23
|
+
]
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "fn_rotate",
|
|
28
|
+
"type": "function",
|
|
29
|
+
"z": "tab_pca9536_demo",
|
|
30
|
+
"name": "One-hot pattern",
|
|
31
|
+
"func": "const i = Math.floor(Date.now() / 200) % 2;\nconst prev = (i + 1) % 2;\nreturn [[{ payload: { pin: prev, value: 0 } }, { payload: { pin: i, value: 1 } }]];",
|
|
32
|
+
"outputs": 1,
|
|
33
|
+
"noerr": 0,
|
|
34
|
+
"x": 330,
|
|
35
|
+
"y": 60,
|
|
36
|
+
"wires": [
|
|
37
|
+
[
|
|
38
|
+
"mcp_write"
|
|
39
|
+
]
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "mcp_write",
|
|
44
|
+
"type": "periph-pca9536",
|
|
45
|
+
"z": "tab_pca9536_demo",
|
|
46
|
+
"name": "Write LEDs",
|
|
47
|
+
"bus": "1",
|
|
48
|
+
"x": 560,
|
|
49
|
+
"y": 60,
|
|
50
|
+
"wires": [
|
|
51
|
+
[]
|
|
52
|
+
],
|
|
53
|
+
"pollInterval": ""
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"id": "inj_port",
|
|
57
|
+
"type": "inject",
|
|
58
|
+
"z": "tab_pca9536_demo",
|
|
59
|
+
"name": "Read port 1s",
|
|
60
|
+
"repeat": "1",
|
|
61
|
+
"payload": "{\"port\":0}",
|
|
62
|
+
"payloadType": "json",
|
|
63
|
+
"topic": "",
|
|
64
|
+
"once": false,
|
|
65
|
+
"x": 120,
|
|
66
|
+
"y": 160,
|
|
67
|
+
"wires": [
|
|
68
|
+
[
|
|
69
|
+
"mcp_port"
|
|
70
|
+
]
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"id": "mcp_port",
|
|
75
|
+
"type": "periph-pca9536",
|
|
76
|
+
"z": "tab_pca9536_demo",
|
|
77
|
+
"name": "Read port",
|
|
78
|
+
"bus": "1",
|
|
79
|
+
"x": 330,
|
|
80
|
+
"y": 160,
|
|
81
|
+
"wires": [
|
|
82
|
+
[
|
|
83
|
+
"fn_hex"
|
|
84
|
+
]
|
|
85
|
+
],
|
|
86
|
+
"pollInterval": ""
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": "fn_hex",
|
|
90
|
+
"type": "function",
|
|
91
|
+
"z": "tab_pca9536_demo",
|
|
92
|
+
"name": "Format hex",
|
|
93
|
+
"func": "msg.payload = 'PIO=0x' + msg.payload.value.toString(16);\nreturn msg;",
|
|
94
|
+
"outputs": 1,
|
|
95
|
+
"noerr": 0,
|
|
96
|
+
"x": 540,
|
|
97
|
+
"y": 160,
|
|
98
|
+
"wires": [
|
|
99
|
+
[
|
|
100
|
+
"dbg_port"
|
|
101
|
+
]
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "dbg_port",
|
|
106
|
+
"type": "debug",
|
|
107
|
+
"z": "tab_pca9536_demo",
|
|
108
|
+
"name": "Port value",
|
|
109
|
+
"active": true,
|
|
110
|
+
"tosidebar": true,
|
|
111
|
+
"complete": "payload",
|
|
112
|
+
"x": 740,
|
|
113
|
+
"y": 160,
|
|
114
|
+
"wires": []
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"id": "inj_btn",
|
|
118
|
+
"type": "inject",
|
|
119
|
+
"z": "tab_pca9536_demo",
|
|
120
|
+
"name": "Read P2 500ms",
|
|
121
|
+
"repeat": "0.5",
|
|
122
|
+
"payload": "{\"pin\":2}",
|
|
123
|
+
"payloadType": "json",
|
|
124
|
+
"topic": "",
|
|
125
|
+
"once": false,
|
|
126
|
+
"x": 120,
|
|
127
|
+
"y": 260,
|
|
128
|
+
"wires": [
|
|
129
|
+
[
|
|
130
|
+
"mcp_btn"
|
|
131
|
+
]
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"id": "mcp_btn",
|
|
136
|
+
"type": "periph-pca9536",
|
|
137
|
+
"z": "tab_pca9536_demo",
|
|
138
|
+
"name": "Read P2",
|
|
139
|
+
"bus": "1",
|
|
140
|
+
"x": 330,
|
|
141
|
+
"y": 260,
|
|
142
|
+
"wires": [
|
|
143
|
+
[
|
|
144
|
+
"dbg_btn"
|
|
145
|
+
]
|
|
146
|
+
],
|
|
147
|
+
"pollInterval": ""
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "dbg_btn",
|
|
151
|
+
"type": "debug",
|
|
152
|
+
"z": "tab_pca9536_demo",
|
|
153
|
+
"name": "P2 level",
|
|
154
|
+
"active": true,
|
|
155
|
+
"tosidebar": true,
|
|
156
|
+
"complete": "payload",
|
|
157
|
+
"x": 540,
|
|
158
|
+
"y": 260,
|
|
159
|
+
"wires": []
|
|
160
|
+
}
|
|
161
|
+
]
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab_pca9539_demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "PCA9539 Demo",
|
|
6
|
+
"info": "Output control and input polling on the PCA9539 16-bit I²C / SMBus IO expander.\n\nHardware:\n- P00–P07 (port 0): eight LEDs (anode through 220 Ω, cathode to GND; active-high)\n- P10–P17 (port 1): push buttons to GND (external pull-ups required: the chip has none)\n\nHow it works:\n1. An Inject node every 200 ms feeds a Function node that writes a rotating one-hot pattern to the LEDs (P00→P07), one pin at a time.\n2. A second Inject node reads all 16 pins every second; a Function node formats the 16-bit hex value for a Debug node.\n3. A third Inject node reads pin 8 (P10, a button input); a Debug node shows the 0/1 level.\n\nWith the INT line wired (set the INT GPIO line in the node's config panel) the node also emits { changed, value } whenever a button on port 1 changes.\n\nTo observe: watch the LEDs chase and press the buttons; the pin values change in the debug sidebar."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"id": "inj_rotate",
|
|
10
|
+
"type": "inject",
|
|
11
|
+
"z": "tab_pca9539_demo",
|
|
12
|
+
"name": "Rotate 200ms",
|
|
13
|
+
"repeat": "0.2",
|
|
14
|
+
"payload": "",
|
|
15
|
+
"payloadType": "date",
|
|
16
|
+
"topic": "",
|
|
17
|
+
"once": false,
|
|
18
|
+
"x": 120,
|
|
19
|
+
"y": 60,
|
|
20
|
+
"wires": [
|
|
21
|
+
[
|
|
22
|
+
"fn_rotate"
|
|
23
|
+
]
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "fn_rotate",
|
|
28
|
+
"type": "function",
|
|
29
|
+
"z": "tab_pca9539_demo",
|
|
30
|
+
"name": "One-hot pattern",
|
|
31
|
+
"func": "const i = Math.floor(Date.now() / 200) % 8;\nconst prev = (i + 7) % 8;\nreturn [[{ payload: { pin: prev, value: 0 } }, { payload: { pin: i, value: 1 } }]];",
|
|
32
|
+
"outputs": 1,
|
|
33
|
+
"noerr": 0,
|
|
34
|
+
"x": 330,
|
|
35
|
+
"y": 60,
|
|
36
|
+
"wires": [
|
|
37
|
+
[
|
|
38
|
+
"mcp_write"
|
|
39
|
+
]
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "mcp_write",
|
|
44
|
+
"type": "periph-pca9539",
|
|
45
|
+
"z": "tab_pca9539_demo",
|
|
46
|
+
"name": "Write LEDs",
|
|
47
|
+
"bus": "1",
|
|
48
|
+
"address": "74",
|
|
49
|
+
"gpioChip": "0",
|
|
50
|
+
"intPin": "",
|
|
51
|
+
"x": 560,
|
|
52
|
+
"y": 60,
|
|
53
|
+
"wires": [
|
|
54
|
+
[]
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "inj_port",
|
|
59
|
+
"type": "inject",
|
|
60
|
+
"z": "tab_pca9539_demo",
|
|
61
|
+
"name": "Read all 1s",
|
|
62
|
+
"repeat": "1",
|
|
63
|
+
"payload": "{}",
|
|
64
|
+
"payloadType": "json",
|
|
65
|
+
"topic": "",
|
|
66
|
+
"once": false,
|
|
67
|
+
"x": 120,
|
|
68
|
+
"y": 160,
|
|
69
|
+
"wires": [
|
|
70
|
+
[
|
|
71
|
+
"mcp_port"
|
|
72
|
+
]
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "mcp_port",
|
|
77
|
+
"type": "periph-pca9539",
|
|
78
|
+
"z": "tab_pca9539_demo",
|
|
79
|
+
"name": "Read all pins",
|
|
80
|
+
"bus": "1",
|
|
81
|
+
"address": "74",
|
|
82
|
+
"gpioChip": "0",
|
|
83
|
+
"intPin": "",
|
|
84
|
+
"x": 330,
|
|
85
|
+
"y": 160,
|
|
86
|
+
"wires": [
|
|
87
|
+
[
|
|
88
|
+
"fn_hex"
|
|
89
|
+
]
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"id": "fn_hex",
|
|
94
|
+
"type": "function",
|
|
95
|
+
"z": "tab_pca9539_demo",
|
|
96
|
+
"name": "Format hex",
|
|
97
|
+
"func": "msg.payload = 'PIO=0x' + msg.payload.value.toString(16).padStart(4, '0');\nreturn msg;",
|
|
98
|
+
"outputs": 1,
|
|
99
|
+
"noerr": 0,
|
|
100
|
+
"x": 540,
|
|
101
|
+
"y": 160,
|
|
102
|
+
"wires": [
|
|
103
|
+
[
|
|
104
|
+
"dbg_port"
|
|
105
|
+
]
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"id": "dbg_port",
|
|
110
|
+
"type": "debug",
|
|
111
|
+
"z": "tab_pca9539_demo",
|
|
112
|
+
"name": "All pins",
|
|
113
|
+
"active": true,
|
|
114
|
+
"tosidebar": true,
|
|
115
|
+
"complete": "payload",
|
|
116
|
+
"x": 740,
|
|
117
|
+
"y": 160,
|
|
118
|
+
"wires": []
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"id": "inj_btn",
|
|
122
|
+
"type": "inject",
|
|
123
|
+
"z": "tab_pca9539_demo",
|
|
124
|
+
"name": "Read P10 500ms",
|
|
125
|
+
"repeat": "0.5",
|
|
126
|
+
"payload": "{\"pin\":8}",
|
|
127
|
+
"payloadType": "json",
|
|
128
|
+
"topic": "",
|
|
129
|
+
"once": false,
|
|
130
|
+
"x": 120,
|
|
131
|
+
"y": 260,
|
|
132
|
+
"wires": [
|
|
133
|
+
[
|
|
134
|
+
"mcp_btn"
|
|
135
|
+
]
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"id": "mcp_btn",
|
|
140
|
+
"type": "periph-pca9539",
|
|
141
|
+
"z": "tab_pca9539_demo",
|
|
142
|
+
"name": "Read P10",
|
|
143
|
+
"bus": "1",
|
|
144
|
+
"address": "74",
|
|
145
|
+
"gpioChip": "0",
|
|
146
|
+
"intPin": "",
|
|
147
|
+
"x": 330,
|
|
148
|
+
"y": 260,
|
|
149
|
+
"wires": [
|
|
150
|
+
[
|
|
151
|
+
"dbg_btn"
|
|
152
|
+
]
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": "dbg_btn",
|
|
157
|
+
"type": "debug",
|
|
158
|
+
"z": "tab_pca9539_demo",
|
|
159
|
+
"name": "P10 level",
|
|
160
|
+
"active": true,
|
|
161
|
+
"tosidebar": true,
|
|
162
|
+
"complete": "payload",
|
|
163
|
+
"x": 540,
|
|
164
|
+
"y": 260,
|
|
165
|
+
"wires": []
|
|
166
|
+
}
|
|
167
|
+
]
|