Comments (7)
from avr-hal.
@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.
from avr-hal.
Am I missing something? Is there a different way to read from a pin and get it back?
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 .into_...()
methods that are used to convert a pin between different digital I/O modes because they don't reset the ADC configuration. I am not sure how this can be best plumbed into our codebase. Maybe the easiest solution is simply a .into_digital()
method on ADC pins which always just makes the pin a floating input - and then you can further convert the pin into any digital I/O as you please. What do you think?
from avr-hal.
Maybe the easiest solution is simply a
.into_digital()
method on ADC pins which always just makes the pin a floating input.
Could you just add another impl for Pin<mode::Analog, PIN>
that implements all the into...
methods and resets the ADC in each one? If that doesn't work, an into_digital
method would also be fine by me. On a related note, it looks like an Adc::disable_pin
method might be missing.
I am happy to work on a PR for this next week if you don't have the bandwidth to take it on.
from avr-hal.
@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.
from avr-hal.
from avr-hal.
Could you just add another impl for Pin<mode::Analog, PIN> that implements all the into... methods and resets the ADC in each one?
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 into_digital()
approach...
I am happy to work on a PR for this next week if you don't have the bandwidth to take it on.
I'd certainly welcome a PR :)
from avr-hal.
Related Issues (20)
- Panic while trying to write to serial using `ufmt::uwriteln` HOT 4
- Add configurable board options to ravedude HOT 3
- Get pin number HOT 6
- Program freezes if compiled in debug mode.
- ravedude should check rust target against selected MCU HOT 3
- Document clock type design in more detail HOT 1
- cargo build - error[E0658] - proc_macro::Literal::byte_character(byte) HOT 9
- can't find crate for `core` HOT 12
- cargo build - error[E0658] - proc_macro::Literal::byte_character(byte) HOT 4
- Very weird error when compiling a very basic program: __addsf3 multiple defenitions HOT 9
- Ravedude freezes on programmer uploading HOT 5
- Arduino Nano: avrdude error: programmer is not responding HOT 11
- Watchdog intterupt mode HOT 1
- [Solved] Cannot find `pwm` in `embedded_hal` HOT 2
- peripherals type alias HOT 2
- Enhance `avr_hal_generic::renamed_pins! {}` to also generate type aliases for each pin
- tier 3 target and broken HOT 6
- Utilising the `atmega2560`'s "USART in SPI Mode" HOT 10
- Issue with math calculations with floats to serial port output HOT 5
- Incorrect ADC readings after toolchain bump HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avr-hal.