Comments (7)
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:
from ofxgpio.
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.
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.
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.
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.
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.
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)
- ADS1015 GPIO HOT 1
- Problem example-i2c-scanner HOT 1
- Can't compare ofstream or ifstream to int in gpio.cpp HOT 4
- example-apa102-ledstrip not lighting leds with Stretch HOT 5
- Use SPI1 for APA102 HOT 5
- 12c examples HOT 9
- Gpio io HOT 5
- Orange Pi 4G IOT HOT 2
- Cannot make SPI work HOT 2
- unable to set direction of gpio HOT 1
- how do i add ofxGPIO to an existing project? HOT 1
- servo example on rpi 2 - no movement HOT 1
- for Asus TinkerBoard HOT 1
- OPERATION FAILED: Unable to set direction of GPIO4 - openFrameworks not working HOT 2
- Adapting read-write example to distance sensor HOT 5
- using spi1 with MCP
- Issues with using input and output and startup.
- doesnt seems to work with RPi5 Bookworm 0F12.0 arch64 HOT 2
- error open frameworks compiling with window HOT 3
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 ofxgpio.