-
Notifications
You must be signed in to change notification settings - Fork 223
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
No way to switch an analog pin back to digital mode #490
Comments
On Fri, Jan 12, 2024 at 03:39:56PM -0800, Quinn Freedman wrote:
Am I missing something?
I am missing real life schematic of PCB where the analog input
also can be used as digital output.
My only current workaround is to start an `unsafe` block, get a second
copy of `arduino_hal::Peripherals` with `steal()`, and use a second
copy of the pin. But that is not a great solution for something that
should be safe to do.
Please tell about the electronics that is on the embedded appliance.
Groeten
Geert Stappers
--
Silence is hard to parse
|
@stappersg this is entirely besides the point. There are certainly usecases where a pin is used with the ADC and digital I/O at the same time. |
No, unfortunately you are not missing anything. We simply don't have this implemented yet. The problem is that we can't just reuse the |
Could you just add another impl for I am happy to work on a PR for this next week if you don't have the bandwidth to take it on. |
@stappersg My current usecase is that I have several pullup inputs connected to buttons, but I want to read their floating value before setting them to pullup in order to seed my PRNG. But you could also have situations where you want to switch between input modes based on what is connected to your device, user configuration, etc. |
On Sat, Jan 13, 2024 at 09:16:04AM -0800, Quinn Freedman wrote:
@stappersg My current usecase is that I have several pullup inputs
connected to buttons, but I want to read their floating value before
setting them to pullup in order to seed my PRNG.
OKay.
That makes sense.
Thanks for elaborating.
But you could also have situations where you want to switch
between input modes based on what is connected to your device, user
configuration, etc.
Groeten
Geert Stappers
--
Silence is hard to parse
|
No, unfortunately, Rust doesn't allow multiple inherent impls on the same type to define methods of the same name, even if the generics don't overlap. That's why I suggested the
I'd certainly welcome a PR :) |
If I set an pin to a digital input/output, I can later change it to a different input/output config:
But, if I change it to an analog input, I cant figure out how to use it as an output afterwards:
Am I missing something? Is there a different way to read from a pin and get it back?
My only current workaround is to start an
unsafe
block, get a second copy ofarduino_hal::Peripherals
withsteal()
, and use a second copy of the pin. But that is not a great solution for something that should be safe to do.The text was updated successfully, but these errors were encountered: