< GeeXLab Reference Guide />

> Back to Reference Guide Index


gh_rpi library

Description

gh_rpi is the module that manages the Raspberry Pi (RPi) GPIO and RGB LED matrix panel programming.


Number of functions: 31

  1. gh_rpi.gpio_analog_read (Lua - Python)
  2. gh_rpi.gpio_analog_write (Lua - Python)
  3. gh_rpi.gpio_digital_read (Lua - Python)
  4. gh_rpi.gpio_digital_write (Lua - Python)
  5. gh_rpi.gpio_digital_write_byte (Lua - Python)
  6. gh_rpi.gpio_init (Lua - Python)
  7. gh_rpi.gpio_get_alt (Lua - Python)
  8. gh_rpi.gpio_get_board_info (Lua - Python)
  9. gh_rpi.gpio_phys_pin_to_gpio (Lua - Python)
  10. gh_rpi.gpio_pwm_tone_write (Lua - Python)
  11. gh_rpi.gpio_pwm_write (Lua - Python)
  12. gh_rpi.gpio_set_gpio_clock (Lua - Python)
  13. gh_rpi.gpio_set_pin_mode (Lua - Python)
  14. gh_rpi.gpio_set_pin_mode_alt (Lua - Python)
  15. gh_rpi.gpio_set_pad_drive (Lua - Python)
  16. gh_rpi.gpio_set_pull_up_down_control (Lua - Python)
  17. gh_rpi.gpio_set_pmw_clock (Lua - Python)
  18. gh_rpi.gpio_set_pwm_mode (Lua - Python)
  19. gh_rpi.gpio_set_pwm_range (Lua - Python)
  20. gh_rpi.gpio_wpi_pin_to_gpio (Lua - Python)
  21. gh_rpi.rgbmatrix_fill_f32 (Lua - Python)
  22. gh_rpi.rgbmatrix_fill_u8 (Lua - Python)
  23. gh_rpi.rgbmatrix_get_luminance_correct (Lua - Python)
  24. gh_rpi.rgbmatrix_get_num_pixels (Lua - Python)
  25. gh_rpi.rgbmatrix_get_pwmbits (Lua - Python)
  26. gh_rpi.rgbmatrix_init (Lua - Python)
  27. gh_rpi.rgbmatrix_set_luminance_correct (Lua - Python)
  28. gh_rpi.rgbmatrix_set_pixel_f32 (Lua - Python)
  29. gh_rpi.rgbmatrix_set_pixel_u8 (Lua - Python)
  30. gh_rpi.rgbmatrix_set_pwmbits (Lua - Python)
  31. gh_rpi.rgbmatrix_terminate (Lua - Python)



gpio_analog_read

Description

Reads an analog value of a given pin.


Syntax

value = gh_rpi.gpio_analog_read(
 pin
)

Languages

Lua - Python


Parameters


Return Values


Code sample


value = gh_rpi.gpio_analog_read(pin)
            


gpio_analog_write

Description

Writes the analog value to the given pin.


Syntax

gh_rpi.gpio_analog_write(
 pin,
 value
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_analog_write(pin, value)
            


gpio_digital_read

Description

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


Syntax

value = gh_rpi.gpio_digital_read(
 pin
)

Languages

Lua - Python


Parameters


Return Values


Code sample


pin = 23
value = gh_rpi.gpio_digital_read(pin)
            


gpio_digital_write

Description

Writes an output bit.


Syntax

gh_rpi.gpio_digital_write(
 pin,
 value
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


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


gpio_digital_write_byte

Description

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


Syntax

gh_rpi.gpio_digital_write_byte(
 value
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_digital_write_byte(value)
            


gpio_init

Description

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


Syntax

gh_rpi.gpio_init(
 pin_mode
)

Languages

Lua - Python


Parameters


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)
            


gpio_get_alt

Description

Returns the ALT bits for a given pin.


Syntax

x = gh_rpi.gpio_get_alt(
 pin
)

Languages

Lua - Python


Parameters


Return Values


Code sample


x = gh_rpi.gpio_get_alt(pin)
            


gpio_get_board_info

Description

Returns information about the Raspberry Pi board.


Syntax

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

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


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


gpio_phys_pin_to_gpio

Description

Translates a physical pin number to native GPIO pin number.


Syntax

gpio_pin = gh_rpi.gpio_phys_pin_to_gpio(
 phys_pin
)

Languages

Lua - Python


Parameters


Return Values


Code sample


gpio_pin = gh_rpi.gpio_phys_pin_to_gpio(phys_pin)
            


gpio_pwm_tone_write

Description

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


Syntax

gh_rpi.gpio_pwm_tone_write(
 pin,
 freq
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_pwm_tone_write(pin, freq)
            


gpio_pwm_write

Description

Writes an output PWM value.


Syntax

gh_rpi.gpio_pwm_write(
 pin,
 value
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_pwm_write(pin, value)
            


gpio_set_gpio_clock

Description

Sets the frequency of a GPIO clock pin.


Syntax

gh_rpi.gpio_set_gpio_clock(
 pin,
 freq
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_set_gpio_clock(pin, freq)
            


gpio_set_pin_mode

Description

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


Syntax

gh_rpi.gpio_set_pin_mode(
 mode
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


GPIO_MODE_OUTPUT = 1
gh_rpi.mgpio_set_pin_mode(GPIO_MODE_OUTPUT)
            


gpio_set_pin_mode_alt

Description

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


Syntax

gh_rpi.gpio_set_pin_mode_alt(
 pin,
 mode
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_set_pin_mode_alt(pin, mode)
            


gpio_set_pad_drive

Description

Sets the PAD driver value.


Syntax

gh_rpi.gpio_set_pad_drive(
 group,
 value
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_set_pad_drive(group, value)
            


gpio_set_pull_up_down_control

Description

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


Syntax

gh_rpi.gpio_set_pull_up_down_control(
 pin,
 pud
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_set_pull_up_down_control(pin, pud)
            


gpio_set_pmw_clock

Description

Sets the PWM clock.


Syntax

gh_rpi.gpio_set_pmw_clock(
 divisor
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_set_pmw_clock(divisor)
            


gpio_set_pwm_mode

Description

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


Syntax

gh_rpi.gpio_set_pwm_mode(
 mode
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_set_pwm_mode(mode)
            


gpio_set_pwm_range

Description

Sets the PWM range register.


Syntax

gh_rpi.gpio_set_pwm_range(
 range
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_set_pwm_range(range)
            


gpio_wpi_pin_to_gpio

Description

Translates a wiringPi pin number to native GPIO pin number.


Syntax

gpio_pin = gh_rpi.gpio_wpi_pin_to_gpio(
 wpi_pin
)

Languages

Lua - Python


Parameters


Return Values


Code sample


gpio_pin = gh_rpi.gpio_wpi_pin_to_gpio(wpi_pin)
            


rgbmatrix_fill_f32

Description

Clears all LEDs with an uniform color.


Syntax

gh_rpi.rgbmatrix_fill_f32(
 r,
 g,
 b
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.rgbmatrix_fill_u8(1.0, 0, 0)
            


rgbmatrix_fill_u8

Description

Clears all LEDs with an uniform color.


Syntax

gh_rpi.rgbmatrix_fill_u8(
 r,
 g,
 b
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.rgbmatrix_fill_u8(255, 0, 0)
            


rgbmatrix_get_luminance_correct

Description

Gets the luminance correct state.


Syntax

state = gh_rpi.rgbmatrix_get_luminance_correct()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


state = gh_rpi.rgbmatrix_get_luminance_correct()
            


rgbmatrix_get_num_pixels

Description

Returns the numbers of LEDs (or pixels).


Syntax

nw, nh = gh_rpi.rgbmatrix_get_num_pixels()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


num_leds_x, num_leds_y = gh_rpi.rgbmatrix_get_num_pixels()
            


rgbmatrix_get_pwmbits

Description

Gets the number of bits for color representation: from 1 bit for simple color to 11 bits for true color.


Syntax

bits = gh_rpi.rgbmatrix_get_pwmbits()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


bits = gh_rpi.rgbmatrix_get_pwmbits()
            


rgbmatrix_init

Description

Initializes the functions to deal with RGB LED matrix panels (following the HUB75 interface).


Syntax

ret = gh_rpi.rgbmatrix_init(
 num_rows,
 num_chained_displays
)

Languages

Lua - Python


Parameters


Return Values


Code sample


ret = gh_rpi.rgbmatrix_init(32, 1)
            


rgbmatrix_set_luminance_correct

Description

Map brightness of output linearly to input with CIE1931 profile.


Syntax

state = gh_rpi.rgbmatrix_set_luminance_correct()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


gh_rpi.rgbmatrix_set_luminance_correct(1)
            


rgbmatrix_set_pixel_f32

Description

Sets the color of a particular LED (or pixel).


Syntax

gh_rpi.rgbmatrix_set_pixel_f32(
 x,
 y,
 r,
 g,
 b
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.rgbmatrix_set_pixel_f32(7, 8,   1.0, 0, 0)
            


rgbmatrix_set_pixel_u8

Description

Sets the color of a particular LED (or pixel).


Syntax

gh_rpi.rgbmatrix_set_pixel_u8(
 x,
 y,
 r,
 g,
 b
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.rgbmatrix_set_pixel_u8(7, 8,   255, 0, 0)
            


rgbmatrix_set_pwmbits

Description

Sets the number of bits for color representation: from 1 bit for simple color to 11 bits for true color.


Syntax

gh_rpi.rgbmatrix_set_pwmbits(
 bits
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.rgbmatrix_set_pwmbits(11)
            


rgbmatrix_terminate

Description

Terminates and cleanup functions to deal with RGB LED matrix panels.


Syntax

gh_rpi.rgbmatrix_terminate()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values

This function has no return value(s).


Code sample


gh_rpi.rgbmatrix_terminate()
            






GeeXLab Rootard Guide | Downloads | Contact | Newsletter