pytest_rotary_encoder.py 799 B

123456789101112131415161718192021222324
  1. # SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: CC0-1.0
  3. import pytest
  4. from pytest_embedded.dut import Dut
  5. @pytest.mark.esp32
  6. @pytest.mark.esp32s2
  7. @pytest.mark.esp32s3
  8. @pytest.mark.esp32c6
  9. @pytest.mark.esp32h2
  10. @pytest.mark.generic
  11. def test_rotary_encoder(dut: Dut) -> None:
  12. dut.expect_exact('install pcnt unit')
  13. dut.expect_exact('set glitch filter')
  14. dut.expect_exact('install pcnt channels')
  15. dut.expect_exact('set edge and level actions for pcnt channels')
  16. dut.expect_exact('add watch points and register callbacks')
  17. dut.expect_exact('clear pcnt unit')
  18. dut.expect_exact('start pcnt unit')
  19. res = dut.expect(r'Pulse count: (\d+)')
  20. count_val = res.group(1).decode('utf8')
  21. assert -100 <= int(count_val) <= 100