Esempio n. 1
0
def test_ultrasound_pulse_on_same_pin() -> None:
    """Test same pin for trigger and echo."""
    backend = SBArduinoConsoleBackend(
        "TestBoard",
        console_class=MockConsole,
    )

    backend._console.next_input = "2345"  # type: ignore
    assert backend.get_ultrasound_pulse(3, 3) == timedelta(microseconds=2345)

    # Check backend updated its view of what modes the pins are in now.
    assert backend.get_gpio_pin_mode(3) is GPIOPinMode.DIGITAL_INPUT
Esempio n. 2
0
def test_ultrasound_pulse() -> None:
    """Test that we can read an ultrasound pulse time."""
    backend = SBArduinoConsoleBackend(
        "TestBoard",
        console_class=MockConsole,
    )

    backend._console.next_input = "2345"  # type: ignore
    assert backend.get_ultrasound_pulse(3, 4) == timedelta(microseconds=2345)

    # Check backend updated its view of what modes the pins are in now.
    assert backend.get_gpio_pin_mode(3) is GPIOPinMode.DIGITAL_OUTPUT
    assert backend.get_gpio_pin_digital_state(3) is False
    assert backend.get_gpio_pin_mode(4) is GPIOPinMode.DIGITAL_INPUT