Skip to content

Raspberry

Functions

Has Gpio

Checks if the system has GPIO capabilities.

Return Type: Boolean

Signatures:

bool has_gpio()

Raspi Cleanup  {</>}

This function should be called when you are finished using the GPIO library. It sets all pin modes to INPUT and values to LOW.

Signatures:

void raspi_cleanup()

Usage:  {</>}


Raspi Get Mode

This function retrieves the mode of the specified pin.

Parameters:

NameTypeDescription
pinGpio PinThe pin to get the mode for.

Return Type: Gpio Pin Mode

Signatures:

gpio_pin_mode raspi_get_mode(gpio_pin pin)

Raspi Init  {</>}

This function initializes the GPIO library for use. It should be called before any other GPIO functions.

Signatures:

void raspi_init()

Usage:  {</>}


Raspi Read  {</>}

This function reads the value from the specified pin.

Parameters:

NameTypeDescription
pinGpio PinThe pin to read the value from.

Return Type: Gpio Pin Value

Signatures:

gpio_pin_value raspi_read(gpio_pin pin)

Usage:  {</>}


Raspi Set Mode  {</>}

This function sets the mode of the specified pin to the specified mode.

Parameters:

NameTypeDescription
pinGpio PinThe pin to set the mode for.
modeGpio Pin ModeThe mode to set for the pin.

Signatures:

void raspi_set_mode(gpio_pin pin, gpio_pin_mode mode)

Usage:  {</>}


Raspi Set Pull Up Down  {</>}

This function sets the pull-up/down mode for the specified pin.

Parameters:

NameTypeDescription
pinGpio PinThe pin to set the pull up/down mode for.
pudPull Up DownThe pull up/down mode to set for the pin.

Signatures:

void raspi_set_pull_up_down(gpio_pin pin, pull_up_down pud)

Usage:  {</>}


Raspi Set Pwm Dutycycle  {</>}

This function sets the PWM duty cycle for the specified pin.

Parameters:

NameTypeDescription
pinGpio PinThe pin to set the PWM duty cycle for.
dutycycleIntegerThe PWM duty cycle to set for the pin.

Signatures:

void raspi_set_pwm_dutycycle(gpio_pin pin, int dutycycle)

Usage:  {</>}


Raspi Set Pwm Frequency  {</>}

This function sets the PWM frequency for the specified pin.

Parameters:

NameTypeDescription
pinGpio PinThe pin to set the PWM frequency for.
frequencyIntegerThe PWM frequency to set for the pin.

Signatures:

void raspi_set_pwm_frequency(gpio_pin pin, int frequency)

Usage:  {</>}


Raspi Set Pwm Range  {</>}

This function sets the PWM range for the specified pin. Valid values for the range are 25 - 40000

Parameters:

NameTypeDescription
pinGpio PinThe pin to set the PWM range for.
rangeIntegerThe PWM range to set for the pin.

Signatures:

void raspi_set_pwm_range(gpio_pin pin, int range)

Usage:  {</>}


Raspi Spi Close

This function closes SPI communication on a particular channel.

Parameters:

NameTypeDescription
handleIntegerA reference to the specific SPI connection to close.

Return Type: Integer

Signatures:

int raspi_spi_close(int handle)

Raspi Spi Open

This function opens SPI communication on a particular channel. It will return -1 if not using Raspberry Pi.

Parameters:

NameTypeDescription
channelIntegerThe SPI channel to use.
speedIntegerThe speed of data transfer (in baud).
spi_flagsIntegerOptional flags for the SPI modes and settings.

Return Type: Integer

Signatures:

int raspi_spi_open(int channel, int speed, int spi_flags)

Raspi Spi Transfer

This function transfers data through SPI, it sends data from sendBuf and receives it into recvBuf.

Parameters:

NameTypeDescription
handleIntegerThe reference for a specific SPI connection.
sendStringThe data to send.
countIntegerThe number of bytes to be transferred.
bytes_transferedIntegerThe number of bytes transferred (output)

Return Type: String

Signatures:

string raspi_spi_transfer(int handle, const string &send, int count, int &bytes_transfered)

Raspi Write  {</>}

This function writes the specified value to the specified pin.

Parameters:

NameTypeDescription
pinGpio PinThe pin to write the value to.
valueGpio Pin ValueThe value to write to the pin.

Signatures:

void raspi_write(gpio_pin pin, gpio_pin_value value)

Usage:  {</>}


Remote Raspi Cleanup

This function closes the connection to the remote Raspberry Pi and releases any resources associated with it.

Parameters:

NameTypeDescription
piConnectionThe connection object to the remote Raspberry Pi.

Return Type: Boolean

Signatures:

bool remote_raspi_cleanup(connection pi)

Remote Raspi Get Mode

This function retrieves the mode of a specific pin on a remote Raspberry Pi.

Parameters:

NameTypeDescription
piConnectionThe connection object to the remote Raspberry Pi.
pinGpio PinThe pin to get the mode for.

Return Type: Gpio Pin Mode

Signatures:

gpio_pin_mode remote_raspi_get_mode(connection pi, gpio_pin pin)

Remote Raspi Init

This function initialises a connection to a remote Raspberry Pi using the specified name, host, and port.

Parameters:

NameTypeDescription
nameStringThe name of the connection.
hostStringThe host address of the Raspberry Pi.
portunsigned shortThe port to use for the connection.

Return Type: Connection

Signatures:

connection remote_raspi_init(const string &name, const string &host, unsigned short port)

Remote Raspi Read

This function reads the value from a specific pin on a remote Raspberry Pi.

Parameters:

NameTypeDescription
piConnectionThe connection object to the remote Raspberry Pi.
pinGpio PinThe pin to read the value from.

Return Type: Gpio Pin Value

Signatures:

gpio_pin_value remote_raspi_read(connection pi, gpio_pin pin)

Remote Raspi Set Mode

This function sets the mode of a specific pin on a remote Raspberry Pi.

Parameters:

NameTypeDescription
piConnectionThe connection object to the remote Raspberry Pi.
pinGpio PinThe pin to set the mode for.
modeGpio Pin ModeThe mode to set for the pin.

Signatures:

void remote_raspi_set_mode(connection pi, gpio_pin pin, gpio_pin_mode mode)

Remote Raspi Set Pull Up Down

This function sets the pull-up/down mode of a specific pin on a remote Raspberry Pi.

Parameters:

NameTypeDescription
piConnectionThe connection object to the remote Raspberry Pi.
pinGpio PinThe pin to set the pull up/down mode for.
pudPull Up DownThe pull up/down mode to set for the pin.

Signatures:

void remote_raspi_set_pull_up_down(connection pi, gpio_pin pin, pull_up_down pud)

Remote Raspi Set Pwm Dutycycle

This function sets the PWM duty cycle for a specific pin on a remote Raspberry Pi.

Parameters:

NameTypeDescription
piConnectionThe connection object to the remote Raspberry Pi.
pinGpio PinThe pin to set the PWM duty cycle for.
dutycycleIntegerThe PWM duty cycle to set for the pin.

Signatures:

void remote_raspi_set_pwm_dutycycle(connection pi, gpio_pin pin, int dutycycle)

Remote Raspi Set Pwm Frequency

This function sets the PWM frequency for a specific pin on a remote Raspberry Pi.

Parameters:

NameTypeDescription
piConnectionThe connection object to the remote Raspberry Pi.
pinGpio PinThe pin to set the PWM frequency for.
frequencyIntegerThe PWM frequency to set for the pin.

Signatures:

void remote_raspi_set_pwm_frequency(connection pi, gpio_pin pin, int frequency)

Remote Raspi Set Pwm Range

This function sets the PWM range for a specific pin on a remote Raspberry Pi. Valid values for the range are 25 - 40000

Parameters:

NameTypeDescription
piConnectionThe connection object to the remote Raspberry Pi.
pinGpio PinThe pin to set the PWM range for.
rangeIntegerThe PWM range to set for the pin.

Signatures:

void remote_raspi_set_pwm_range(connection pi, gpio_pin pin, int range)

Remote Raspi Write

This function writes a specified value to a specific pin on a remote Raspberry Pi.

Parameters:

NameTypeDescription
piConnectionThe connection object to the remote Raspberry Pi.
pinGpio PinThe pin to write the value to.
valueGpio Pin ValueThe value to write to the pin.

Signatures:

void remote_raspi_write(connection pi, gpio_pin pin, gpio_pin_value value)