Accessing GPIO pins using the two different numering schemes (BCM and BOARD) at the same time ?

On Sun, 17 Nov 2019 20:58:08 +0100, "R.Wieser" declaimed the following:

There are NO internal tables... And no global conversion routine. Tables and conversion are specific to the GPIO library one is using.

And... if you intend your code to be used by others (via import and calling functions) you are going to have to document which library you are using, and for those where it matters, which pin naming structure you expect them to be using.

Again -- gpiozero SIMPLIFIES a lot of this... It accepts multiple naming styles without locking the user into a single style. It accepts multiple back-ends (RPi.GPIO, pigpio...). Set up your module on the basis that the end-user should initialize gpiozero with their preferred back-end, and everything else should be transparent. Any pins that are to be controlled both within your module and by the end-user SHOULD be something they provide to your module as an initialization. Any pins your module dedicates should be documented so the end-user doesn't attempt to use them.

--
	Wulfraed                 Dennis Lee Bieber         AF6VN 
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/
Reply to
Dennis Lee Bieber
Loading thread data ...

Dennis,

Please re-read my definition of 'internal'. That you have your own (which you have not mentioned yet) should not be the basis of an argument.

That I never even suggested.

True. Sow, how about that GPIO library exposing what it uses ? So that I/we can convert from one of its pinnaming schemes to its other one(s) ?

No. I expect my code, if possible, to adapt to whatever the user wishes to use, not the other way around.

[snip]

Actually, this is the fricking *first time* anyone has tried to tell me WHY I should be using gpiozero over a RPi.GPIO, without just appearing to order me to do so.

I'll most likely take a look at it. ... after I've finished with what I'm currently busy with.

Sounds good. And thats all that I tried to do (for my class module using RPi.GPIO) too.

Regards, Rudy Wieser

Reply to
R.Wieser

Right. I can see how gpiozero can bring some highly desirable benefits. but that was not my question. A Dumbass stated:

Do. Not. Use. RPi.GPIO. Instead. Use. Gpiozero.

as if it was mandatory. All I wanted to know was why I *shouldn't* use Rpi.GPIO. It appears to have been a false alarm. Sigh.

Reply to
Tony van der Hoff

On Mon, 18 Nov 2019 08:22:41 +0100, "R.Wieser" declaimed the following:

I'll plead "overlapping posts"

{blast -- Looks like I need to reimage my 3B+ -- the file manager is crashing on start-up}

NOTE: the conversion is from user-name to physical (SoC) number, no reverse look-up.

17
11
17
7
17
17

{('J8', 2), ('J8', 4)}

{('J8', 1), ('J8', 17)}

set()

{('J8', 30), ('J8', 9), ('J8', 34), ('J8', 20), ('J8', 14), ('J8', 39), ('J8', 25), ('J8', 6)}

set()

{('J8', 11)}

Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3/dist-packages/gpiozero/pins/data.py", line 1158, in physical_pin raise PinMultiplePins('multiple pins can be used for %s' % function) gpiozero.exc.PinMultiplePins: multiple pins can be used for 5V

Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3/dist-packages/gpiozero/pins/data.py", line 1158, in physical_pin raise PinMultiplePins('multiple pins can be used for %s' % function) gpiozero.exc.PinMultiplePins: multiple pins can be used for 3V3

('J8', 11)

'3B+'

'MicroSD'

4

'BCM2837'

'Sony'

True

PinInfo(number=17, function='3V3', pull_up=False, row=9, col=1)

PinInfo(number=11, function='GPIO17', pull_up=False, row=6, col=1)

Is there any other information you want from it?

Heh! This is what I get for reading the source and not the documentation...

myPi = gpiozero.pins.data.pi_info()

can be simplified to

myPi = gpiozero.pi_info()

formatting link

,--------------------------------. | oooooooooooooooooooo J8 +==== | 1ooooooooooooooooooo PoE | USB | Wi oo +==== | Fi Pi Model 3B+ V1.3 oo | | ,----. +==== | |D| |SoC | | USB | |S| | | +==== | |I| `----' | | |C| +====== | |S| | Net | pwr |HDMI| |I||A| +====== `-| |--------| |----|V|-------'

Revision : a020d3 SoC : BCM2837 RAM : 1024Mb Storage : MicroSD USB ports : 4 (excluding power) Ethernet ports : 1 Wi-fi : True Bluetooth : True Camera ports (CSI) : 1 Display ports (DSI): 1

J8: 3V3 (1) (2) 5V GPIO2 (3) (4) 5V GPIO3 (5) (6) GND GPIO4 (7) (8) GPIO14 GND (9) (10) GPIO15 GPIO17 (11) (12) GPIO18 GPIO27 (13) (14) GND GPIO22 (15) (16) GPIO23 3V3 (17) (18) GPIO24 GPIO10 (19) (20) GND GPIO9 (21) (22) GPIO25 GPIO11 (23) (24) GPIO8 GND (25) (26) GPIO7 GPIO0 (27) (28) GPIO1 GPIO5 (29) (30) GND GPIO6 (31) (32) GPIO12 GPIO13 (33) (34) GND GPIO19 (35) (36) GPIO16 GPIO26 (37) (38) GPIO20 GND (39) (40) GPIO21

{That can also be produced by the gpiozero command line tool: pinout

--
	Wulfraed                 Dennis Lee Bieber         AF6VN 
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/
Reply to
Dennis Lee Bieber

Dennis,

That would explain it. :-)

I have been talking about the RPi.GPIO module only ... As mentioned, I will take a look at other possibilities /after/ I've finished with the current one.

(And yes, I understood that you wanted to show me that the gpiozero module can do what I was asking for. Don't worry about that)

That might mean that gpizero is part of the NOOBS 3.2.0 package, as its a valid command on my Pi, returning what you've shown - including the ASCII art.

By the way, I've been adding functions to what is present in the RPi.GPIO-0.7.0.tar.gz file. Currently just a 'setupBCM' and 'outputBCM', but when I figure out how the CPython code behaves (there is ofcourse lots of code overlap between the origional "xxxx", "xxxBCM" and "xxxBOARD" functions, and I'd like fold them together) I will probably add the others too.

Yeah, I know that that will cause my Python scripts using those new methods not te be sharable with others anymore (for the duration of this experiment). Thats just not to be helped. :-)

Regards, Rudy Wieser

Reply to
R.Wieser

Den 2019-11-16 kl. 18:24, skrev Gordon Henderson:

Sad reading. Just want to say that I like wiringpi, and have had lots of use from it.

Thanks for the time and effort

Reply to
Björn Lundin

pio

+1
--
Cheers, 
Chris.
Reply to
Chris

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.