GPC Developer Guides
...
Functions
Internal Functions

Device Functions

Here we will cover a few functions available within your code, these functions

Function

Description

get_rtime

Returns the elapsed time between main iterations in milliseconds.

get_slot

Returns the active slot number.

load_slot

Loads a specified slot.

get_ctrlbutton

Returns the identifier of the controller button.

vm_tctrl

Sets the vm timeout for the next iteration.

set_rgb

Sets the LED on the ZEN to the supplied RGB color.

set_hsb

Sets the LED on the ZEN to the supplied HSB color.

get_rtime

get_rtime returns the elapsed time between the current and previous iteration of the main function. The value returned is in milliseconds.

You can see this function in action by using this counter script:

GPC


🔴 Syntax

get_rtime();

Parameters

None

🔵 Returns

The elapsed time, in milliseconds, since the last main iteration, default is 10ms but is dependant on the use of vm_tctrl

get_slot

get_slot returns an int value representing the current active slot of the Cronus Device.

GPC


🔴 Syntax

get_slot();

Parameters

None

🔵 Returns

An int value represents the current active slot of the Cronus Device.

load_slot

load_slot will attempt to load the slot number specified within its parameter. If there is no script current stored in the specified slot, then it will unload the current slot and load slot 0 of the device.

GPC


🔴 Syntax

load_slot ( <slot_number> );

Parameters

<slot_number> : A value which represents a slot number to load with a range of 0 - 8.

🔵 Returns

Note: Any code after this statement will not be executed as the new slot is loaded immediately and any changes made by the current script will be kept during the first execution of the loaded slot

get_ctrlbutton

get_ctrlbutton returns the current control button. The control button is set in the Device Tab of the Zen Studio this basically lets you know which button combo is configured to switch slots using the remote slot configuration

GPC


🔴 Syntax

get_ctrlbutton();

Parameters

Nothing

🔵 Returns

Depending on the remote slot settings the value can be 0, 1 or 8

vm_tctrl

vm_tctrl sets the virtual machine timeout for the next iteration. By default, the virtual machine runs the main loop every 10 milliseconds as it aids stability. You can however adjust how often each main iteration is run. Just be aware that changing this setting may cause instability within your script.

GPC


🔴 Syntax

vm_tctrl( <timeout_offset> );

Parameters

<timeout_offset> : Numeric value to add to the Virtual Machine base time. Range -9 ~ 30

🔵 Returns

Nothing

set_rgb

set_rgb sets the LED colors on the Zen eyes or a Playstation controller based on the Hue, Saturation, and Brightness.

GPC


🔴 Syntax

set_rgb( <red> , <green> , <blue> );

Parameters

<red> : The amount of red to use with a range of 0 - 255 <green> : The amount of green to use with a range of 0 - 255 <blue> : The amount of blue to use with a range of 0 - 255

🔵 Returns

Nothing

set_hsb

set_hsb sets the LED colors on the Zen eyes or a Playstation controller based on the Hue, Saturation, and Brightness.

GPC


🔴 Syntax

set_hsb( <hue>, <saturation>, <brightness> );

Parameters

<hue> : The hue (color on a 360 degree wheel) to use with a range of 0 - 359 <saturation> : The saturation (amount of color) to use with a range of 0 - 100 <brightness> : The brightness (amount of white) to use with a range of 0 - 100

🔵 Returns

Nothing