Comments (7)
I actually had some read methods as part of OutputPin
during development, but decided against keeping them in, because the user should already be aware of the level they set the pin at, and they can keep track of it just like you're doing now. You can still read the initial state of the pin by using the read
method on the Pin
instance you get back from Gpio::get
, before converting it to an OutputPin
.
If I were to re-add those read methods, checking the relevant registers would add additional overhead, so saving state would still be a faster way of keeping track. I don't mind adding them back in with the next release if there's enough demand for it though.
Are you trying to accomplish anything in particular where you need to know the state of the OutputPin
, or do you just want to be able to return it as a convenience to the users of your library?
from rppal.
Actually, now that I think about it, reading the pin's level before configuring it would only make sense if it was already previously configured for output, so that might not be that useful to you.
from rppal.
from rppal.
When I removed the methods, I assumed there would be no use case for them, but it sounds nice to have in your situation, so I'll add them to the list for the 0.11.0 release!
You'll have to save state internally for now, or alternatively, you might be able to work with IoPin
instead, which does allow you to call read
, is_low
and is_high
on a pin set for output.
from rppal.
from rppal.
Thanks for the compliment! It's great to hear my code has been useful to other people as well.
Speaking of which, I'll likely push my initial implementation of software-based PWM to the master branch later this week, so you'll have something new to go through. I still have a few more things to try first before I'm ready to settle for 'good enough' 😄.
from rppal.
Wow... that's awesome... I have already started porting gpio access using rppal. I am having much code repetition trying to mimic OOP design in original python library.. going to try some macros to be DRYer
from rppal.
Related Issues (20)
- Syncronous Interrupt hanging HOT 2
- InputPin trait not implemented HOT 1
- Interrupt reading multiple same level edges clarification
- ioctl compile errors for all arm musl targets HOT 3
- Support 1 Wire protocol HOT 1
- PinNotAvailable(): how to drop and reinit pin? HOT 1
- `rppal::gpio::Error` should impl `Serialize`
- Reason for not supporting 10-bit i2c addressing HOT 1
- Error Compiling rppal v0.13.1 HOT 1
- Accessing GPIOs > 54 on BCM2711 causes errors
- Does rppal support non-blocking SPI? HOT 2
- Soft PWM broken in 0.14.0 - subtraction undeflow error HOT 1
- cargo check yields errors after adding to Cargo.toml HOT 3
- GPIO starts fluctating HOT 1
- Set multiple pins at once? HOT 2
- Interrupt service routines for Timers? HOT 1
- is there any clear or clean or cleanup method? HOT 3
- Wrong library. My mistake. HOT 1
- Raspberry Pi5 HOT 53
- Banana Pi M5 support HOT 2
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 rppal.