2 from .pico_u2if import pico_u2if
 
   6     """A basic Pin class for use with MCP2221."""
 
  19     def __init__(self, pin_id=None):
 
  24     def init(self, mode=IN, pull=PULL_NONE):
 
  25         """Initialize the Pin"""
 
  26         pull = Pin.PULL_NONE if pull is None else pull
 
  28             raise RuntimeError("Can not init a None type pin.")
 
  29         if mode not in (Pin.IN, Pin.OUT):
 
  30             raise ValueError("Incorrect mode value.")
 
  31         if pull not in (Pin.PULL_NONE, Pin.PULL_UP, Pin.PULL_DOWN):
 
  32             raise ValueError("Incorrect pull value.")
 
  34         pico_u2if.gpio_init_pin(self.id, mode, pull)
 
  39     def value(self, val=None):
 
  40         """Set or return the Pin Value"""
 
  42         if self._mode in (Pin.IN, Pin.OUT):
 
  45                 return pico_u2if.gpio_get_pin(self.id)
 
  47             if val in (Pin.LOW, Pin.HIGH):
 
  48                 pico_u2if.gpio_set_pin(self.id, val)
 
  51             raise ValueError("Invalid value for pin.")
 
  54             "No action for mode {} with value {}".format(self._mode, val)
 
  58 # create pin instances for each pin