2 `analogio` - Analog input and output control
3 =================================================
4 See `CircuitPython:analogio` in CircuitPython for more details.
5 * Author(s): Carter Nelson
8 from adafruit_blinka.microcontroller.nxp_lpc4330.pin import Pin
9 from adafruit_blinka import ContextManaged
12 class AnalogIn(ContextManaged):
13 """Analog Input Class"""
15 def __init__(self, pin):
16 self._pin = Pin(pin.id)
17 self._pin.init(mode=Pin.ADC)
21 """Read the ADC and return the value"""
22 return self._pin.value()
24 # pylint: disable=no-self-use
26 def value(self, value):
27 # emulate what CircuitPython does
28 raise AttributeError("'AnalogIn' object has no attribute 'value'")
30 # pylint: enable=no-self-use
36 class AnalogOut(ContextManaged):
37 """Analog Output Class"""
39 def __init__(self, pin):
40 self._pin = Pin(pin.id)
41 self._pin.init(mode=Pin.DAC)
45 """Return an error. This is output only."""
46 # emulate what CircuitPython does
47 raise AttributeError("unreadable attribute")
50 def value(self, value):
51 self._pin.value(value)