-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathncd-comm.html
148 lines (143 loc) · 5.29 KB
/
ncd-comm.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<script type="text/javascript">
RED.nodes.registerType('ncd-comm',{
category: 'config',
defaults: {
name: {value: ""},
bus: {value: ""},
busManual: {value: ""},
commType: {value: ""},
addr: {value: 0, validate: RED.validators.number()},
useMux: {value: ""},
muxAddr: {value: 112, validate: RED.validators.number()},
muxPort: {value: "0", validate: RED.validators.number()}
},
label: function() {
if(this.name) return this.name;
if(this.bus == '_manual') return 'i2c-'+this.busManual;
var label = 'i2c-'+this.bus;
if(this.commType == 'ncd-usb'){
label += ' ('+this.addr+')';
}
if(this.useMux){
label += ' ( mux '+this.muxAddr+':'+this.muxPort+')';
}
return label;
},
oneditprepare: function() {
var config = this;
$('#node-config-input-commType').change(function(){
commType = $(this).val();
if(['standard', 'usb', 'ncd-usb'].indexOf(commType) < 0) return;
$('#node-config-input-bus option').remove();
$.getJSON('ncd/i2c-bus/list/'+commType, function(busses) {
if(busses.constructor != Array){
$('#node-config-input-bus').hide().append($('<option/>',{
'value': '_manual',
'selected': 'selected'
}));
$('#node-config-input-busManual').show();
}else if (busses.length !== 0) {
busses.forEach((bus) => {
var option = $('<option/>',{
'value': bus,
'text': bus
});
if(bus == config.bus) option.attr('selected', 'selected');
option.appendTo('#node-config-input-bus');
});
}else{
}
});
if(commType == 'ncd-usb'){
$('.ncd-comm-addr').show();
}else{
$('.ncd-comm-addr').hide();
}
});
if(['standard', 'usb', 'ncd-usb'].indexOf(this.commType) > -1){
if(this.commType != 'ncd-usb') $('.ncd-comm-addr').hide();
}else{
$('.ncd-comm-addr').hide();
}
if(typeof this.addr == 'undefined'){
$('#node-config-input-addr').val('0');
}
},
});
</script>
<script type="text/x-red" data-template-name="ncd-comm">
<div class="form-row">
<label for="node-config-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-config-input-commType"><i class="icon-bookmark"></i> Comm Type</label>
<select id="node-config-input-commType">
<option value="standard">I2C Bus</option>
<option value="ncd-usb">NCD USB</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-bus"><i class="icon-bookmark"></i> I2C Bus</label>
<select id="node-config-input-bus">
<option selected="selected">--Select Comm Type--</option>
</select>
<input id="node-config-input-busManual" style="display: none;" />
</div>
<div class="form-row ncd-comm-addr">
<label for="node-config-input-addr"><i class="icon-bookmark"></i> I2C Port</label>
<input type="number" id="node-config-input-addr" width="5" />
</div>
<div class="form-row">
<label for="node-config-input-useMux"><i class="icon-bookmark"></i> Use Multiplexer</label>
<input type="checkbox" id="node-config-input-useMux" value="1" />
</div>
<div class="form-row">
<label for="node-config-input-muxAddr"><i class="icon-bookmark"></i> Multiplexer Address</label>
<select id="node-config-input-muxAddr">
<option value="112">112</option>
<option value="113">113</option>
<option value="114">114</option>
<option value="115">115</option>
<option value="116">116</option>
<option value="117">117</option>
<option value="118">118</option>
<option value="119">119</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-muxPort"><i class="icon-bookmark"></i> Multiplexer Port</label>
<select id="node-config-input-muxPort">
<option selected="selected" value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
</select>
</div>
</script>
<script type="text/x-red" data-help-name="ncd-comm">
<div>
<h3>Comm Type</h3>
<p>
<b>Select I2C Bus</b> If you are using the I2C pins, or an exposed I2C port on a device that has native support I2C, such as a Raspberry Pi.<br />
<b>Select NCD USB</b> If you are using an NCD.io device such as the <a href="https://store.ncd.io/product/dual-usb-to-5-port-i2c-bridge-adapter-100khz-for-anyi2c-software-windows-platform-ftdi-ft232rl/">BridgeX5</a> or <a href="https://store.ncd.io/product/usb-to-i2c-converter-with-virtual-com-port-ft230xs/">USB to I2C Converter</a>.<br />
<b>Select USB</b> If you are using a USB to I2C converter that expects raw data.
</p>
</div>
<div>
<h3>I2C Bus</h3>
<p>
Once you have selected your Comm Type, the I2C Bus list will be populated with available busses. Select the one you would like to use.
</p>
</div>
<div class="ncd-comm-addr">
<h3>I2C Port</h3>
<p>
If you are using an NCD device for I2C Communication, an additional field is displayed for the I2C Port. For the standard USB to I2C converter, this should alway be 0, for the BridgeX5, it will be 0-4 depending on the port your device is plugged in to.
</p>
</div>
</script>