Exemple #1
0
def set_pins_as_inputs(exportpins):
    '''Set all the configured pins as inputs.'''
    if exportpins and not WiringPiStub.is_stubbed():
        subprocess.check_call([_GPIO_UTILITY_PATH, 'unexportall'])

    for i in range(GPIOLEN):
        set_pin_as_input(i, exportpins)

    if exportpins:
        wiringpi.wiringPiSetupSys()
Exemple #2
0
def set_pins_as_outputs(exportpins):
    '''Set all the configured pins as outputs.'''

    if exportpins and not WiringPiStub.is_stubbed():
        subprocess.check_call([_GPIO_UTILITY_PATH, 'unexportall'])

    for i in range(GPIOLEN):
        set_pin_as_output(i, exportpins)

    # When exporting pins via the gpio utility, you have to re-call wiringPiSetupSys after
    # after changing or exporting any pins.
    if exportpins:
        wiringpi.wiringPiSetupSys()
Exemple #3
0
def set_pin_as_output(i, exportpins):
    '''Set the specified pin as an output.'''

    if exportpins:
        if is_pin_pwm(i):
            # Error! Can't do PWM with gpio pin export
            logging.error("Cannot use gpio pin export with PWM")
        else:
            if not WiringPiStub.is_stubbed():
                subprocess.check_call([_GPIO_UTILITY_PATH, 'export', str(_GPIO_PINS[i]), 'out'])
    else:
        wiringpi.pinMode(_GPIO_PINS[i], _GPIOASOUTPUT)
        if is_pin_pwm(i):
            wiringpi.softPwmCreate(_GPIO_PINS[i], 0, _PWM_MAX)
Exemple #4
0
def set_pin_as_input(i, exportpins):
    '''Set the specified pin as an input.'''
    if exportpins and not WiringPiStub.is_stubbed():
        subprocess.check_call([_GPIO_UTILITY_PATH, 'export', str(_GPIO_PINS[i]), 'in'])
    else:
        wiringpi.pinMode(_GPIO_PINS[i], _GPIOASINPUT)