New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GPIO.setmode(x) missing #1
Comments
I'm not sure about this one. What is the necessity of setmode if the key and name are already offered as options dynamically? Is it just to match the RPi.GPIO methods? If I do add it, I think it would be a dummy implementation to help with porting code. Although, I think it would be just as easy to remove it if you're porting code from RPi though, as you'd still need to change all your channels. The issue is that there are also other integers that are already mapped to P8_10. For example, that particular pin has gpio number 68. It isn't a very user-friendly mapping. Also, using 10 for P8_10 could be confused as 10 for P9_10. The issue is the large number of pins available compared to the Pi. :) I'm going to close this for now, but would be open for further arguments on it. |
I don't want to re-open it but it's a good discussion subject nonetheless. I see the points you are making. To answer your question: it's for compatibily purposes indeed. In my program I would like to use the same codebase for RPi and BBB so that I only need to change some port number/names in a config.py file. At the moment the importing port looks like this: try: Which is no big problem but perhaps it would be better placed in the library. |
These are all the LEDs defined in [source/event_gpio.h](https://github.com/adafruit/adafruit-beaglebone-io-python/blob/master/source/event_gpio.h) which map to entries in `pins_t table[]` in [source/common.c](https://github.com/adafruit/adafruit-beaglebone-io-python/blob/master/source/common.c#L72) * 66 * BeagleBone (not Blue): `{ "TIMER4", "P8_7", 66, -1, -1},` * BeagleBone Blue: `{ "RED_LED", "RED", 66, -1, -1}, // LEDs` * 67 * BeagleBone (not Blue): `{ "TIMER7", "P8_8", 67, -1, -1},` * BeagleBone Blue: `{ "GREEN_LED", "GREEN", 67, -1, -1},` * 27 * BeagleBone (not Blue): `{ "GPIO0_27", "P8_17", 27, -1, -1},` * BeagleBone Blue: `{ "BAT25", "BAT25", 27, -1, -1},` * PocketBeagle: `{ "GPIO0_27", "P2_19", 27, -1, -1},` * 11 * BeagleBone (not Blue): `{ "UART5_RTSN", "P8_32", 11, -1, -1},` * BeagleBone Blue: `{ "BAT50", "BAT50", 11, -1, -1},` * 61 * BeagleBone (not Blue): ` { "GPIO1_29", "P8_26", 61, -1, -1},` * BeagleBone Blue: ` { "BAT75", "BAT75", 61, -1, -1},` NOTE: header pin modes are well defined in these PDFs: * [BBBP8Header.pdf](http://exploringbeaglebone.com/wp-content/uploads/2014/10/BBBP8Header.pdf) * [BBBP9Header.pdf](http://exploringbeaglebone.com/wp-content/uploads/2014/10/BBBP9Header.pdf) ``` import Adafruit_BBIO.GPIO as GPIO test_pins = [ "P8_7", "P8_8", "P8_17", "P8_32", "P8_26" ] for pin in test_pins: print("========================") print("test GPIO.setup(): {0}".format(pin)) GPIO.setup(pin, GPIO.OUT) print("test GPIO.output(): {0}".format(pin)) GPIO.output(pin, GPIO.HIGH) value = GPIO.input(pin); print("test GPIO.input(): {0}={1}".format(pin, value)); GPIO.cleanup() ``` ``` debian@beaglebone:~/ssh/adafruit-beaglebone-io-python$ cat /etc/dogtag BeagleBoard.org Debian Image 2017-10-17 debian@beaglebone:~/ssh/adafruit-beaglebone-io-python$ cat /etc/debian_version 9.2 debian@beaglebone:~/ssh/adafruit-beaglebone-io-python$ uname -a Linux beaglebone 4.9.57-ti-r71 #1 SMP PREEMPT Thu Oct 19 18:17:06 UTC 2017 armv7l GNU/Linux ``` ``` debian@beaglebone:~/ssh/adafruit-beaglebone-io-python$ sudo python ~/issue178.py ======================== test GPIO.setup(): P8_7 gpio_set_value: uboot_overlay_enabled() is true gpio_set_value: pocketbeagle() is FASLE gpio_set_value: beaglebone_blue() is FALSE gpio_set_value: default gpio path gpio_set_value: filename=/sys/class/gpio/gpio66/value test GPIO.output(): P8_7 gpio_set_value: uboot_overlay_enabled() is true gpio_set_value: pocketbeagle() is FASLE gpio_set_value: beaglebone_blue() is FALSE gpio_set_value: default gpio path gpio_set_value: filename=/sys/class/gpio/gpio66/value gpio open_value_file: default gpio path gpio open_value_file: filename=/sys/class/gpio/gpio66/value test GPIO.input(): P8_7=1 ======================== test GPIO.setup(): P8_8 gpio_set_value: uboot_overlay_enabled() is true gpio_set_value: pocketbeagle() is FASLE gpio_set_value: beaglebone_blue() is FALSE gpio_set_value: default gpio path gpio_set_value: filename=/sys/class/gpio/gpio67/value test GPIO.output(): P8_8 gpio_set_value: uboot_overlay_enabled() is true gpio_set_value: pocketbeagle() is FASLE gpio_set_value: beaglebone_blue() is FALSE gpio_set_value: default gpio path gpio_set_value: filename=/sys/class/gpio/gpio67/value gpio open_value_file: default gpio path gpio open_value_file: filename=/sys/class/gpio/gpio67/value test GPIO.input(): P8_8=1 ======================== test GPIO.setup(): P8_17 gpio_set_value: uboot_overlay_enabled() is true gpio_set_value: pocketbeagle() is FASLE gpio_set_value: beaglebone_blue() is FALSE gpio_set_value: default gpio path gpio_set_value: filename=/sys/class/gpio/gpio27/value test GPIO.output(): P8_17 gpio_set_value: uboot_overlay_enabled() is true gpio_set_value: pocketbeagle() is FASLE gpio_set_value: beaglebone_blue() is FALSE gpio_set_value: default gpio path gpio_set_value: filename=/sys/class/gpio/gpio27/value gpio open_value_file: default gpio path gpio open_value_file: filename=/sys/class/gpio/gpio27/value test GPIO.input(): P8_17=1 ======================== test GPIO.setup(): P8_32 gpio_set_value: uboot_overlay_enabled() is true gpio_set_value: pocketbeagle() is FASLE gpio_set_value: beaglebone_blue() is FALSE gpio_set_value: default gpio path gpio_set_value: filename=/sys/class/gpio/gpio11/value test GPIO.output(): P8_32 gpio_set_value: uboot_overlay_enabled() is true gpio_set_value: pocketbeagle() is FASLE gpio_set_value: beaglebone_blue() is FALSE gpio_set_value: default gpio path gpio_set_value: filename=/sys/class/gpio/gpio11/value gpio open_value_file: default gpio path gpio open_value_file: filename=/sys/class/gpio/gpio11/value test GPIO.input(): P8_32=1 ======================== test GPIO.setup(): P8_26 gpio_set_value: uboot_overlay_enabled() is true gpio_set_value: pocketbeagle() is FASLE gpio_set_value: beaglebone_blue() is FALSE gpio_set_value: default gpio path gpio_set_value: filename=/sys/class/gpio/gpio61/value test GPIO.output(): P8_26 gpio_set_value: uboot_overlay_enabled() is true gpio_set_value: pocketbeagle() is FASLE gpio_set_value: beaglebone_blue() is FALSE gpio_set_value: default gpio path gpio_set_value: filename=/sys/class/gpio/gpio61/value gpio open_value_file: default gpio path gpio open_value_file: filename=/sys/class/gpio/gpio61/value test GPIO.input(): P8_26=1 ```
GPIO.setmode(x) is missing. It should be either a dummy function or it should do something meaningful.
Currently when 'P8_10' or 'GPIO0_10' is for instance used. with GPIO.setmode(BOARD or BCM) the additional syntax of using integer 10 could be mapped to either P8_10 or GPIO0_10 .
The text was updated successfully, but these errors were encountered: