2016-09-20 09:19:45 +02:00
|
|
|
<!DOCTYPE html>
|
2021-10-18 22:21:44 +02:00
|
|
|
<script type="text/html" data-template-name="pimcp3008">
|
2016-09-20 09:19:45 +02:00
|
|
|
<div class="form-row">
|
2018-01-13 17:42:22 +01:00
|
|
|
<label for="node-input-dev"><i class="fa fa-server"></i> Device</label>
|
|
|
|
<select type="text" id="node-input-dev" style="width:150px;">
|
|
|
|
<option value="3008">mcp3008</option>
|
|
|
|
<option value="3002">mcp3002</option>
|
|
|
|
<option value="3004">mcp3004</option>
|
2021-10-18 22:21:44 +02:00
|
|
|
<option value="3201">mcp3201</option>
|
2018-01-13 17:42:22 +01:00
|
|
|
<option value="3202">mcp3202</option>
|
|
|
|
<option value="3204">mcp3204</option>
|
|
|
|
<option value="3208">mcp3208</option>
|
|
|
|
<option value="3304">mcp3304</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-pin"><i class="fa fa-map-pin"></i> Input pin</label>
|
2016-09-20 09:19:45 +02:00
|
|
|
<select type="text" id="node-input-pin" style="width:150px;">
|
|
|
|
<option value=0>A0</option>
|
|
|
|
<option value=1>A1</option>
|
|
|
|
<option value=2>A2</option>
|
|
|
|
<option value=3>A3</option>
|
|
|
|
<option value=4>A4</option>
|
|
|
|
<option value=5>A5</option>
|
|
|
|
<option value=6>A6</option>
|
|
|
|
<option value=7>A7</option>
|
|
|
|
<option value="M">set by msg.payload</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
2016-11-06 21:26:19 +01:00
|
|
|
<div class="form-row">
|
2018-01-13 17:42:22 +01:00
|
|
|
<label for="node-input-dnum"><i class="fa fa-toggle-on"></i> Device ID</label>
|
2016-11-06 21:26:19 +01:00
|
|
|
<select type="text" id="node-input-dnum" style="width:150px;">
|
|
|
|
<option value=0>CE0</option>
|
|
|
|
<option value=1>CE1</option>
|
2021-10-27 14:46:00 +02:00
|
|
|
<option value=2>CE2</option>
|
2016-11-06 21:26:19 +01:00
|
|
|
</select>
|
|
|
|
</div>
|
2018-09-21 14:53:08 +02:00
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-bus"><i class="fa fa-toggle-on"></i> SPI bus</label>
|
|
|
|
<select type="text" id="node-input-bus" style="width:150px;">
|
|
|
|
<option value=0>0</option>
|
|
|
|
<option value=1>1</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
2016-09-20 09:19:45 +02:00
|
|
|
<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>
|
|
|
|
|
2021-10-18 22:21:44 +02:00
|
|
|
<script type="text/html" data-help-name="pimcp3008">
|
2021-10-19 21:34:08 +02:00
|
|
|
<p>Reads from an MCP3xxx Series Analogue to Digital Converter (ADC) chip on the Pi SPI CE0 or CE1 connection,
|
|
|
|
such as the rasp.io/analogzero.</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 7.</p>
|
|
|
|
<p>Outputs a numeric <code>msg.payload</code> with a range of 0 to 1023 for MCP30xx or 0 to 4095 for
|
|
|
|
MCP32xx and MPC33xx, representing 0V to 3.3V.</p>
|
|
|
|
<p><i>Hint</i>: use a <code>range</code> node to re-scale the values to ones you want.</p>
|
|
|
|
<p>Also sets <code>msg.topic</code> to <i>adc/{the pin number}</i></p>
|
|
|
|
<p><b>Warning</b>: Input voltages must not exceed 3.3V</p>
|
|
|
|
<p>The SPI bus must be enabled for this node to work. This can be achieved by using the
|
|
|
|
advanced menu (option 9 A5) of the <b>raspi-config</b> utility.</p>
|
2016-09-20 09:19:45 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
RED.nodes.registerType('pimcp3008',{
|
|
|
|
category: 'Raspberry Pi',
|
|
|
|
paletteLabel: 'A/D converter',
|
|
|
|
color: "#c6dbef",
|
|
|
|
defaults: {
|
|
|
|
name: {value:""},
|
2018-01-13 17:42:22 +01:00
|
|
|
dev: {value:"3008"},
|
2016-11-06 21:26:19 +01:00
|
|
|
pin: {value:0, required:true},
|
2018-09-21 14:53:08 +02:00
|
|
|
dnum: {value:0},
|
|
|
|
bus: {value:0}
|
2016-09-20 09:19:45 +02:00
|
|
|
},
|
|
|
|
inputs: 1,
|
|
|
|
outputs: 1,
|
|
|
|
icon: "rpi.png",
|
|
|
|
label: function() {
|
2021-10-27 14:46:00 +02:00
|
|
|
return this.name || "mcp:"+this.dev+" "+" bus:"+this.bus+" CS:"+this.dnum+" pin:"+((this.pin==="M")?"":this.pin);
|
2016-09-20 09:19:45 +02:00
|
|
|
},
|
|
|
|
labelStyle: function() {
|
|
|
|
return this.name?"node_label_italic":"";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|