Code Monkey home page Code Monkey logo

Comments (7)

golemparts avatar golemparts commented on May 28, 2024

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.

golemparts avatar golemparts commented on May 28, 2024

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.

rahul-thakoor avatar rahul-thakoor commented on May 28, 2024

from rppal.

golemparts avatar golemparts commented on May 28, 2024

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.

rahul-thakoor avatar rahul-thakoor commented on May 28, 2024

from rppal.

golemparts avatar golemparts commented on May 28, 2024

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.

rahul-thakoor avatar rahul-thakoor commented on May 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.