gpio
gpio copied to clipboard
Pin glitch on init to output with default value 1
Not sure if there's any interest in maintaining this still, but if there is... when you initialize a pin to an output with default value of 1, the pin gets set to a default value of 0 first briefly. The fix is to write either high or low to the direction sysfs file instead of out, which simultaneously sets it to an output and writes the default value.
For anyone who finds this issue before any fix is actually implemented, here's a workaround:
gpio.setup(PIN_NUMBER, None, None, None)
with open(f"{gpio.GPIO_ROOT}/gpio{PIN_NUMBER}/direction", "w") as f:
f.write("high" if DEFAULT_VALUE else "low")
Thank you- would you be interested in raising a PR for this, or just want me to pick up the change with a co-author credit?