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

OutputDevice does not allow initial_value or active_high parameters #8

Open
djkieras opened this issue Jan 17, 2020 · 4 comments
Open
Labels
help wanted Extra attention is needed

Comments

@djkieras
Copy link

The Python library allows both those parameters to be set on creation of a new OutputDevice.

It appears that these values currently are hard-coded to active_state true (high) and inactive_state false(low).

If using an active low relay, this is the exact opposite of what is desired.

active_state: true,

@djkieras
Copy link
Author

@rahul-thakoor
Copy link
Owner

hey @djkieras
can you try using https://docs.rs/rust_gpiozero/0.2.0/rust_gpiozero/output_devices/struct.OutputDevice.html#method.set_active_high and passing false after you create an OutputDevice?

@djkieras
Copy link
Author

Already tried that. The thing is, the pin is instantiated with the defaults beforehand, and thus the device already has fired before the call to set_active_high. This happens after the initial boot of the Pi, but if you terminate the process and then restart it, it seems to work fine.

My suspicion is that the Pi OS does not know the default state of the pin and thus the first creation and subsequent operations affect the behavior until a restart. This could be a GPIO state bug that might be remedied in the future.

I made a couple of small changes to /boot/config.txt to set my desired pin to active_low. Limited testing indicates that may indeed work; however, seems like it would be unreliable per the documentation, and definitely overridden by any software. https://www.raspberrypi.org/documentation/configuration/config-txt/gpio.md

@rahul-thakoor rahul-thakoor added the help wanted Extra attention is needed label Jul 9, 2020
@djkieras
Copy link
Author

Been away from this project a while. Gotta get back into the swing of Rust after 6 month Java contract. If I remember correctly, directly emulating Python is not going to work because Rust does not allow optional parameters. Perhaps I will noodle with a few things and learn from that and have a suggestion, or a contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants