-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpca9536.html
112 lines (107 loc) · 5.08 KB
/
pca9536.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<script type="text/javascript">
RED.comms.subscribe('ncd-dependencies', (t,d) => {
RED.notify(d);
})
RED.nodes.registerType('ncd-pca9536',{
category: 'NCD',
color: '#a6bbcf',
defaults: {
name: {value: ""},
connection: {value: "", type: "ncd-comm"},
interval: {value: 0, validate: RED.validators.number()},
onchange: {value: ""},
outputs: {value: 1},
output_all: {value: 0},
io_1: {value: 1},
io_2: {value: 1},
io_3: {value: 1},
io_4: {value: 1},
},
inputs:1,
outputs:1,
icon: "serial.png",
label: function() {
return this.name || "PCA9536";
},
outputLabels: function(i){
if(!this.output_all || i == 4) return 'Device Status';
return 'GPIO '+(i+1);
},
oneditsave: function(){
this.outputs = $('#node-input-output_all').is(':checked') ? 5 : 1;
}
});
</script>
<script type="text/x-red" data-template-name="ncd-pca9536">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-connection"><i class="icon-tag"></i> I2C Connection</label>
<select id="node-input-connection"></select>
</div>
<div class="form-row">
<label for="node-input-interval"><i class="icon-repeat"></i> Interval</label>
<input type="text" id="node-input-interval" placeholder="Interval">
</div>
<div class="form-row">
<label for="node-input-onchange"><i class="icon-tag"></i> Only send message on change</label>
<input type="checkbox" id="node-input-onchange" value="1" placeholder="Interval">
</div>
<div class="form-row" id="ncd-device-data-wrapper">
<input type="hidden" id="node-input-data">
</div>
<div class="form-row">
<label for="node-input-output_all"><i class="icon-tag"></i> Output all channels</label>
<input type="checkbox" id="node-input-output_all" value="1">
</div>
<h4>Channel Direction</h4>
<i>Select Outputs</i>
<div class="form-row">
<label for="node-input-io_1"><i class="icon-tag"></i> Channel 1</label>
<input type="checkbox" id="node-input-io_1" name="node-input-io_1" value="1">
</div>
<div class="form-row">
<label for="node-input-io_2"><i class="icon-tag"></i> Channel 2</label>
<input type="checkbox" id="node-input-io_2" name="node-input-io_2" value="1">
</div>
<div class="form-row">
<label for="node-input-io_3"><i class="icon-tag"></i> Channel 3</label>
<input type="checkbox" id="node-input-io_3" name="node-input-io_3" value="1">
</div>
<div class="form-row">
<label for="node-input-io_4"><i class="icon-tag"></i> Channel 4</label>
<input type="checkbox" id="node-input-io_4" name="node-input-io_4" value="1">
</div>
</script>
<script type="text/x-red" data-help-name="ncd-pca9536">
<h3>I2C Connection</h3>
<p>Configure the connection you want to use to communicate to your I2C device. Native I2C and USB to I2C converters are supported.</p>
<h3>Interval</h3>
<p>The interval defines the time between status checks. It is in milliseconds, and the interval starts after the previous check has finished.</p>
<h3>Message on Change</h3>
<p>If this option is set, the device will only generate an output message if the status of the inputs or outputs has changed since the last status check or command.</p>
<h3>Output All Channels</h3>
<p>By default this device will have 1 output, which will send a payload anytime it detects a status change on the device (or everyime it recieves a message with a topic of "get_status"). Use this option to enable seperate outputs for each channel.</p>
<h3>Channel Direction</h3>
<p>Each selected channel will be configured as an output. Any channels left unchecked will be pulled up internally and set as an input.</p>
<h3>Input values</h3>
<p>You can send commands to the device through the use of topics and payloads. Any input messages that do not contain a compatible topic will be ignored. The compatible topics are:</p>
<ul>
<li><b>get_status</b> Forces a status check outside of the normal interval.</li>
<li><b>all</b> Allows you to send a single byte to control all channels (see below)</li>
<li><b>channel_(n)</b> Addresses a specific channel (1-4), and expects a payload of 0 or 1 to turn the output off or on, respectively.</li>
</ul>
<i>When sending a single byte to control all channels, the lowest bit will control channel 1. Set bits turn the output on, unset bits turn the output off.</i>
<h3>Output Values</h3>
<p>When Output All Channels is selected, each output represents a channel, the topic will indicate the channel (channel_(n)), and the payload will be 1 or 0</p>
<p>The last output on the node (the only output if Output All Channels is not selected) will send an object as the payload keyed by the channel, with a 1 or 0 defining the status. A status of 1 on an output indicates that it is active, a status of 1 on an input means it is being pulled to ground.</p>
<p>i.e.:<br />
{<br/>
channel_1:1,<br/>
channel_2:0,<br/>
channel_3:0,<br/>
channel_4:0,<br/>
}</p>
</script>