예제 #1
0
def test_commands(monkeypatch):
    command_log = []

    def capture_write(value, path):
        command_log.append((value, path))

    monkeypatch.setattr(gpio, '_write_value', capture_write)

    gpio.set_high(gpio.OUTPUT_PINS['HALT'])
    gpio.set_low(gpio.OUTPUT_PINS['RED_BUTTON'])

    expected_log = [
        # Set command sequence
        (gpio.HIGH, "{0}/gpio{1}/value".format(gpio._path_prefix,
                                               gpio.OUTPUT_PINS['HALT'])
         ),  # NOQA
        (gpio.LOW, "{0}/gpio{1}/value".format(gpio._path_prefix,
                                              gpio.OUTPUT_PINS['RED_BUTTON'])
         )  # NOQA
    ]

    assert command_log == expected_log
예제 #2
0
def button_red():
    gpio.set_high(gpio.OUTPUT_PINS['RED_BUTTON'])
    gpio.set_low(gpio.OUTPUT_PINS['GREEN_BUTTON'])
    gpio.set_low(gpio.OUTPUT_PINS['BLUE_BUTTON'])
예제 #3
0
#!/usr/bin/env python
from time import sleep

from opentrons.drivers.rpi_drivers import gpio

# set the direction of each gpio (in or out)
gpio.initialize()

# audio-enable pin can stay HIGH always, unless there is noise coming
# from the amplifier, then we can set to LOW to disable the amplifier
gpio.set_high(gpio.OUTPUT_PINS['AUDIO_ENABLE'])

# smoothieware programming pins, must be in a known state (HIGH)
gpio.set_high(gpio.OUTPUT_PINS['HALT'])
gpio.set_high(gpio.OUTPUT_PINS['ISP'])
gpio.set_low(gpio.OUTPUT_PINS['RESET'])
sleep(0.25)
gpio.set_high(gpio.OUTPUT_PINS['RESET'])
sleep(0.25)

# turn light to blue
gpio.turn_on_blue_button_light()