For the complete documentation index, see llms.txt. This page is also available as Markdown.

Device 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:

Code-Snippet

int days;
int hours;
int minutes;
int seconds;
int milliseconds;

main {
    milliseconds += get_rtime();

    if(milliseconds >= 1000) { // Check if we have 1000 or more milliseconds passed
        milliseconds -= 1000 // Subtract 1000 from the milliseconds value, this ensures accuracy as the timing may not be precise
        seconds++; // Increment the seconds counter
    }

    if(seconds == 60) { // Check if 60 seconds has passed (1 minute)
        seconds = 0; // Reset the seconds counter to 0
        minutes++; // Increment the minutes counter
    }

    if(minutes == 60) { // Check if 60 minutes has passed (1 hour)
        minutes = 0; // Reset the minutes counter to 0
        hours++; // Increment the hours counter
    }

    if(hours == 24) { // Check if 24 hours has passed (1 day)
        hours = 0; // Reset the hours counter to 0
        days++; // Increment the days counter
    }

    set_val(TRACE_1, milliseconds); // Output the milliseconds to TRACE_1
    set_val(TRACE_2, seconds); // Output the seconds to TRACE_2
    set_val(TRACE_3, minutes); // Output the minutes to TRACE_3
    set_val(TRACE_4, hours); // Output the hours to TRACE_4
    set_val(TRACE_5, days); // Output the days to TRACE_5
}

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.

Code-Snippet

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.

Code-Snippet

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.

Code-Snippet

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.

Code-Snippet

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.

Code-Snippet

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.

Code-Snippet

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

Last updated