GLSL Hacker
FEATURES DOWNLOAD GALLERY BLOG LEARN



Back to Reference Guide Index

gh_rpi Library

Description

gh_rpi is the module that manages the Raspberry Pi (RPi) GPIO programming.

Number of functions: 20



gh_rpi.gpio_init

Description

Initializes the access to the RPi. Must be called once in a INIT script.

Languages

Lua - Python

Parameters

  • pin_mode [INTEGER]: sets the pin numbering mode: 0 (wirinPi mode), 1 (GPIO mode), 2 (GPIO system mode) and 3 (physical mode).

    Return Values

    This function has no return value(s).

    Code sample


    GPIO_PINS_MAPPING_MODE_GPIO = 1
    GPIO_PINS_MAPPING_MODE_PHYSICAL = 3
    gh_rpi.gpio_init(GPIO_PINS_MAPPING_MODE_GPIO)



    gh_rpi.gpio_get_board_info

    Description

    Returns information about the Raspberry Pi board.

    Languages

    Lua - Python

    Parameters

    This function has no input parameter(s).

    Return Values

  • model [STRING]: model of the board.
  • rev [STRING]: revision of the board.
  • maker [STRING]: maker of the board.
  • memsize [STRING]: memory size available on the board.

    Code sample


    model, rev, maker, memsize = gh_rpi.gpio_get_board_info()



    gh_rpi.gpio_set_pin_mode

    Description

    Sets the GPIO pin mode: input, output, PWM output, etc..

    Languages

    Lua - Python

    Parameters

  • mode [INTEGER]: pin mode: 0 (INPUT), 1 (OUTPUT), 2 (PWM_OUTPUT), 3 (GPIO_CLOCK), 4 (SOFT_PWM_OUTPUT), 5 (SOFT_TONE_OUTPUT) and 6 (PWM_TONE_OUTPUT).

    Return Values

    This function has no return value(s).

    Code sample


    GPIO_MODE_OUTPUT = 1
    gh_rpi.mgpio_set_pin_mode(GPIO_MODE_OUTPUT)



    gh_rpi.gpio_digital_write

    Description

    Writes an output bit.

    Languages

    Lua - Python

    Parameters

  • pin [INTEGER]: pin number.
  • value [INTEGER]: 0 (LOW) or 1 (HIGH).

    Return Values

    This function has no return value(s).

    Code sample


    pin = 23
    state = 1
    gh_rpi.gpio_digital_write(pin, state)



    gh_rpi.gpio_digital_read

    Description

    Reads the value of a given pin, returning 1 (HIGH) or 0 (LOW).

    Languages

    Lua - Python

    Parameters

  • pin [INTEGER]: pin number.

    Return Values

  • value [INTEGER]: 1 (HIGH) or 0 (LOW).

    Code sample


    pin = 23
    value = gh_rpi.gpio_digital_read(pin)



    gh_rpi.gpio_analog_write

    Description

    Writes the analog value to the given pin.

    Languages

    Lua - Python

    Parameters

  • pin [INTEGER]: pin number.
  • value [INTEGER]: analog value

    Return Values

    This function has no return value(s).

    Code sample


    gh_rpi.gpio_analog_write(pin, value)



    gh_rpi.gpio_analog_read

    Description

    Reads an analog value of a given pin.

    Languages

    Lua - Python

    Parameters

  • pin [INTEGER]: pin number.

    Return Values

  • value [INTEGER]: analog value.

    Code sample


    value = gh_rpi.gpio_analog_read(pin)



    gh_rpi.gpio_pwm_write

    Description

    Writes an output PWM value.

    Languages

    Lua - Python

    Parameters

  • pin [INTEGER]: pin number.
  • value [INTEGER]: PWM value

    Return Values

    This function has no return value(s).

    Code sample


    gh_rpi.gpio_pwm_write(pin, value)



    gh_rpi.gpio_pwm_tone_write

    Description

    Writes the given frequency on the RPi's PWM pin.

    Languages

    Lua - Python

    Parameters

  • pin [INTEGER]: pin number.
  • freq [INTEGER]: frequency

    Return Values

    This function has no return value(s).

    Code sample


    gh_rpi.gpio_pwm_tone_write(pin, freq)



    gh_rpi.gpio_digital_write_byte

    Description

    Writes an 8-bit byte to the first 8 GPIO pins.

    Languages

    Lua - Python

    Parameters

  • value [INTEGER]: 8-bit value

    Return Values

    This function has no return value(s).

    Code sample


    gh_rpi.gpio_digital_write_byte(value)



    gh_rpi.gpio_set_pull_up_down_control

    Description

    Controls the internal pull-up/down resistors on a GPIO pin.

    Languages

    Lua - Python

    Parameters

  • pin [INTEGER]: pin number.
  • pud [INTEGER]: pull-up/down resistors value

    Return Values

    This function has no return value(s).

    Code sample


    gh_rpi.gpio_set_pull_up_down_control(pin, pud)



    gh_rpi.gpio_set_pin_mode_alt

    Description

    Special function that lets you set any pin to any mode.

    Languages

    Lua - Python

    Parameters

  • pin [INTEGER]: pin number.
  • mode [INTEGER]: mode

    Return Values

    This function has no return value(s).

    Code sample


    gh_rpi.gpio_set_pin_mode_alt(pin, mode)



    gh_rpi.gpio_set_gpio_clock

    Description

    Sets the frequency of a GPIO clock pin.

    Languages

    Lua - Python

    Parameters

  • pin [INTEGER]: pin number.
  • freq [INTEGER]: frequency

    Return Values

    This function has no return value(s).

    Code sample


    gh_rpi.gpio_set_gpio_clock(pin, freq)



    gh_rpi.gpio_set_pmw_clock

    Description

    Sets the PWM clock.

    Languages

    Lua - Python

    Parameters

  • divisor [INTEGER]: frequency divisor

    Return Values

    This function has no return value(s).

    Code sample


    gh_rpi.gpio_set_pmw_clock(divisor)



    gh_rpi.gpio_set_pwm_range

    Description

    Sets the PWM range register.

    Languages

    Lua - Python

    Parameters

  • range [INTEGER]: PWM range

    Return Values

    This function has no return value(s).

    Code sample


    gh_rpi.gpio_set_pwm_range(range)



    gh_rpi.gpio_set_pwm_mode

    Description

    Selects the native balanced mode, or standard mark:space mode.

    Languages

    Lua - Python

    Parameters

  • mode [INTEGER]: PWM mode: 0 (PWM_MODE_MS) or 1 (PWM_MODE_BAL)

    Return Values

    This function has no return value(s).

    Code sample


    gh_rpi.gpio_set_pwm_mode(mode)



    gh_rpi.gpio_get_alt

    Description

    Returns the ALT bits for a given pin.

    Languages

    Lua - Python

    Parameters

  • pin [INTEGER]: pin number.

    Return Values

  • x [INTEGER]: ALT bits.

    Code sample


    x = gh_rpi.gpio_get_alt(pin)



    gh_rpi.gpio_set_pad_drive

    Description

    Sets the PAD driver value.

    Languages

    Lua - Python

    Parameters

  • group [INTEGER]: group.
  • value [INTEGER]: value.

    Return Values

    This function has no return value(s).

    Code sample


    gh_rpi.gpio_set_pad_drive(group, value)



    gh_rpi.gpio_wpi_pin_to_gpio

    Description

    Translates a wiringPi pin number to native GPIO pin number.

    Languages

    Lua - Python

    Parameters

  • wpi_pin [INTEGER]: wiringPi pin number.

    Return Values

  • gpio_pin [INTEGER]: GPIO pin number.

    Code sample


    gpio_pin = gh_rpi.gpio_wpi_pin_to_gpio(wpi_pin)



    gh_rpi.gpio_phys_pin_to_gpio

    Description

    Translates a physical pin number to native GPIO pin number.

    Languages

    Lua - Python

    Parameters

  • phys_pin [INTEGER]: Physical pin number.

    Return Values

  • gpio_pin [INTEGER]: GPIO pin number.

    Code sample


    gpio_pin = gh_rpi.gpio_phys_pin_to_gpio(phys_pin)





    2013-2015 Geeks3D. All Rights Reserved.

    .:- G3D Network -:.