コード例 #1
0
class AnalogOut(ContextManaged):
    def __init__(self, pin):
        self._pin = Pin(pin.id)
        self._pin.init(mode=Pin.DAC)

    @property
    def value(self):
        # emulate what CircuitPython does
        raise AttributeError("unreadable attribute")

    @value.setter
    def value(self, value):
        self._pin.value(value)

    def deinit(self):
        del self._pin
コード例 #2
0
class AnalogIn(ContextManaged):
    def __init__(self, pin):
        self._pin = Pin(pin.id)
        self._pin.init(mode=Pin.ADC)

    @property
    def value(self):
        return self._pin.value()

    @value.setter
    def value(self, value):
        # emulate what CircuitPython does
        raise AttributeError("'AnalogIn' object has no attribute 'value'")

    def deinit(self):
        del self._pin
コード例 #3
0
class AnalogIn(ContextManaged):
    """Analog Input Class"""
    def __init__(self, pin):
        self._pin = Pin(pin.id)
        self._pin.init(mode=Pin.ADC)

    @property
    def value(self):
        """Read the ADC and return the value"""
        return self._pin.value()

    # pylint: disable=no-self-use
    @value.setter
    def value(self, value):
        # emulate what CircuitPython does
        raise AttributeError("'AnalogIn' object has no attribute 'value'")

    # pylint: enable=no-self-use

    def deinit(self):
        del self._pin