UNPKG

node-red-contrib-tinkerforge

Version:
142 lines (131 loc) 4.81 kB
<!-- - Copyright 2017 IBM Corp. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. --> <script type="text/x-red" data-template-name="TinkerForge LEDStrip"> <div class="form-row"> <label for="node-input-device"><i class="fa fa-tasks"></i> Device</label> <input type="text" id="node-input-device" > </div> <div class="form-row"> <label for="node-input-sensor"><i class="fa"></i> Sensor</label> <select id="node-input-sensor"></select> </div> <div class="form-row"> <label for="node-input-mode"><i class="fa fa-cogs"></i> Mode</label> <select id="node-input-mode" style="width:73%"> <option value="pcent">Bar - Percent of length</option> <option value="pixels">Bar - Number of pixels</option> <option value="pcentneedle">Needle - Percent of length</option> <option value="pixelsneedle">Needle - Number of pixels</option> <option value="shiftu">Add pixel to start</option> <option value="shiftd">Add pixel to end</option> </select> </div> <div class="form-row"> <label for="node-input-rgb"><i class="fa"></i> RGB</label> <select id="node-input-rgb" placeholder="rgb"> <option value="rgb">RGB</option> <option value="brg">BRG</option> </select> </div> <div class="form-row"> <label for="node-input-bgnd"><i class="fa"></i> Background</label> <input type="text" id="node-input-bgnd" placeholder="0,0,0"> </div> <div class="form-row"> <label for="node-input-pixels"><i class="fa"></i> Pixels</label> <input type="text" id="node-input-pixels" > </div> <div class="form-row"> <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="LED Strip"> </div> </script> <script type="text/x-red" data-help-name="TinkerForge LEDStrip"> <p>A node to control the LED strip bricklet. It is based on the neopixel node and supports most of the same input input formats.</p> <p>It supports the following modes:</p> <ul> <li>Bar - percentage of length</li> <li>Bar - number of pixels</li> <li>Needle - percentage of length</li> <li>Needle - number of pixels</li> </ul> <p>Some LED strips take input values in RGB order and some in BRG, this node always takes input in RGB order and there is a configuration option to set the order the stip requires.</p> </script> <script type="text/javascript"> RED.nodes.registerType("TinkerForge LEDStrip",{ category: 'TinkerForge', defaults: { device: {type: "TinkerForgeConfig", required: true}, sensor: {required: true}, pixels: {validate:RED.validators.number() , required: true}, bgnd: {value: ""}, rgb: {required: true, value:'rgb'}, mode: {required: true}, name: {} }, outputs: 0, inputs: 1, label: function() { return this.name || "TinkerForge LEDStrip"; }, paletteLabel: 'LED Strip', color: 'gray', icon: 'tf.png', oneditprepare: function() { var node = this; if (node.device) { var key = $('#node-input-device').val(); $.getJSON('TinkerForge/' + key +"/sensors/" + 231, function(data){ $('#node-input-sensor').find('option').remove().end(); for (d in data) { $('<option/>',{ value: data[d].uid, text: data[d].uid + " - " + data[d].position }).appendTo('#node-input-sensor'); } if (node.sensor) { $('#node-input-sensor').val(node.sensor); } }); } else { console.log("no device"); } $('#node-input-device').change(function(){ var dev = $('#node-input-device').val(); if (dev) { var key = dev; $.getJSON('TinkerForge/' + key +"/sensors/" + 231, function(data){ $('#node-input-sensor').find('option').remove().end(); for (d in data) { $('<option/>',{ value: data[d].uid, text: data[d].uid + " - " + data[d].position }).appendTo('#node-input-sensor'); } if (node.sensor) { $('#node-input-sensor').val(node.sensor); } }); } else { console.log("no device"); } }); if (node.sensor) { $('#node-input-sensor').val(node.sensor); } } }); </script>