1 # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
 
   3 # SPDX-License-Identifier: MIT
 
   4 """Genereic Pin class for use with MicroPython boards"""
 
   5 from adafruit_blinka import Enum
 
  10     Identifies an IO pin on the microcontroller.
 
  12     They are fixed by the hardware so they cannot be constructed on demand. Instead, use board or
 
  13     microcontroller.pin to reference the desired pin.
 
  16     def __init__(self, pin_id):
 
  17         """Identifier for pin, referencing platform-specific pin id"""
 
  21         # pylint: disable=import-outside-toplevel, cyclic-import
 
  23         import microcontroller.pin
 
  25         for key in dir(board):
 
  26             if getattr(board, key) is self:
 
  27                 return "board.{}".format(key)
 
  28         # pylint: enable=import-outside-toplevel, cyclic-import
 
  30         for key in dir(microcontroller.pin):
 
  31             if getattr(microcontroller.pin, key) is self:
 
  32                 return "microcontroller.pin.{}".format(key)