-
Notifications
You must be signed in to change notification settings - Fork 0
/
edgepi-digital-input.html
153 lines (144 loc) · 4.13 KB
/
edgepi-digital-input.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
149
150
151
152
153
<script type="text/javascript">
RED.nodes.registerType("digital-in", {
category: "EdgePi",
color: "#f391aa",
defaults: {
name: { value: "" },
transport: { value: "Local" },
tcpAddress: { value: "" },
tcpPort: { value: "" },
channel: { value: "1" },
},
inputs: 1,
outputs: 1,
icon: "right-arrow.svg",
label: function () {
return this.name || "digital-in";
},
oneditprepare: function () {
const transportType = document.getElementById("node-input-transport");
const tcpTransportInputs = document.querySelector(".form-row.tcp");
function updateEditor() {
tcpTransportInputs.style.display =
transportType.value === "Network" ? "flex" : "none";
}
updateEditor();
transportType.addEventListener("change", updateEditor);
},
oneditsave: function () {
this.channel = document.getElementById("node-input-channel").value;
},
});
</script>
<script type="text/html" data-template-name="digital-in">
<style>
* {
box-sizing: border-box !important;
}
.form-row {
display: flex;
align-items: center;
}
.form-row > label {
margin-top: auto;
margin-bottom: auto;
}
.form-row.tcp {
flex-direction: row;
align-items: center;
margin-top: -5px;
margin-bottom: 10px;
}
.tcp-address-input {
width: 160px !important;
margin-left: 100px !important;
}
.tcp-port-input {
width: 60px !important;
}
.tcp-port-label {
width: 5px !important;
margin: auto 5px;
}
</style>
<div class="form-row name">
<label for="node-input-name"><i class="fa fa-tag"></i> Name:</label>
<input type="text" id="node-input-name" placeholder="Name" />
</div>
<div class="form-row transport">
<label for="node-input-transport">RPC Server:</label>
<select id="node-input-transport">
<option value="Local">Local</option>
<option value="Network">Network</option>
</select>
</div>
<div class="form-row tcp">
<input
class="tcp-address-input"
type="text"
id="node-input-tcpAddress"
placeholder="IP Address/ Hostname"
/>
<label class="tcp-port-label" for="node-input-tcpPort">:</label>
<input
class="tcp-port-input"
type="text"
id="node-input-tcpPort"
placeholder="Port"
/>
</div>
<div class="form-row">
<label for="node-input-channel">Channel:</label>
<select id="node-input-channel">
<option value="1">D-IN1</option>
<option value="2">D-IN2</option>
<option value="3">D-IN3</option>
<option value="4">D-IN4</option>
<option value="5">D-IN5</option>
<option value="6">D-IN6</option>
<option value="7">D-IN7</option>
<option value="8">D-IN8</option>
</select>
</div>
</script>
<script type="text/html" data-help-name="digital-in">
<p>
Gets the state of a given digital input channel on the EdgePi. The output
returns a boolean indicating whether or not the input channel has a voltage
running.
</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>RPC Server</dt>
<dd>
The connection to your EdgePi's RPC Server. Use <strong>Local</strong> if
node-red is running on EdgePi. Otherwise use the
<strong>Network</strong> option and enter EdgePi's IP address / Hostname.
</dd>
<dt>Channel</dt>
<dd>The EdgePi D-IN channel to check the state for.</dd>
</dl>
<h3>Inputs</h3>
<dd>
Initial configuration set in the editor is applied once the node is
deployed. Configuration can then be dynamically set from input.
</dd>
<dl class="message-properties">
<dt>msg.payload<span class="property-type">number</span></dt>
<dd>The Digital Input channel.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">boolean</span></dt>
<dd>The status of the given channel.</dd>
</dl>
<h3>References</h3>
<ul>
<li>
<a href="https://github.com/edgepi-cloud/node-red-digital-input"
>GitHub</a
>
-the node's github repository
</li>
</ul>
</script>