QUERY · ISSUE
ESP8266 Pin Get Physical Address
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
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.