Raspberry
Functions
Section titled “Functions”Retrieve an ADC device that has been loaded.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the ADC device. |
Return Type: Adc Device
Signatures:
adc_device adc_device_named(const string &name)
public static AdcDevice SplashKit.AdcDeviceNamed(string name);
def adc_device_named(name):
function AdcDeviceNamed(const name: String): AdcDevice
Closes an ADC device given its pointer.
Parameters:
Name | Type | Description |
---|---|---|
adc | Adc Device | The ADC device to close. |
Signatures:
void close_adc(adc_device adc)
public static void SplashKit.CloseAdc(AdcDevice adc);
def close_adc(adc):
procedure CloseAdc(adc: AdcDevice)
Closes an ADC device given its name.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the ADC device to close. |
Signatures:
void close_adc(const string &name)
public static void SplashKit.CloseAdc(string name);
def close_adc_named(name):
procedure CloseAdc(const name: String)
Closes all ADC devices that have been opened.
Signatures:
void close_all_adc()
public static void SplashKit.CloseAllAdc();
def close_all_adc():
procedure CloseAllAdc()
Checks if an ADC device with the given name has been loaded.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name used to identify the ADC device. |
Return Type: Boolean
Signatures:
bool has_adc_device(const string &name)
public static bool SplashKit.HasAdcDevice(string name);
def has_adc_device(name):
function HasAdcDevice(const name: String): Boolean
Opens an ADC device with the specified name and type. Defaults to bus 1 and address 0x48.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the ADC device to open. |
type | Adc Type | The type of ADC device (e.g., ADS7830, PCF8591). |
Return Type: Adc Device
Signatures:
adc_device open_adc(const string &name, adc_type type)
public static AdcDevice SplashKit.OpenAdc(string name, AdcType type);public AdcDevice(string name, AdcType type);
def open_adc(name, type):
function OpenAdc(const name: String; type: AdcType): AdcDevice
Loads an ADC device on the specified I2C bus at a given address.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name to assign this ADC device. |
bus | Integer | The I2C bus number. |
address | Integer | The I2C address of the ADC device. |
type | Adc Type | The type of ADC device (e.g., ADS7830, PCF8591). |
Return Type: Adc Device
Signatures:
adc_device open_adc(const string &name, int bus, int address, adc_type type)
public static AdcDevice SplashKit.OpenAdc(string name, int bus, int address, AdcType type);public AdcDevice(string name, int bus, int address, AdcType type);
def open_adc_with_bus(name, bus, address, type):
function OpenAdc(const name: String; bus: Integer; address: Integer; type: AdcType): AdcDevice
Reads an 8-bit value from the specified ADC channel on the device.
Parameters:
Name | Type | Description |
---|---|---|
adc | Adc Device | The ADC device to read from. |
channel | Adc Pin | The channel number to read (range depends on ADC type). |
Return Type: Integer
Signatures:
int read_adc(adc_device adc, adc_pin channel)
public int AdcDevice.Read(AdcPin channel);public static int SplashKit.ReadAdc(AdcDevice adc, AdcPin channel);
def read_adc(adc, channel):
function ReadAdc(adc: AdcDevice; channel: AdcPin): Integer
Reads an 8-bit value from the specified ADC channel on the device using its name.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The ADC name string to close. |
channel | Adc Pin | The channel number to read (range depends on ADC type). |
Return Type: Integer
Signatures:
int read_adc(const string &name, adc_pin channel)
public static int SplashKit.ReadAdc(string name, AdcPin channel);
def read_adc_named(name, channel):
function ReadAdc(const name: String; channel: AdcPin): Integer
Checks if the system has GPIO capabilities.
Return Type: Boolean
Signatures:
bool has_gpio()
public static bool SplashKit.HasGpio();
def has_gpio():
function HasGpio(): Boolean
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()
public static void SplashKit.RaspiCleanup();
def raspi_cleanup():
procedure RaspiCleanup()
Usage: {</>}
This function retrieves the mode of the specified pin.
Parameters:
Name | Type | Description |
---|---|---|
pin | Gpio Pin | The pin to get the mode for. |
Return Type: Gpio Pin Mode
Signatures:
gpio_pin_mode raspi_get_mode(gpio_pin pin)
public static GpioPinMode SplashKit.RaspiGetMode(GpioPin pin);
def raspi_get_mode(pin):
function RaspiGetMode(pin: GpioPin): GpioPinMode
This function initializes the GPIO library for use. It should be called before any other GPIO functions.
Signatures:
void raspi_init()
public static void SplashKit.RaspiInit();
def raspi_init():
procedure RaspiInit()
Usage: {</>}
This function reads the value from the specified pin.
Parameters:
Name | Type | Description |
---|---|---|
pin | Gpio Pin | The pin to read the value from. |
Return Type: Gpio Pin Value
Signatures:
gpio_pin_value raspi_read(gpio_pin pin)
public static GpioPinValue SplashKit.RaspiRead(GpioPin pin);
def raspi_read(pin):
function RaspiRead(pin: GpioPin): GpioPinValue
Usage: {</>}
This function sets the mode of the specified pin to the specified mode.
Parameters:
Name | Type | Description |
---|---|---|
pin | Gpio Pin | The pin to set the mode for. |
mode | Gpio Pin Mode | The mode to set for the pin. |
Signatures:
void raspi_set_mode(gpio_pin pin, gpio_pin_mode mode)
public static void SplashKit.RaspiSetMode(GpioPin pin, GpioPinMode mode);
def raspi_set_mode(pin, mode):
procedure RaspiSetMode(pin: GpioPin; mode: GpioPinMode)
Usage: {</>}
This function sets the pull-up/down mode for the specified pin.
Parameters:
Name | Type | Description |
---|---|---|
pin | Gpio Pin | The pin to set the pull up/down mode for. |
pud | Pull Up Down | The pull up/down mode to set for the pin. |
Signatures:
void raspi_set_pull_up_down(gpio_pin pin, pull_up_down pud)
public static void SplashKit.RaspiSetPullUpDown(GpioPin pin, PullUpDown pud);
def raspi_set_pull_up_down(pin, pud):
procedure RaspiSetPullUpDown(pin: GpioPin; pud: PullUpDown)
Usage: {</>}
This function sets the PWM duty cycle for the specified pin.
Parameters:
Name | Type | Description |
---|---|---|
pin | Gpio Pin | The pin to set the PWM duty cycle for. |
dutycycle | Integer | The PWM duty cycle to set for the pin. |
Signatures:
void raspi_set_pwm_dutycycle(gpio_pin pin, int dutycycle)
public static void SplashKit.RaspiSetPwmDutycycle(GpioPin pin, int dutycycle);
def raspi_set_pwm_dutycycle(pin, dutycycle):
procedure RaspiSetPwmDutycycle(pin: GpioPin; dutycycle: Integer)
Usage: {</>}
This function sets the PWM frequency for the specified pin.
Parameters:
Name | Type | Description |
---|---|---|
pin | Gpio Pin | The pin to set the PWM frequency for. |
frequency | Integer | The PWM frequency to set for the pin. |
Signatures:
void raspi_set_pwm_frequency(gpio_pin pin, int frequency)
public static void SplashKit.RaspiSetPwmFrequency(GpioPin pin, int frequency);
def raspi_set_pwm_frequency(pin, frequency):
procedure RaspiSetPwmFrequency(pin: GpioPin; frequency: Integer)
Usage: {</>}
This function sets the PWM range for the specified pin. Valid values for the range are 25 - 40000
Parameters:
Name | Type | Description |
---|---|---|
pin | Gpio Pin | The pin to set the PWM range for. |
range | Integer | The PWM range to set for the pin. |
Signatures:
void raspi_set_pwm_range(gpio_pin pin, int range)
public static void SplashKit.RaspiSetPwmRange(GpioPin pin, int range);
def raspi_set_pwm_range(pin, range):
procedure RaspiSetPwmRange(pin: GpioPin; range: Integer)
Usage: {</>}
This function closes SPI communication on a particular channel.
Parameters:
Name | Type | Description |
---|---|---|
handle | Integer | A reference to the specific SPI connection to close. |
Return Type: Integer
Signatures:
int raspi_spi_close(int handle)
public static int SplashKit.RaspiSpiClose(int handle);
def raspi_spi_close(handle):
function RaspiSpiClose(handle: Integer): Integer
This function opens SPI communication on a particular channel. It will return -1 if not using Raspberry Pi.
Parameters:
Name | Type | Description |
---|---|---|
channel | Integer | The SPI channel to use. |
speed | Integer | The speed of data transfer (in baud). |
spi_flags | Integer | Optional flags for the SPI modes and settings. |
Return Type: Integer
Signatures:
int raspi_spi_open(int channel, int speed, int spi_flags)
public static int SplashKit.RaspiSpiOpen(int channel, int speed, int spiFlags);
def raspi_spi_open(channel, speed, spi_flags):
function RaspiSpiOpen(channel: Integer; speed: Integer; spiFlags: Integer): Integer
This function transfers data through SPI, it sends data from sendBuf and receives it into recvBuf.
Parameters:
Name | Type | Description |
---|---|---|
handle | Integer | The reference for a specific SPI connection. |
send | String | The data to send. |
count | Integer | The number of bytes to be transferred. |
bytes_transfered | Integer | The number of bytes transferred (output) |
Return Type: String
Signatures:
string raspi_spi_transfer(int handle, const string &send, int count, int &bytes_transfered)
public static string SplashKit.RaspiSpiTransfer(int handle, string send, int count, ref int bytesTransfered);
def raspi_spi_transfer(handle, send, count, bytes_transfered):
function RaspiSpiTransfer(handle: Integer; const send: String; count: Integer; var bytesTransfered: Integer): String
This function writes the specified value to the specified pin.
Parameters:
Name | Type | Description |
---|---|---|
pin | Gpio Pin | The pin to write the value to. |
value | Gpio Pin Value | The value to write to the pin. |
Signatures:
void raspi_write(gpio_pin pin, gpio_pin_value value)
public static void SplashKit.RaspiWrite(GpioPin pin, GpioPinValue value);
def raspi_write(pin, value):
procedure RaspiWrite(pin: GpioPin; value: GpioPinValue)
Usage: {</>}
This function closes the connection to the remote Raspberry Pi and releases any resources associated with it.
Parameters:
Name | Type | Description |
---|---|---|
pi | Connection | The connection object to the remote Raspberry Pi. |
Return Type: Boolean
Signatures:
bool remote_raspi_cleanup(connection pi)
public static bool SplashKit.RemoteRaspiCleanup(Connection pi);
def remote_raspi_cleanup(pi):
function RemoteRaspiCleanup(pi: Connection): Boolean
This function retrieves the mode of a specific pin on a remote Raspberry Pi.
Parameters:
Name | Type | Description |
---|---|---|
pi | Connection | The connection object to the remote Raspberry Pi. |
pin | Gpio Pin | The pin to get the mode for. |
Return Type: Gpio Pin Mode
Signatures:
gpio_pin_mode remote_raspi_get_mode(connection pi, gpio_pin pin)
public static GpioPinMode SplashKit.RemoteRaspiGetMode(Connection pi, GpioPin pin);
def remote_raspi_get_mode(pi, pin):
function RemoteRaspiGetMode(pi: Connection; pin: GpioPin): GpioPinMode
This function initialises a connection to a remote Raspberry Pi using the specified name, host, and port.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the connection. |
host | String | The host address of the Raspberry Pi. |
port | unsigned short | The port to use for the connection. |
Return Type: Connection
Signatures:
connection remote_raspi_init(const string &name, const string &host, unsigned short port)
public static Connection SplashKit.RemoteRaspiInit(string name, string host, ushort port);
def remote_raspi_init(name, host, port):
function RemoteRaspiInit(const name: String; const host: String; port: Word): Connection
This function reads the value from a specific pin on a remote Raspberry Pi.
Parameters:
Name | Type | Description |
---|---|---|
pi | Connection | The connection object to the remote Raspberry Pi. |
pin | Gpio Pin | The pin to read the value from. |
Return Type: Gpio Pin Value
Signatures:
gpio_pin_value remote_raspi_read(connection pi, gpio_pin pin)
public static GpioPinValue SplashKit.RemoteRaspiRead(Connection pi, GpioPin pin);
def remote_raspi_read(pi, pin):
function RemoteRaspiRead(pi: Connection; pin: GpioPin): GpioPinValue
This function sets the mode of a specific pin on a remote Raspberry Pi.
Parameters:
Name | Type | Description |
---|---|---|
pi | Connection | The connection object to the remote Raspberry Pi. |
pin | Gpio Pin | The pin to set the mode for. |
mode | Gpio Pin Mode | The mode to set for the pin. |
Signatures:
void remote_raspi_set_mode(connection pi, gpio_pin pin, gpio_pin_mode mode)
public static void SplashKit.RemoteRaspiSetMode(Connection pi, GpioPin pin, GpioPinMode mode);
def remote_raspi_set_mode(pi, pin, mode):
procedure RemoteRaspiSetMode(pi: Connection; pin: GpioPin; mode: GpioPinMode)
This function sets the pull-up/down mode of a specific pin on a remote Raspberry Pi.
Parameters:
Name | Type | Description |
---|---|---|
pi | Connection | The connection object to the remote Raspberry Pi. |
pin | Gpio Pin | The pin to set the pull up/down mode for. |
pud | Pull Up Down | The 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)
public static void SplashKit.RemoteRaspiSetPullUpDown(Connection pi, GpioPin pin, PullUpDown pud);
def remote_raspi_set_pull_up_down(pi, pin, pud):
procedure RemoteRaspiSetPullUpDown(pi: Connection; pin: GpioPin; pud: PullUpDown)
This function sets the PWM duty cycle for a specific pin on a remote Raspberry Pi.
Parameters:
Name | Type | Description |
---|---|---|
pi | Connection | The connection object to the remote Raspberry Pi. |
pin | Gpio Pin | The pin to set the PWM duty cycle for. |
dutycycle | Integer | The PWM duty cycle to set for the pin. |
Signatures:
void remote_raspi_set_pwm_dutycycle(connection pi, gpio_pin pin, int dutycycle)
public static void SplashKit.RemoteRaspiSetPwmDutycycle(Connection pi, GpioPin pin, int dutycycle);
def remote_raspi_set_pwm_dutycycle(pi, pin, dutycycle):
procedure RemoteRaspiSetPwmDutycycle(pi: Connection; pin: GpioPin; dutycycle: Integer)
This function sets the PWM frequency for a specific pin on a remote Raspberry Pi.
Parameters:
Name | Type | Description |
---|---|---|
pi | Connection | The connection object to the remote Raspberry Pi. |
pin | Gpio Pin | The pin to set the PWM frequency for. |
frequency | Integer | The PWM frequency to set for the pin. |
Signatures:
void remote_raspi_set_pwm_frequency(connection pi, gpio_pin pin, int frequency)
public static void SplashKit.RemoteRaspiSetPwmFrequency(Connection pi, GpioPin pin, int frequency);
def remote_raspi_set_pwm_frequency(pi, pin, frequency):
procedure RemoteRaspiSetPwmFrequency(pi: Connection; pin: GpioPin; frequency: Integer)
This function sets the PWM range for a specific pin on a remote Raspberry Pi. Valid values for the range are 25 - 40000
Parameters:
Name | Type | Description |
---|---|---|
pi | Connection | The connection object to the remote Raspberry Pi. |
pin | Gpio Pin | The pin to set the PWM range for. |
range | Integer | The PWM range to set for the pin. |
Signatures:
void remote_raspi_set_pwm_range(connection pi, gpio_pin pin, int range)
public static void SplashKit.RemoteRaspiSetPwmRange(Connection pi, GpioPin pin, int range);
def remote_raspi_set_pwm_range(pi, pin, range):
procedure RemoteRaspiSetPwmRange(pi: Connection; pin: GpioPin; range: Integer)
This function writes a specified value to a specific pin on a remote Raspberry Pi.
Parameters:
Name | Type | Description |
---|---|---|
pi | Connection | The connection object to the remote Raspberry Pi. |
pin | Gpio Pin | The pin to write the value to. |
value | Gpio Pin Value | The value to write to the pin. |
Signatures:
void remote_raspi_write(connection pi, gpio_pin pin, gpio_pin_value value)
public static void SplashKit.RemoteRaspiWrite(Connection pi, GpioPin pin, GpioPinValue value);
def remote_raspi_write(pi, pin, value):
procedure RemoteRaspiWrite(pi: Connection; pin: GpioPin; value: GpioPinValue)
The Adc Device
type is used to refer to ADC (Analog-to-Digital Converter)
devices that can be managed by the SplashKit ADC code. ADC devices are:
-
loaded with
load_adc_device
, -
accessed using
Adc Device Named
or checked withHas Adc Device
, -
read using
read_adc_channel
to retrieve analog values from specific channels, -
and must be released using
free_adc_device
(to release a specific ADC device) orfree_all_adc_devices
(to release all loaded ADC devices).
ADC devices allow you to interface with external analog sensors or inputs, converting their signals into digital values for processing in your application.
You can check if an ADC device is loaded using Has Adc Device
.
Use free_adc_device
to release resources associated with a specific ADC device,
or free_all_adc_devices
to clean up all ADC devices.