UNPKG

node-red-contrib-easybotics-pca9685

Version:

use a pca9685 to control brushed DC motors, servos, or stepper motors

154 lines (132 loc) 4.15 kB
<script type="text/javascript"> RED.nodes.registerType('pca-manager', { category: 'config', defaults: { name: {value:""}, address: {value: 0x6f}, }, icon: "arrow-in.png", label: 'PCA Manager' }); </script> <script type="text/x-red" data-template-name="pca-manager"> <div class = "form-row"> <label for="node-config-input-name"><i class="icon-tag"></i> Name </label> </div> </script> <script type="text/javascript"> RED.nodes.registerType('pca-DC-motor', { category: 'PCA', defaults: { name: {value:""}, motor: {value:"1", required: true}, smooth: {value:500, required: true}, handle: {type: 'pca-manager', required:true}, }, /* oneditprepare: function () { $("#node-config-input-motor").change(function() { this.motor = $("#node-config-input-motor").val(); }); $("#node-config-input-motor").val(this.motor); }, */ inputs: 1, outputs: 1, icon: "arrow-in.png", label: function() { return this.name || "DC Motor" } }); </script> <script type="text/x-red" data-template-name="pca-DC-motor"> <div class= 'form-row'> <label for='node-input-handle'><i class ='fa fa-tag'></i> PCA Handle</label> <input type='text' id='node-input-handle'/> </div> <div class= 'form-row'> <label for='node-input-smooth'><i class ='fa fa-tag'></i> Smoothing</label> <input type='number' id='node-input-smooth' min="0" placeholder="Default: 500 milliseconds"/> </div> <div class='form-row'> <label for='node-input-motor'><i class='icon-bookmark'></i> Motor Number</label> <select id='node-input-motor'> <option> 1 </option> <option> 2 </option> <option> 3 </option> <option> 4 </option> </select> </div> <div class = "form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name </label> <input type="text" id="node-input-name" placeholder="Name"> </div> </script> <script type="text/x-red" data-help-name="pca-DC-motor"> <p> a msg.payload of just an integer moves the motor to that speed over the smoothing period defined in the config <br> Limit is between -100 and 100 <br> <br> <b> msg.payload.speed: </b> The speed to move the motor too <br> <b> msg.payload.smooth: </b> The number of milliseconds accelerate the motor over <br> <br> For example a speed of 50 and smoothing of 10000 accelerates the motor to half speed over ten seconds </p> </script> <script type="text/javascript"> RED.nodes.registerType('pca-servo', { category: 'PCA', defaults: { name: {value:""}, pin: {value:"0", required: true}, smooth: {value:500, required: true}, handle: {type: 'pca-manager', required:true}, }, inputs: 1, outputs: 1, icon: "arrow-in.png", label: function() { return this.name || "Servo" } }); </script> <script type="text/x-red" data-template-name="pca-servo"> <div class= 'form-row'> <label for='node-input-handle'><i class ='fa fa-tag'></i> PCA Handle</label> <input type='text' id='node-input-handle'/> </div> <div class= 'form-row'> <label for='node-input-smooth'><i class ='fa fa-tag'></i> Smoothing</label> <input type='number' id='node-input-smooth' min="0" placeholder="Default: 500 milliseconds"/> </div> <div class='form-row'> <label for='node-input-pin'><i class='icon-bookmark'></i>Servo Pin Number</label> <select id='node-input-pin'> <option> 1 </option> <option> 0 </option> <option> 14 </option> <option> 15 </option> </select> </div> <div class = "form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name </label> <input type="text" id="node-input-name" placeholder="Name"> </div> </script> <script type="text/x-red" data-help-name="pca-servo"> <p> a msg.payload of just an integer moves the servo that angle over the smoothing period defiend in the config <br> Limit is betwteen -90 and 90 <br> <br> <b> msg.payload.angle: </b> The angle to move the servo too <br> <b> msg.payload.smooth: </b> The number of milliseconds move the servo over <br> <br> For example an angle of 45 and smoothing of 10000 moves the servo to 45 degrees in ten seconds </p> </script>