fivdi / pigpio

Fast GPIO, PWM, servo control, state change notification and interrupt handling with Node.js on the Raspberry Pi
MIT License
943 stars 89 forks source link

Setting output direction #123

Closed 13 closed 3 years ago

13 commented 3 years ago

I'm running a relay with the following onoff library initialization:

var relay = new Gpio(4, 'high', {activeLow:true})

Exists there a pigpio equivalent?

fivdi commented 3 years ago

There is no exact equivalent but it should be possible to implement the equivalent using the functionality provided by pigpio. What have you tried and what were the issues?

13 commented 3 years ago

Resolved by inverting the logic

function setRelay(gpio,state) {
  if (state){
    gpio.digitalWrite(!true)
  } else {
    gpio.digitalWrite(!false)
  }
}