node-red-contrib-roadrunner-adc
Version:
Node-RED nodes to read Acmesystem's Roadrunner ADC lines via IIO.
65 lines (61 loc) • 2.45 kB
HTML
<style>
.rr-adc-select select {
width: 4em;
}
</style>
<script type="text/x-red" data-template-name="rr-adc in">
<div class="form-row rr-adc-select" id="adcform">
<label for="node-input-adc"><i class="fa fa-circle"></i> ADC Line</label>
<select id="node-input-adc">
<option value="0" >00</option>
<option value="1" >01</option>
<option value="2" >02</option>
<option value="3" >03</option>
<option value="4" >04</option>
<option value="5" >05</option>
<option value="6" >06</option>
<option value="7" >07</option>
<option value="8" >08</option>
<option value="9" >09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="M">set by msg.payload</option>
</select>
</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="rr-gpio in">
<p>RoadRunner input node. Generates a <code>msg.payload</code> with the value of the corresponding ADC line.</p>
<p>You can either set a channel in the edit dialogue, or you can set the <code>msg.payload</code>
to select the channel dynamically. If so then the expected payload must be a value from 0 to 11.</p>
<p>Also sets <code>msg.topic</code> to <i>rr-adc/{the adc line number}</i></p>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">number</span></dt>
<dd>the payload will be the value read from the ADC line.</dd>
</dl>
<h3>Details</h3>
<p>Requires <i>/sys/bus/iio/devices/iio\:device0/</i> to be user readable in order to work if you are not running node-red as root.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('rr-adc in',{
category: 'RoadRunner',
color: '#a6bbcf',
defaults: {
name: {value:""},
adc: { value:0, required:true }
},
inputs:1,
outputs:1,
icon: "roadrunner.png",
label: function() {
return this.name||"rr-adc "+(this.adc==="M"?"":this.adc);
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
</script>