node-red-contrib-periph-adc-dac 1.3.3 → 1.5.0

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.
@@ -0,0 +1,158 @@
1
+ [
2
+ {
3
+ "id": "tab-cs43l22-demo",
4
+ "type": "tab",
5
+ "label": "CS43L22 Headphone Demo",
6
+ "disabled": false,
7
+ "info": "Headphone amplifier bring-up with a CS43L22 stereo DAC. The audio stream (MCLK, SCLK, LRCK, SDIN) comes from the board's I2S master; Node-RED only drives the control port. An Inject node sends {start: true} once (MCLK must already be running), a second Inject ticks every 5 s into a Function node that steps the master volume 0 -> -30 dB -> 0 in 2 dB steps, a third sends a single-beep command, and a Debug node shows the volume and the status register read back (reading the status clears its flags). A fourth Inject sends {stop: true} for the power-down sequence."
8
+ },
9
+ {
10
+ "id": "inj-start",
11
+ "type": "inject",
12
+ "name": "Start (once)",
13
+ "topic": "",
14
+ "payload": "{\"start\":true}",
15
+ "payloadType": "json",
16
+ "repeat": "",
17
+ "crontab": "",
18
+ "once": true,
19
+ "onceDelay": 0.5,
20
+ "z": "tab-cs43l22-demo",
21
+ "x": 150,
22
+ "y": 60,
23
+ "wires": [
24
+ [
25
+ "cs43l22-node"
26
+ ]
27
+ ]
28
+ },
29
+ {
30
+ "id": "inj-tick",
31
+ "type": "inject",
32
+ "name": "Volume tick (5 s)",
33
+ "topic": "",
34
+ "payload": "",
35
+ "payloadType": "date",
36
+ "repeat": "5",
37
+ "crontab": "",
38
+ "once": false,
39
+ "onceDelay": 0.5,
40
+ "z": "tab-cs43l22-demo",
41
+ "x": 150,
42
+ "y": 120,
43
+ "wires": [
44
+ [
45
+ "fn-ramp"
46
+ ]
47
+ ]
48
+ },
49
+ {
50
+ "id": "fn-ramp",
51
+ "type": "function",
52
+ "name": "volume ramp",
53
+ "func": "// 0, -2 ... -30 dB, then back up, then wrap.\nlet i = context.get('step') || 0;\ncontext.set('step', (i + 1) % 30);\nconst db = i <= 15 ? -i * 2 : -(30 - i) * 2;\nmsg.payload = { volume: db };\nreturn msg;",
54
+ "outputs": 1,
55
+ "noerr": 0,
56
+ "z": "tab-cs43l22-demo",
57
+ "x": 350,
58
+ "y": 120,
59
+ "wires": [
60
+ [
61
+ "cs43l22-node"
62
+ ]
63
+ ]
64
+ },
65
+ {
66
+ "id": "inj-beep",
67
+ "type": "inject",
68
+ "name": "Beep",
69
+ "topic": "",
70
+ "payload": "{\"beep\":{\"frequency\":1,\"onTime\":2,\"offTime\":0,\"volume\":-6,\"mode\":1}}",
71
+ "payloadType": "json",
72
+ "repeat": "",
73
+ "crontab": "",
74
+ "once": false,
75
+ "onceDelay": 0.5,
76
+ "z": "tab-cs43l22-demo",
77
+ "x": 150,
78
+ "y": 180,
79
+ "wires": [
80
+ [
81
+ "cs43l22-node"
82
+ ]
83
+ ]
84
+ },
85
+ {
86
+ "id": "inj-read",
87
+ "type": "inject",
88
+ "name": "Read back",
89
+ "topic": "",
90
+ "payload": "",
91
+ "payloadType": "date",
92
+ "repeat": "",
93
+ "crontab": "",
94
+ "once": false,
95
+ "onceDelay": 0.5,
96
+ "z": "tab-cs43l22-demo",
97
+ "x": 150,
98
+ "y": 240,
99
+ "wires": [
100
+ [
101
+ "cs43l22-node"
102
+ ]
103
+ ]
104
+ },
105
+ {
106
+ "id": "inj-stop",
107
+ "type": "inject",
108
+ "name": "Stop",
109
+ "topic": "",
110
+ "payload": "{\"stop\":true}",
111
+ "payloadType": "json",
112
+ "repeat": "",
113
+ "crontab": "",
114
+ "once": false,
115
+ "onceDelay": 0.5,
116
+ "z": "tab-cs43l22-demo",
117
+ "x": 150,
118
+ "y": 300,
119
+ "wires": [
120
+ [
121
+ "cs43l22-node"
122
+ ]
123
+ ]
124
+ },
125
+ {
126
+ "id": "cs43l22-node",
127
+ "type": "periph-cs43l22",
128
+ "z": "tab-cs43l22-demo",
129
+ "name": "CS43L22",
130
+ "bus": "1",
131
+ "address": "0x4A",
132
+ "gpioChip": "0",
133
+ "resGpio": "",
134
+ "format": "i2s",
135
+ "x": 580,
136
+ "y": 150,
137
+ "wires": [
138
+ [
139
+ "dbg-out"
140
+ ]
141
+ ]
142
+ },
143
+ {
144
+ "id": "dbg-out",
145
+ "type": "debug",
146
+ "z": "tab-cs43l22-demo",
147
+ "name": "volume + status",
148
+ "active": true,
149
+ "tosidebar": true,
150
+ "console": false,
151
+ "tostatus": false,
152
+ "complete": "payload",
153
+ "targetType": "msg",
154
+ "x": 820,
155
+ "y": 150,
156
+ "wires": []
157
+ }
158
+ ]
@@ -0,0 +1,158 @@
1
+ [
2
+ {
3
+ "id": "tab-ds1881-demo",
4
+ "type": "tab",
5
+ "label": "DS1881 Volume Demo",
6
+ "disabled": false,
7
+ "info": "Stereo volume control with a DS1881 dual audio potentiometer. An Inject node ticks every 200 ms into a Function node that ramps the attenuation from 0 dB to 40 dB in 2 dB steps and back; the periph-ds1881 node sets both channels and returns {position0, position1, db0, db1}, which a Debug node shows. Two more Inject nodes send {mute: true} and {mute: false} (the last volume is restored on unmute), a third reads back both channels with the configuration, and a fourth sends {store: true} to persist the positions to EEPROM (the chip is rated for only 50 000 writes, so leave that one alone unless needed). The wipers are volatile by default, so after a power cycle both channels start muted until the ramp runs."
8
+ },
9
+ {
10
+ "id": "inj-ramp",
11
+ "type": "inject",
12
+ "name": "Ramp tick (200 ms)",
13
+ "topic": "",
14
+ "payload": "",
15
+ "payloadType": "date",
16
+ "repeat": "0.2",
17
+ "crontab": "",
18
+ "once": true,
19
+ "onceDelay": 0.5,
20
+ "z": "tab-ds1881-demo",
21
+ "x": 150,
22
+ "y": 100,
23
+ "wires": [
24
+ [
25
+ "fn-ramp"
26
+ ]
27
+ ]
28
+ },
29
+ {
30
+ "id": "fn-ramp",
31
+ "type": "function",
32
+ "name": "volume ramp",
33
+ "func": "// 0, 2 ... 40 dB, then back down to 2 dB, then wrap.\nlet i = context.get('step') || 0;\ncontext.set('step', (i + 1) % 40);\nconst db = i <= 20 ? i * 2 : (40 - i) * 2;\nmsg.payload = { db: db };\nreturn msg;",
34
+ "outputs": 1,
35
+ "noerr": 0,
36
+ "z": "tab-ds1881-demo",
37
+ "x": 350,
38
+ "y": 100,
39
+ "wires": [
40
+ [
41
+ "ds1881-node"
42
+ ]
43
+ ]
44
+ },
45
+ {
46
+ "id": "inj-mute",
47
+ "type": "inject",
48
+ "name": "Mute",
49
+ "topic": "",
50
+ "payload": "{\"mute\":true}",
51
+ "payloadType": "json",
52
+ "repeat": "",
53
+ "crontab": "",
54
+ "once": false,
55
+ "onceDelay": 0.1,
56
+ "z": "tab-ds1881-demo",
57
+ "x": 160,
58
+ "y": 180,
59
+ "wires": [
60
+ [
61
+ "ds1881-node"
62
+ ]
63
+ ]
64
+ },
65
+ {
66
+ "id": "inj-unmute",
67
+ "type": "inject",
68
+ "name": "Unmute",
69
+ "topic": "",
70
+ "payload": "{\"mute\":false}",
71
+ "payloadType": "json",
72
+ "repeat": "",
73
+ "crontab": "",
74
+ "once": false,
75
+ "onceDelay": 0.1,
76
+ "z": "tab-ds1881-demo",
77
+ "x": 160,
78
+ "y": 240,
79
+ "wires": [
80
+ [
81
+ "ds1881-node"
82
+ ]
83
+ ]
84
+ },
85
+ {
86
+ "id": "inj-read",
87
+ "type": "inject",
88
+ "name": "Read back",
89
+ "topic": "",
90
+ "payload": "",
91
+ "payloadType": "date",
92
+ "repeat": "",
93
+ "crontab": "",
94
+ "once": false,
95
+ "onceDelay": 0.1,
96
+ "z": "tab-ds1881-demo",
97
+ "x": 160,
98
+ "y": 300,
99
+ "wires": [
100
+ [
101
+ "ds1881-node"
102
+ ]
103
+ ]
104
+ },
105
+ {
106
+ "id": "inj-store",
107
+ "type": "inject",
108
+ "name": "Store to EEPROM",
109
+ "topic": "",
110
+ "payload": "{\"store\":true}",
111
+ "payloadType": "json",
112
+ "repeat": "",
113
+ "crontab": "",
114
+ "once": false,
115
+ "onceDelay": 0.1,
116
+ "z": "tab-ds1881-demo",
117
+ "x": 160,
118
+ "y": 360,
119
+ "wires": [
120
+ [
121
+ "ds1881-node"
122
+ ]
123
+ ]
124
+ },
125
+ {
126
+ "id": "ds1881-node",
127
+ "type": "periph-ds1881",
128
+ "name": "DS1881",
129
+ "bus": "1",
130
+ "option": "1",
131
+ "zerocrossing": true,
132
+ "nonvolatile": false,
133
+ "z": "tab-ds1881-demo",
134
+ "x": 560,
135
+ "y": 140,
136
+ "wires": [
137
+ [
138
+ "dbg-ds1881"
139
+ ]
140
+ ],
141
+ "address": "0x28"
142
+ },
143
+ {
144
+ "id": "dbg-ds1881",
145
+ "type": "debug",
146
+ "name": "positions / dB",
147
+ "active": true,
148
+ "tosidebar": true,
149
+ "console": false,
150
+ "tostatus": false,
151
+ "complete": "payload",
152
+ "targetType": "msg",
153
+ "z": "tab-ds1881-demo",
154
+ "x": 780,
155
+ "y": 140,
156
+ "wires": []
157
+ }
158
+ ]
@@ -0,0 +1,137 @@
1
+ [
2
+ {
3
+ "id": "tab-ds3502-demo",
4
+ "type": "tab",
5
+ "label": "DS3502 Voltage Setter Demo",
6
+ "disabled": false,
7
+ "info": "VCOM-style voltage setter on one DS3502 high-voltage digital potentiometer with RH = 15 V and RL = 0 V. An inject node sends {voltage: 5} on deploy; a second inject ticks every 500 ms into a function node that sweeps {code: n} through 16 steps (0, 8, ... 120); a debug node shows code, ratio and voltage; a button inject sends {store: true} to persist the last setting in the EEPROM (power-up value)."
8
+ },
9
+ {
10
+ "id": "inj-sweep",
11
+ "type": "inject",
12
+ "name": "Sweep tick (500 ms)",
13
+ "topic": "",
14
+ "payload": "",
15
+ "payloadType": "date",
16
+ "repeat": "0.5",
17
+ "crontab": "",
18
+ "once": true,
19
+ "onceDelay": 0.5,
20
+ "z": "tab-ds3502-demo",
21
+ "x": 150,
22
+ "y": 100,
23
+ "wires": [
24
+ [
25
+ "fn-sweep"
26
+ ]
27
+ ]
28
+ },
29
+ {
30
+ "id": "fn-sweep",
31
+ "type": "function",
32
+ "name": "sweep wiper",
33
+ "func": "// 16 steps of 8 codes: 0, 8, ... 120, then wrap.\nlet i = context.get('step') || 0;\ncontext.set('step', (i + 1) % 16);\nmsg.payload = { code: i * 8 };\nreturn msg;",
34
+ "outputs": 1,
35
+ "noerr": 0,
36
+ "z": "tab-ds3502-demo",
37
+ "x": 350,
38
+ "y": 100,
39
+ "wires": [
40
+ [
41
+ "ds3502-node"
42
+ ]
43
+ ]
44
+ },
45
+ {
46
+ "id": "inj-rheo",
47
+ "type": "inject",
48
+ "name": "Set 5 V",
49
+ "topic": "",
50
+ "payload": "{\"voltage\":5}",
51
+ "payloadType": "json",
52
+ "repeat": "",
53
+ "crontab": "",
54
+ "once": true,
55
+ "onceDelay": 0.1,
56
+ "z": "tab-ds3502-demo",
57
+ "x": 160,
58
+ "y": 180,
59
+ "wires": [
60
+ [
61
+ "ds3502-node"
62
+ ]
63
+ ]
64
+ },
65
+ {
66
+ "id": "inj-sd-on",
67
+ "type": "inject",
68
+ "name": "Store wiper in EEPROM",
69
+ "topic": "",
70
+ "payload": "{\"store\":true}",
71
+ "payloadType": "json",
72
+ "repeat": "",
73
+ "crontab": "",
74
+ "once": false,
75
+ "onceDelay": 0.1,
76
+ "z": "tab-ds3502-demo",
77
+ "x": 160,
78
+ "y": 300,
79
+ "wires": [
80
+ [
81
+ "ds3502-node"
82
+ ]
83
+ ]
84
+ },
85
+ {
86
+ "id": "inj-read",
87
+ "type": "inject",
88
+ "name": "Read wiper",
89
+ "topic": "",
90
+ "payload": "",
91
+ "payloadType": "date",
92
+ "repeat": "",
93
+ "crontab": "",
94
+ "once": false,
95
+ "onceDelay": 0.1,
96
+ "z": "tab-ds3502-demo",
97
+ "x": 160,
98
+ "y": 240,
99
+ "wires": [
100
+ [
101
+ "ds3502-node"
102
+ ]
103
+ ]
104
+ },
105
+ {
106
+ "id": "ds3502-node",
107
+ "type": "periph-ds3502",
108
+ "name": "DS3502",
109
+ "bus": "1",
110
+ "z": "tab-ds3502-demo",
111
+ "x": 560,
112
+ "y": 140,
113
+ "wires": [
114
+ [
115
+ "dbg-ds3502"
116
+ ]
117
+ ],
118
+ "address": "0x28",
119
+ "vhigh": "15",
120
+ "vlow": "0"
121
+ },
122
+ {
123
+ "id": "dbg-ds3502",
124
+ "type": "debug",
125
+ "name": "code / ratio / voltage",
126
+ "active": true,
127
+ "tosidebar": true,
128
+ "console": false,
129
+ "tostatus": false,
130
+ "complete": "payload",
131
+ "targetType": "msg",
132
+ "z": "tab-ds3502-demo",
133
+ "x": 780,
134
+ "y": 140,
135
+ "wires": []
136
+ }
137
+ ]
@@ -0,0 +1,173 @@
1
+ [
2
+ {
3
+ "id": "tab-es8311-demo",
4
+ "type": "tab",
5
+ "label": "ES8311 Volume Control",
6
+ "disabled": false,
7
+ "info": "Runtime volume control of an ES8311 audio codec whose I2S stream is produced elsewhere. An Inject node sets -40 dB on deploy; a second Inject node fires every 10 s and a Function node alternates the volume between -20 dB and -60 dB. The Debug node prints the value read back from the chip, which shows the 0.5 dB quantisation. Adjust MCLK and sample rate in the device config node to match the I2S source."
8
+ },
9
+ {
10
+ "id": "cfg-es8311",
11
+ "type": "es8311-device",
12
+ "name": "ES8311",
13
+ "bus": "1",
14
+ "address": "18",
15
+ "mclk": "12288000",
16
+ "sampleRate": "48000",
17
+ "volume": "-60",
18
+ "micGain": "24"
19
+ },
20
+ {
21
+ "id": "inj-start",
22
+ "type": "inject",
23
+ "name": "-40 dB on deploy",
24
+ "props": [
25
+ {
26
+ "p": "payload"
27
+ }
28
+ ],
29
+ "repeat": "",
30
+ "crontab": "",
31
+ "once": true,
32
+ "onceDelay": 1,
33
+ "topic": "",
34
+ "payload": "{\"volume\":-40,\"mute\":false}",
35
+ "payloadType": "json",
36
+ "z": "tab-es8311-demo",
37
+ "x": 150,
38
+ "y": 100,
39
+ "wires": [
40
+ [
41
+ "es8311"
42
+ ]
43
+ ]
44
+ },
45
+ {
46
+ "id": "inj-tick",
47
+ "type": "inject",
48
+ "name": "every 10 s",
49
+ "props": [
50
+ {
51
+ "p": "payload"
52
+ }
53
+ ],
54
+ "repeat": "10",
55
+ "crontab": "",
56
+ "once": false,
57
+ "onceDelay": 0.1,
58
+ "topic": "",
59
+ "payload": "",
60
+ "payloadType": "date",
61
+ "z": "tab-es8311-demo",
62
+ "x": 130,
63
+ "y": 180,
64
+ "wires": [
65
+ [
66
+ "fn-alternate"
67
+ ]
68
+ ]
69
+ },
70
+ {
71
+ "id": "fn-alternate",
72
+ "type": "function",
73
+ "name": "alternate -20 / -60 dB",
74
+ "func": "const loud = context.get('loud') || false;\ncontext.set('loud', !loud);\nmsg.payload = { volume: loud ? -60 : -20 };\nreturn msg;",
75
+ "outputs": 1,
76
+ "noerr": 0,
77
+ "initialize": "",
78
+ "finalize": "",
79
+ "libs": [],
80
+ "z": "tab-es8311-demo",
81
+ "x": 330,
82
+ "y": 180,
83
+ "wires": [
84
+ [
85
+ "es8311",
86
+ "delay-1s"
87
+ ]
88
+ ]
89
+ },
90
+ {
91
+ "id": "fn-readback",
92
+ "type": "change",
93
+ "name": "read back",
94
+ "rules": [
95
+ {
96
+ "t": "set",
97
+ "p": "payload",
98
+ "pt": "msg",
99
+ "to": "{}",
100
+ "tot": "json"
101
+ }
102
+ ],
103
+ "action": "",
104
+ "property": "",
105
+ "from": "",
106
+ "to": "",
107
+ "reg": false,
108
+ "z": "tab-es8311-demo",
109
+ "x": 360,
110
+ "y": 260,
111
+ "wires": [
112
+ [
113
+ "es8311"
114
+ ]
115
+ ]
116
+ },
117
+ {
118
+ "id": "delay-1s",
119
+ "type": "delay",
120
+ "name": "",
121
+ "pauseType": "delay",
122
+ "timeout": "1",
123
+ "timeoutUnits": "seconds",
124
+ "rate": "1",
125
+ "nbRateUnits": "1",
126
+ "rateUnits": "second",
127
+ "randomFirst": "1",
128
+ "randomLast": "5",
129
+ "randomUnits": "seconds",
130
+ "drop": false,
131
+ "allowrate": false,
132
+ "outputs": 1,
133
+ "z": "tab-es8311-demo",
134
+ "x": 350,
135
+ "y": 220,
136
+ "wires": [
137
+ [
138
+ "fn-readback"
139
+ ]
140
+ ]
141
+ },
142
+ {
143
+ "id": "es8311",
144
+ "type": "periph-es8311",
145
+ "name": "ES8311",
146
+ "device": "cfg-es8311",
147
+ "z": "tab-es8311-demo",
148
+ "x": 560,
149
+ "y": 180,
150
+ "wires": [
151
+ [
152
+ "dbg-output"
153
+ ]
154
+ ]
155
+ },
156
+ {
157
+ "id": "dbg-output",
158
+ "type": "debug",
159
+ "name": "",
160
+ "active": true,
161
+ "tosidebar": true,
162
+ "console": false,
163
+ "tostatus": false,
164
+ "complete": "payload",
165
+ "targetType": "msg",
166
+ "statusVal": "",
167
+ "statusType": "auto",
168
+ "z": "tab-es8311-demo",
169
+ "x": 760,
170
+ "y": 180,
171
+ "wires": []
172
+ }
173
+ ]