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



gpio_analog_read

Description

Reads an analog value of a given pin.


Syntax

value = gh_rpi.gpio_analog_read(
 pin
)

Languages


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


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


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


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


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_digital_write_byte(value)
			


gpio_get_alt

Description

Returns the ALT bits for a given pin.


Syntax

x = gh_rpi.gpio_get_alt(
 pin
)

Languages


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

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

Languages


Parameters

This function has no input parameter(s).


Return Values


Code sample


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


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


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_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


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


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


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


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_set_gpio_clock(pin, freq)
			


gpio_set_pad_drive

Description

Sets the PAD driver value.


Syntax

gh_rpi.gpio_set_pad_drive(
 group,
 value
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_set_pad_drive(group, value)
			


gpio_set_pin_mode

Description

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


Syntax

gh_rpi.gpio_set_pin_mode(
 mode
)

Languages


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


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_set_pin_mode_alt(pin, mode)
			


gpio_set_pmw_clock

Description

Sets the PWM clock.


Syntax

gh_rpi.gpio_set_pmw_clock(
 divisor
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_set_pmw_clock(divisor)
			


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


Parameters


Return Values

This function has no return value(s).


Code sample


gh_rpi.gpio_set_pull_up_down_control(pin, pud)
			


gpio_set_pwm_mode

Description

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


Syntax

gh_rpi.gpio_set_pwm_mode(
 mode
)

Languages


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


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


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


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


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


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

nh, nw = gh_rpi.rgbmatrix_get_num_pixels()

Languages


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

num_bits = gh_rpi.rgbmatrix_get_pwmbits()

Languages


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_panels
)

Languages


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


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


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


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(
 num_bits
)

Languages


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


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