Exemple #1
0
def test_digital_state_setter() -> None:
    """Test that we can set the digital state."""
    driver = MockGPIOPinDriver()
    pin = GPIOPin(
        0,
        driver,
        initial_mode=GPIOPinMode.DIGITAL_INPUT,
        hardware_modes={
            GPIOPinMode.DIGITAL_OUTPUT,
            GPIOPinMode.DIGITAL_INPUT,
            GPIOPinMode.DIGITAL_INPUT_PULLUP,
            GPIOPinMode.ANALOGUE_INPUT,
        },
    )

    pin.mode = GPIOPinMode.DIGITAL_OUTPUT
    pin.digital_state = True
    assert driver._written_digital_state[0]
    pin.digital_state = False
    assert not driver._written_digital_state[0]
Exemple #2
0
def test_digital_state_setter():
    """Test that we can set the digital state."""
    driver = MockGPIOPinDriver()
    pin = GPIOPin(
        0,
        MockGPIOPinBoard(),
        driver,
        supported_modes=[
            GPIOPinMode.DIGITAL_OUTPUT,
            GPIOPinMode.DIGITAL_INPUT,
            GPIOPinMode.DIGITAL_INPUT_PULLUP,
            GPIOPinMode.ANALOGUE_INPUT,
        ],
    )

    pin.mode = GPIOPinMode.DIGITAL_OUTPUT
    pin.digital_state = True
    assert driver._written_digital_state[0]
    pin.digital_state = False
    assert not driver._written_digital_state[0]