Giter VIP home page Giter VIP logo

Comments (7)

kashimAstro avatar kashimAstro commented on August 15, 2024

you can choose whether the PIN is HIGH or LOW
with the third parameter of the setup method of the GPIO class.

Example:
gpio.setup(GPIO17,OUT,LOW);

or you can choose to apply a hardware pull-up.
Example:
pull-up

from ofxgpio.

DanielBlackburn avatar DanielBlackburn commented on August 15, 2024

Thanks for the quick response. I thought in the top example though that the third parameter sets the pin LOW, not the pins pull up resistor.

If that is the case would the following code set the pin to input and set the pull up resistor to high?
button.setup(GPIO17,IN,HIGH);

from ofxgpio.

DanielBlackburn avatar DanielBlackburn commented on August 15, 2024

Thanks for the second example but I don't want to use hardware pull-ups. I want to use the Pi's internal pull up resistors.

from ofxgpio.

DanielBlackburn avatar DanielBlackburn commented on August 15, 2024

Wiring Pi has a separate function (pullUpDnControl (int pin, int pud) )to set the pins internal resistors to either off, up, or ground. This is set independent of the pins direction and whether it is high or low. I am looking for the equivalent of this in ofxGPIO.

from ofxgpio.

kashimAstro avatar kashimAstro commented on August 15, 2024

sorry but I thought you were referring to the initial status of the PIN if you talk about the PUD status, the gpio class at the moment is not able to manage it.. ofxGPIO include also BCM2835 you can try starting from:

https://github.com/kashimAstro/ofxGPIO/blob/master/src/bcm2835.c#L409-L423

however, I also recommend taking a look at wiringpi
which implements these features in a simpler way.

good day!

from ofxgpio.

kashimAstro avatar kashimAstro commented on August 15, 2024

just for information, ofxGPIO was born with the purpose of managing multiple types of board (not just raspberry), many of which do not provide a pinout with integrated resistors.

that's why I decided to manage I/O with sysfs:
https://www.kernel.org/doc/Documentation/gpio/sysfs.txt

however this is not always comfortable, as soon as I'm free from work I'll try to implement new boards-specific features.

from ofxgpio.

DanielBlackburn avatar DanielBlackburn commented on August 15, 2024

OK, I understand. Thanks for the clarification. For now I'll use system() to call wiring pi at runtime.

I spotted this in bcm2835.h :

/// Sets the Pull-up/down mode for the specified pin. This is more convenient than
    /// clocking the mode in with bcm2835_gpio_pud() and bcm2835_gpio_pudclk().
    /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
    /// \param[in] pud The desired Pull-up/down mode. One of BCM2835_GPIO_PUD_* from bcm2835PUDControl
    extern void bcm2835_gpio_set_pud(uint8_t pin, uint8_t pud);

If I get time I'll also look at exposing this functionality on the Pi at least.

Thanks very much for all your work on ofxGPIO.

from ofxgpio.

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.