mraa-gpio-din: add configurable GPIO mode for DIN

GPIO mode wasn't set correctly, it was set from Pinmuxes modes instead
of GPIO. Add way to control GPIO modes on DINs from Node-RED with
possible values from mraa : Strong, Hiz, Pull-down, Pull-up.

Signed-off-by: Ivan Mikhaylov <ivan.mikhaylov@siemens.com>
This commit is contained in:
Ivan Mikhaylov 2022-07-07 14:46:14 -04:00
parent d752cc1aa9
commit d1f6480d4f
2 changed files with 14 additions and 2 deletions

View File

@ -7,7 +7,8 @@
defaults: {
name: {value:""},
pin: {value:"", required: true},
interrupt: {value:"", required: true}
interrupt: {value:"", required: true},
mode: {value:"", required: true}
},
inputs:0,
outputs:1,
@ -68,6 +69,16 @@
<option value="19">D19</option>
</select>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa-level-up"></i> Mode</label>
<select type="text" id="node-input-mode" style="width: 250px;">
<option value='' disabled selected style='display:none;'>select mode</option>
<option value="0">Strong </option>
<option value="1">Pull-up </option>
<option value="2">Pull-down </option>
<option value="3">Hiz </option>
</select>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa-level-up"></i> Interrupt</label>
<select type="text" id="node-input-interrupt" style="width: 250px;">

View File

@ -7,10 +7,11 @@ module.exports = function(RED) {
RED.nodes.createNode(this,n);
this.pin = n.pin;
this.interrupt = n.interrupt;
this.mode = n.mode;
this.x = new m.Gpio(parseInt(this.pin));
this.board = m.getPlatformName();
var node = this;
node.x.mode(m.PIN_GPIO);
node.x.mode(parseInt(this.mode));
node.x.dir(m.DIR_IN);
node.x.isr(m.EDGE_BOTH, function() {
var g = node.x.read();