2 `analogio` - Analog input and output control
 
   3 =================================================
 
   4 See `CircuitPython:analogio` in CircuitPython for more details.
 
   5 * Author(s): Carter Nelson
 
   7 from adafruit_blinka import ContextManaged
 
   8 from .pico_u2if import pico_u2if
 
  11 class AnalogIn(ContextManaged):
 
  12     """Analog Input Class"""
 
  14     def __init__(self, pin):
 
  15         # per their pinout, why only two?
 
  16         if pin.id not in (26, 27):
 
  17             raise ValueError("Pin does not support ADC.")
 
  19         pico_u2if.adc_init_pin(self.pin_id)
 
  23         """Read the ADC and return the value"""
 
  24         return pico_u2if.adc_get_value(self.pin_id) << 4
 
  26     # pylint: disable=no-self-use
 
  28     def value(self, value):
 
  29         # emulate what CircuitPython does
 
  30         raise AttributeError("'AnalogIn' object has no attribute 'value'")
 
  32     # pylint: enable=no-self-use