stianeikeland / go-rpio

:electric_plug: Raspberry Pi GPIO library for go-lang
MIT License
2.2k stars 221 forks source link

Setting active_high=False with go-rpio #11

Open karl-gustav opened 8 years ago

karl-gustav commented 8 years ago

Hi!

In the standard gpio python library you have an option to active_high=False, do you have that in this library for go?

Python code:

pin = gpiozero.OutputDevice(2, active_high=False)

Because now the go code looks bonkers, when I want to send a HIGH signal for two seconds on GPIO 2 I have to write the opposite:

func openDoor() {
    doorRemote.Low()
    time.Sleep(time.Second * 2)
    doorRemote.High()
}

Excerpt from the docs:

active_high (bool) – If True (the default), the on() method will set the GPIO to HIGH. If False, the on() method will set the GPIO to LOW (the off() method always does the opposite).

karl-gustav commented 8 years ago

The reason for doing this if from what I'm able to gather that some of the GPIO pins are HIGHby default. (Pin 0-8 according to this random image from a google search)