本文整理匯總了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),
])
示例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),
])
示例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),
])
示例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),
])
示例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)
])
示例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)
])
示例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)
])
示例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)