當前位置: 首頁>>代碼示例>>Python>>正文


Python MockPWMPin.assert_states_and_times方法代碼示例

本文整理匯總了Python中gpiozero.pins.mock.MockPWMPin.assert_states_and_times方法的典型用法代碼示例。如果您正苦於以下問題:Python MockPWMPin.assert_states_and_times方法的具體用法?Python MockPWMPin.assert_states_and_times怎麽用?Python MockPWMPin.assert_states_and_times使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gpiozero.pins.mock.MockPWMPin的用法示例。


在下文中一共展示了MockPWMPin.assert_states_and_times方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_output_pwm_pulse_foreground

# 需要導入模塊: from gpiozero.pins.mock import MockPWMPin [as 別名]
# 或者: from gpiozero.pins.mock.MockPWMPin import assert_states_and_times [as 別名]
def test_output_pwm_pulse_foreground():
    pin = MockPWMPin(2)
    with PWMOutputDevice(pin) as device:
        start = time()
        device.pulse(0.2, 0.2, n=2, background=False)
        assert isclose(time() - start, 0.8, abs_tol=0.05)
        pin.assert_states_and_times([
            (0.0, 0),
            (0.04, 0.2),
            (0.04, 0.4),
            (0.04, 0.6),
            (0.04, 0.8),
            (0.04, 1),
            (0.04, 0.8),
            (0.04, 0.6),
            (0.04, 0.4),
            (0.04, 0.2),
            (0.04, 0),
            (0.04, 0.2),
            (0.04, 0.4),
            (0.04, 0.6),
            (0.04, 0.8),
            (0.04, 1),
            (0.04, 0.8),
            (0.04, 0.6),
            (0.04, 0.4),
            (0.04, 0.2),
            (0.04, 0),
            ])
開發者ID:EdwardBetts,項目名稱:python-gpiozero,代碼行數:31,代碼來源:test_outputs.py

示例2: test_output_pwm_fade_foreground

# 需要導入模塊: from gpiozero.pins.mock import MockPWMPin [as 別名]
# 或者: from gpiozero.pins.mock.MockPWMPin import assert_states_and_times [as 別名]
def test_output_pwm_fade_foreground():
    pin = MockPWMPin(2)
    device = PWMOutputDevice(pin)
    device.blink(0, 0, 0.1, 0.1, n=2, background=False)
    pin.assert_states_and_times([
        (0.0, 0),
        (0.02, 0.2),
        (0.02, 0.4),
        (0.02, 0.6),
        (0.02, 0.8),
        (0.02, 1),
        (0.02, 0.8),
        (0.02, 0.6),
        (0.02, 0.4),
        (0.02, 0.2),
        (0.02, 0),
        (0.02, 0.2),
        (0.02, 0.4),
        (0.02, 0.6),
        (0.02, 0.8),
        (0.02, 1),
        (0.02, 0.8),
        (0.02, 0.6),
        (0.02, 0.4),
        (0.02, 0.2),
        (0.02, 0),
        ])
開發者ID:DeeJay,項目名稱:python-gpiozero,代碼行數:29,代碼來源:test_outputs.py

示例3: test_output_pwm_fade_background

# 需要導入模塊: from gpiozero.pins.mock import MockPWMPin [as 別名]
# 或者: from gpiozero.pins.mock.MockPWMPin import assert_states_and_times [as 別名]
def test_output_pwm_fade_background():
    pin = MockPWMPin(2)
    with PWMOutputDevice(pin) as device:
        start = time()
        device.blink(0, 0, 0.2, 0.2, n=2)
        assert isclose(time() - start, 0, abs_tol=0.05)
        device._blink_thread.join()
        assert isclose(time() - start, 0.8, abs_tol=0.05)
        pin.assert_states_and_times([
            (0.0, 0),
            (0.04, 0.2),
            (0.04, 0.4),
            (0.04, 0.6),
            (0.04, 0.8),
            (0.04, 1),
            (0.04, 0.8),
            (0.04, 0.6),
            (0.04, 0.4),
            (0.04, 0.2),
            (0.04, 0),
            (0.04, 0.2),
            (0.04, 0.4),
            (0.04, 0.6),
            (0.04, 0.8),
            (0.04, 1),
            (0.04, 0.8),
            (0.04, 0.6),
            (0.04, 0.4),
            (0.04, 0.2),
            (0.04, 0),
            ])
開發者ID:EdwardBetts,項目名稱:python-gpiozero,代碼行數:33,代碼來源:test_outputs.py

示例4: test_output_pwm_fade_background

# 需要導入模塊: from gpiozero.pins.mock import MockPWMPin [as 別名]
# 或者: from gpiozero.pins.mock.MockPWMPin import assert_states_and_times [as 別名]
def test_output_pwm_fade_background():
    pin = MockPWMPin(2)
    device = PWMOutputDevice(pin)
    device.blink(0, 0, 0.1, 0.1, n=2)
    device._blink_thread.join()
    pin.assert_states_and_times([
        (0.0, 0),
        (0.02, 0.2),
        (0.02, 0.4),
        (0.02, 0.6),
        (0.02, 0.8),
        (0.02, 1),
        (0.02, 0.8),
        (0.02, 0.6),
        (0.02, 0.4),
        (0.02, 0.2),
        (0.02, 0),
        (0.02, 0.2),
        (0.02, 0.4),
        (0.02, 0.6),
        (0.02, 0.8),
        (0.02, 1),
        (0.02, 0.8),
        (0.02, 0.6),
        (0.02, 0.4),
        (0.02, 0.2),
        (0.02, 0),
        ])
開發者ID:DeeJay,項目名稱:python-gpiozero,代碼行數:30,代碼來源:test_outputs.py

示例5: test_output_pwm_blink_foreground

# 需要導入模塊: from gpiozero.pins.mock import MockPWMPin [as 別名]
# 或者: from gpiozero.pins.mock.MockPWMPin import assert_states_and_times [as 別名]
def test_output_pwm_blink_foreground():
    pin = MockPWMPin(2)
    device = PWMOutputDevice(pin)
    device.blink(0.1, 0.1, n=2, background=False)
    pin.assert_states_and_times([
        (0.0, 0),
        (0.0, 1),
        (0.1, 0),
        (0.1, 1),
        (0.1, 0)
        ])
開發者ID:DeeJay,項目名稱:python-gpiozero,代碼行數:13,代碼來源:test_outputs.py

示例6: test_output_pwm_blink_background

# 需要導入模塊: from gpiozero.pins.mock import MockPWMPin [as 別名]
# 或者: from gpiozero.pins.mock.MockPWMPin import assert_states_and_times [as 別名]
def test_output_pwm_blink_background():
    pin = MockPWMPin(2)
    with PWMOutputDevice(pin) as device:
        device.blink(0.1, 0.1, n=2)
        device._blink_thread.join()
        pin.assert_states_and_times([
            (0.0, 0),
            (0.0, 1),
            (0.1, 0),
            (0.1, 1),
            (0.1, 0)
            ])
開發者ID:ChiangFamily,項目名稱:python-gpiozero,代碼行數:14,代碼來源:test_outputs.py

示例7: test_output_pwm_blink_foreground

# 需要導入模塊: from gpiozero.pins.mock import MockPWMPin [as 別名]
# 或者: from gpiozero.pins.mock.MockPWMPin import assert_states_and_times [as 別名]
def test_output_pwm_blink_foreground():
    pin = MockPWMPin(2)
    with PWMOutputDevice(pin) as device:
        start = time()
        device.blink(0.1, 0.1, n=2, background=False)
        assert isclose(time() - start, 0.4, abs_tol=0.05)
        pin.assert_states_and_times([
            (0.0, 0),
            (0.0, 1),
            (0.1, 0),
            (0.1, 1),
            (0.1, 0)
            ])
開發者ID:EdwardBetts,項目名稱:python-gpiozero,代碼行數:15,代碼來源:test_outputs.py

示例8: test_led_board_fade_background

# 需要導入模塊: from gpiozero.pins.mock import MockPWMPin [as 別名]
# 或者: from gpiozero.pins.mock.MockPWMPin import assert_states_and_times [as 別名]
def test_led_board_fade_background():
    pin1 = MockPWMPin(2)
    pin2 = MockPWMPin(3)
    pin3 = MockPWMPin(4)
    with LEDBoard(pin1, LEDBoard(pin2, pin3, pwm=True), pwm=True) as board:
        board.blink(0, 0, 0.2, 0.2, n=2)
        board._blink_thread.join()
        test = [
            (0.0, 0),
            (0.04, 0.2),
            (0.04, 0.4),
            (0.04, 0.6),
            (0.04, 0.8),
            (0.04, 1),
            (0.04, 0.8),
            (0.04, 0.6),
            (0.04, 0.4),
            (0.04, 0.2),
            (0.04, 0),
            (0.04, 0.2),
            (0.04, 0.4),
            (0.04, 0.6),
            (0.04, 0.8),
            (0.04, 1),
            (0.04, 0.8),
            (0.04, 0.6),
            (0.04, 0.4),
            (0.04, 0.2),
            (0.04, 0),
            ]
        pin1.assert_states_and_times(test)
        pin2.assert_states_and_times(test)
        pin3.assert_states_and_times(test)
開發者ID:ChiangFamily,項目名稱:python-gpiozero,代碼行數:35,代碼來源:test_boards.py


注:本文中的gpiozero.pins.mock.MockPWMPin.assert_states_and_times方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。