当前位置: 首页>>代码示例>>Python>>正文


Python MockPin.drive_low方法代码示例

本文整理汇总了Python中gpiozero.pins.mock.MockPin.drive_low方法的典型用法代码示例。如果您正苦于以下问题:Python MockPin.drive_low方法的具体用法?Python MockPin.drive_low怎么用?Python MockPin.drive_low使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gpiozero.pins.mock.MockPin的用法示例。


在下文中一共展示了MockPin.drive_low方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_input_is_active

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_low [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
开发者ID:ChiangFamily,项目名称:python-gpiozero,代码行数:9,代码来源:test_inputs.py

示例2: test_mock_pin_edges

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_low [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'
开发者ID:alaudet,项目名称:python-gpiozero,代码行数:27,代码来源:test_mock_pin.py

示例3: test_mock_pin_edges

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_low [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"
开发者ID:pcopa,项目名称:python-gpiozero,代码行数:29,代码来源:test_mock_pin.py

示例4: test_input_is_active_high

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_low [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>'
开发者ID:DougieLawson,项目名称:python-gpiozero,代码行数:11,代码来源:test_inputs.py

示例5: test_input_motion_sensor

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_low [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
开发者ID:DougieLawson,项目名称:python-gpiozero,代码行数:11,代码来源:test_inputs.py

示例6: test_input_line_sensor

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_low [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
开发者ID:DougieLawson,项目名称:python-gpiozero,代码行数:11,代码来源:test_inputs.py

示例7: test_input_smoothed_values

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_low [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)
开发者ID:DougieLawson,项目名称:python-gpiozero,代码行数:11,代码来源:test_inputs.py

示例8: test_input_event_deactivated

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_low [as 别名]
def test_input_event_deactivated():
    event = Event()
    pin = MockPin(2)
    with DigitalInputDevice(pin) as device:
        device.when_deactivated = lambda: event.set()
        assert not event.is_set()
        pin.drive_high()
        assert not event.is_set()
        pin.drive_low()
        assert event.is_set()
开发者ID:DougieLawson,项目名称:python-gpiozero,代码行数:12,代码来源:test_inputs.py

示例9: test_input_button

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_low [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)
开发者ID:DougieLawson,项目名称:python-gpiozero,代码行数:13,代码来源:test_inputs.py

示例10: test_traffic_lights_buzzer

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import drive_low [as 别名]
def test_traffic_lights_buzzer():
    red_pin = MockPin(2)
    amber_pin = MockPin(3)
    green_pin = MockPin(4)
    buzzer_pin = MockPin(5)
    button_pin = MockPin(6)
    with TrafficLightsBuzzer(
            TrafficLights(red_pin, amber_pin, green_pin),
            Buzzer(buzzer_pin),
            Button(button_pin)) as board:
        board.lights.red.on()
        board.buzzer.on()
        assert red_pin.state
        assert not amber_pin.state
        assert not green_pin.state
        assert buzzer_pin.state
        button_pin.drive_low()
        assert board.button.is_active
开发者ID:ChiangFamily,项目名称:python-gpiozero,代码行数:20,代码来源:test_boards.py


注:本文中的gpiozero.pins.mock.MockPin.drive_low方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。