← index #7831PR #7005
Likely Duplicate · high · value 1.818
QUERY · ISSUE

ESP8266 Pin Get Physical Address

openby PsuFanopened 2021-09-21updated 2022-03-30
port-esp8266

Is there a way to get the physical address of a pin class? For example a IRQ pin handler, determine which pin has tripped?

from machine import Pin

def handle(p):
	print(int(str(p)[4:-1])) # Better way to get pin number 5?

pin = Pin(5, Pin.IN, Pin.PULL_UP)
pin.irq(trigger=Pin.IRQ_FALLING, handler=handle)
CANDIDATE · PULL REQUEST

esp8266: add Pin.pin() method to return pin number

closedby larsksopened 2021-03-07updated 2021-03-25

Add a new Pin.pin() method to allow querying Pin objects for their
physical pin number.


This only applies to the esp8266 port, so I expect the enthusiasm for
this PR to be low. I wasn't sure if there was a sane way of
implementing something like this at a higher level, rather than
per-port, and I'm not equipped to test anything other than the esp8266
and esp32 ports.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied