node-red-contrib-bean
Version:
Node-red node for the LightBlue Bean
58 lines (49 loc) • 2.59 kB
HTML
<!--
Copyright 2014 Punch Throguh Design.
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="bean accel">
<div class="form-row node-input-bean">
<label for="node-input-bean"><i class="fa fa-random"></i> Bean</label>
<input type="text" id="node-input-bean">
</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="Name">
</div>
</script>
<script type="text/x-red" data-help-name="bean accel">
<p>Sending any message to this node will trigger a request to read a Bean's acceleration.</p>
<p>When the acceleration has been successfully read, this node outputs an object called <b>msg</b> containing a <b>msg.topic</b>,
<b>msg.accelX</b>, <b>msg.accelY</b>, and <b>msg.accelZ</b>. msg.topic is set to <b>"accel"</b> and the acceleration poperties are <b>fixed point numbers</b> representing acceleration in units of <b>g-force</b>.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('bean accel',{
category: 'LightBlue Bean-input', // the palette category
defaults: { // defines the editable properties of the node
name: {name:""},
bean: {type:"bean",required:true} // along with default values.
},
inputs:1, // set the number of inputs - only 0 or 1
outputs:1, // set the number of outputs - 0 to n
color: "#3FADB5",
// set the icon (held in icons dir below where you save the node)
icon: "accel.png", // saved in icons/myicon.png
paletteLabel: "acceleration",
label: function() { // sets the default label contents
var beanNode = RED.nodes.node(this.bean);
return this.name||((beanNode?beanNode.label():"Bean") + " accel");
},
labelStyle: function() { // sets the class to apply to the label
return this.name?"node_label_italic":"";
}
});
</script>