Device Functions
Here we will cover a few functions available within your code, these functions
Function | Description | Zen | Plus |
---|---|---|---|
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_polar | Sets the stick output at a given angle and radius with a high resolution value | ✔️ | ❌ |
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 | ✔️ | ❌ |
clamp function | The clamp() function clamps a value between an upper and lower bound. clamp() enables selecting a middle value within a range of values between a defined minimum and maximum. It takes three parameters: a minimum value, a preferred value, and a maximum allowed value. | ✔️ | ❌ |
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:
🔴 Syntax
get_rtime ( );
⚪ Parameters
None
🔵 Returns
The elapsed time, in milliseconds, between the main iteration
get_slot returns an int value representing the current active slot of the Cronus Device.
🔴 Syntax
getslot();
⚪ Parameters
None
🔵 Returns
An int value representing the current active slot of the Cronus Device.
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.
🔴 Syntax
load_slot ( <slot_number> );
⚪ Parameters
<slot_number> : A value which represents a slot number to load with a range of 0 - 9 on Cronus MAX Plus or 0 - 8 on Cronus ZEN.
🔵 Returns
Nothing
get_ctrlbutton returns the current control button. The control button is set in the Device tab within Cronus PRO's Options window or the Device Tab of the Cronus Zen. The enable remote control switch on device dictates which button it is set to
🔴 Syntax
get_ctrlbutton( );
⚪ Parameters
Nothing
🔵 Returns
Depending on the remote slot settings the value can be 0, 1 or 8.
opcode 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 than changing this setting may cause instability within your script.
🔴 Syntax
vm_tctrl( <variable> );
⚪ Parameters
<variable> : Numeric value to add to the Virtual Machine base time. Range -9 ~ 10
🔵 Returns
Nothing
Sets the stick output at a given angle and radius with a high resolution value
🔴 Syntax¹ ² ³
set_polar(stick,angle,radius);
⚪ Parameters
stick: defined stick.
angle: index point of the bit to be set with a range of 0 to 359.
radius: index point of the bit to be set with a range of -32768 to 32767.
🔵 Returns
Nothing
Sets the LED on the ZEN to the supplied RGB color (Red,Green,Blue).
🔴 Syntax¹ ² ³
set_rgb(red,green,blue);
⚪ Parameters
-
-
-
🔵 Returns
Nothing
set_hsb sets the LED colors on the Zen eyes or a Playstation controller based on the Hue, Saturation, and Brightness.
🔴 Syntax¹ ² ³
set_hsb( Hue, Saturation, Brightness);
⚪ Parameters
-
-
-
🔵 Returns
Nothing
The clamp function clamps x to the range [min, max].
🔴 Syntax¹ ² ³
clamp(x, min, max)
⚪ Parameters
x— The number to clamp. min— Lower bound of range to which x is clamped. Minimum value returned. max— Upper bound of range to which x is clamped. Maximum value returned.
🔵 Returns
Returns min if x is less than min, max if x is greater than max, and x otherwise.;