Control Onion Omega2 GPIO pins from Node (fast-gpio wrapper).
Firstly upgrade the firmware (as fast-gpio was knackered in the first few generations) then the other dependencies:
'use strict';
const Omega2Gpio = require('omega2-gpio'),
gpio = new Omega2Gpio();
gpio.tests()
.then(() => {
let outputA = gpio.pin(11);
let outputB = gpio.pin({
pin: 12,
debugging: true
});
outputA.set(1);
outputB.set(true);
console.log(outputA.get());
console.log(outputB.get());
let inputA = gpio.pin({
pin: 10,
mode: 'input'
});
console.log('Value: ' + inputA.get());
inputA.getPromised().then(value => {
console.log('Value: ' + value);
});
let ledPin = gpio.pin(11),
blink = true;
let blinkInterval = setInterval(() => {
console.log((blink ? '^_^' : '-_-') + '\n');
ledPin.set(blink);
blink = !blink;
}, 500);
setTimeout(() => {
clearInterval(blinkInterval);
ledPin.pwm({
frequency: 5,
duty: 75
});
}, 4000);
}