本文整理汇总了Python中gpiozero.pins.mock.MockPin.drive_high方法的典型用法代码示例。如果您正苦于以下问题:Python MockPin.drive_high方法的具体用法?Python MockPin.drive_high怎么用?Python MockPin.drive_high使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gpiozero.pins.mock.MockPin
的用法示例。
在下文中一共展示了MockPin.drive_high方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_input_is_active
# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_high [as 别名]
def test_input_is_active():
pin = MockPin(2)
with InputDevice(pin, pull_up=True) as device:
pin.drive_high()
assert not device.is_active
pin.drive_low()
assert device.is_active
示例2: test_mock_pin_edges
# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_high [as 别名]
def test_mock_pin_edges():
pin = MockPin(5)
assert pin.when_changed is None
fired = Event()
pin.function = 'input'
pin.edges = 'both'
assert pin.edges == 'both'
pin.drive_low()
assert not pin.state
def changed():
fired.set()
pin.when_changed = changed
pin.drive_high()
assert pin.state
assert fired.wait(0)
fired.clear()
pin.edges = 'falling'
pin.drive_low()
assert not pin.state
assert fired.wait(0)
fired.clear()
pin.drive_high()
assert pin.state
assert not fired.wait(0)
assert pin.edges == 'falling'
示例3: test_mock_pin_edges
# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_high [as 别名]
def test_mock_pin_edges():
pin = MockPin(2)
assert pin.when_changed is None
fired = Event()
pin.function = "input"
pin.edges = "both"
assert pin.edges == "both"
pin.drive_low()
assert not pin.state
def changed():
fired.set()
pin.when_changed = changed
pin.drive_high()
assert pin.state
assert fired.wait(0)
fired.clear()
pin.edges = "falling"
pin.drive_low()
assert not pin.state
assert fired.wait(0)
fired.clear()
pin.drive_high()
assert pin.state
assert not fired.wait(0)
assert pin.edges == "falling"
示例4: test_input_event_activated
# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_high [as 别名]
def test_input_event_activated():
event = Event()
pin = MockPin(2)
with DigitalInputDevice(pin) as device:
device.when_activated = lambda: event.set()
assert not event.is_set()
pin.drive_high()
assert event.is_set()
示例5: test_input_is_active_high
# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_high [as 别名]
def test_input_is_active_high():
pin = MockPin(2)
with InputDevice(pin, pull_up=False) as device:
pin.drive_high()
assert device.is_active
assert repr(device) == '<gpiozero.InputDevice object on pin MOCK2, pull_up=False, is_active=True>'
pin.drive_low()
assert not device.is_active
assert repr(device) == '<gpiozero.InputDevice object on pin MOCK2, pull_up=False, is_active=False>'
示例6: test_input_motion_sensor
# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_high [as 别名]
def test_input_motion_sensor():
pin = MockPin(2)
with MotionSensor(pin) as sensor:
pin.drive_high()
assert sensor.wait_for_motion(1)
assert sensor.motion_detected
pin.drive_low()
assert sensor.wait_for_no_motion(1)
assert not sensor.motion_detected
示例7: test_input_line_sensor
# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_high [as 别名]
def test_input_line_sensor():
pin = MockPin(2)
with LineSensor(pin) as sensor:
pin.drive_low() # logic is inverted for line sensor
assert sensor.wait_for_line(1)
assert sensor.line_detected
pin.drive_high()
assert sensor.wait_for_no_line(1)
assert not sensor.line_detected
示例8: test_input_smoothed_values
# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_high [as 别名]
def test_input_smoothed_values():
pin = MockPin(2)
with SmoothedInputDevice(pin) as device:
device._queue.start()
assert not device.is_active
pin.drive_high()
assert device.wait_for_active(1)
pin.drive_low()
assert device.wait_for_inactive(1)
示例9: test_input_button
# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_high [as 别名]
def test_input_button():
pin = MockPin(2)
with Button(pin) as button:
assert pin.pull == 'up'
assert not button.is_pressed
pin.drive_low()
assert button.is_pressed
assert button.wait_for_press(1)
pin.drive_high()
assert not button.is_pressed
assert button.wait_for_release(1)
示例10: test_input_partial_callback
# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_high [as 别名]
def test_input_partial_callback():
event = Event()
pin = MockPin(2)
def foo(a, b):
event.set()
return a + b
bar = partial(foo, 1)
baz = partial(bar, 2)
with DigitalInputDevice(pin) as device:
device.when_activated = baz
assert not event.is_set()
pin.drive_high()
assert event.is_set()
示例11: test_input_wait_active
# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_high [as 别名]
def test_input_wait_active():
pin = MockPin(2)
with DigitalInputDevice(pin) as device:
pin.drive_high()
assert device.wait_for_active(1)
assert not device.wait_for_inactive(0)