Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin glitch on init to output with default value 1 #28

Open
alexisvl opened this issue Mar 8, 2023 · 1 comment
Open

Pin glitch on init to output with default value 1 #28

alexisvl opened this issue Mar 8, 2023 · 1 comment
Labels

Comments

@alexisvl
Copy link

alexisvl commented Mar 8, 2023

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")
@Gadgetoid
Copy link
Collaborator

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?

@Gadgetoid Gadgetoid added the bug label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants