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

Device, timing, remapper, and BVAR built-ins

These functions affect VM timing, active slots, device settings, LEDs, or persistent binary-variable storage. Treat slot changes and persistent writes as deliberate user actions, never background work at the base of main.

get_rtime

Compiler category: Miscellaneous Functions Backing opcode: grtime

Returns the elapsed time between the current and previous main iterations.

Syntax

elapsed_ms = get_rtime();

Parameters

None.

Returns

Elapsed milliseconds. The usual value is near the VM interval, but it can change with timing control and runtime conditions.

Example

int elapsed_ms;

main {
    elapsed_ms = elapsed_ms + get_rtime();
    if(elapsed_ms >= 1000) elapsed_ms = elapsed_ms - 1000;
    set_val(TRACE_1, elapsed_ms);
}

Subtract the threshold instead of resetting to zero when accumulated timing should retain overshoot.


get_slot

Compiler category: Miscellaneous Functions Backing opcode: gslot

Returns the currently active Zen memory slot.

Syntax

Parameters

None.

Returns

The active slot number.

Example

Refresh the cached value only when the script design has a reason to expect a slot-state change.


load_slot

Compiler category: Miscellaneous Functions Backing opcode: lslot

Immediately attempts to load a slot. Slot 0 unloads the current programmed slot; the accepted range is 0..8.

Syntax

Parameters

  • slot: 0..8.

Returns

Nothing. Loading occurs immediately, so code after the call must not be relied on.

Example

Use an intentional chord to prevent accidental slot changes.


get_ctrlbutton

Compiler category: Controller I/O Functions Backing opcode: gctrlbtn

Returns the configured remote slot-control button mode from the Zen device settings.

Syntax

Parameters

None.

Returns

The configured control-button mode; the supplied Live documentation identifies values 0, 1, and 8.

Example

Treat the result as device configuration data, not as a controller report identifier.


vm_tctrl

Compiler category: Miscellaneous Functions Backing opcode: vmtctrl

Applies an offset to the VM interval for the next iteration.

Syntax

Parameters

  • timeout_offset: compiler-accepted range -9..30 relative to the normal interval.

Returns

Nothing.

Example

Shorter intervals increase VM work and may reduce stability. Measure VM load and controller behavior before keeping a non-default value.


set_rgb

Compiler category: Leds Backing opcode: setRGB

Sets the Zen/controller LED color with red, green, and blue components.

Syntax

Parameters

  • red, green, blue: each 0..255.

Returns

Nothing.

Example

Render on a state change instead of rewriting the same color every cycle.


set_hsb

Compiler category: Leds Backing opcode: setHSB

Sets the Zen/controller LED color using hue, saturation, and brightness.

Syntax

Parameters

  • hue: 0..360 degrees.

  • saturation: 0..100 percent.

  • brightness: 0..100 percent.

Returns

Nothing.

Example


get_info

Compiler category: Miscellaneous Functions Backing opcode: ginfo

Queries a value from the active mouse-and-keyboard profile or related Live device state.

Syntax

Parameters

  • selector: numeric selector accepted by the exact Live build.

Returns

The selected information value.

Example

Use the documented Zen Studio Live selector constants whenever possible. Confirm any raw numeric selector against the intended Live build before relying on its meaning.


set_remapper

Compiler category: Leds Backing opcode: set_remapper

Changes one entry in the device-level remapper. This is different from a script remap declaration because it modifies device configuration.

Syntax

Parameters

  • identifier_from: BUTTON_MIN..BUTTON_MAX.

  • identifier_to: BUTTON_MIN..BUTTON_MAX.

Returns

Nothing.

Example

Use a guarded, explicit action. A device remapper change can affect scripts beyond the current slot.


save_eeprom

Compiler category: Leds Backing opcode: save_eeprom

Persists changed device settings to EEPROM.

Syntax

Parameters

None.

Returns

Nothing.

Example

EEPROM has a finite write life. Never call this unconditionally in main.


get_bvar

Compiler category: Binary variables Backing opcode: gbvar

Reads one indexed BVAR value on the 32-bit target.

Syntax

Parameters

  • index: 0..1023.

Returns

The value stored at the selected index.

Example

Validate loaded data before using it, and reserve index ranges so unrelated records cannot overlap.


set_bvar

Compiler category: Binary variables Backing opcode: sbvar

Writes one indexed BVAR value on the 32-bit target.

Syntax

Parameters

  • index: 0..1023.

  • value: current-target signed integer expression. Device-test storage width and signed round trips for the intended firmware.

Returns

Nothing.

Example

Use named schema constants, bounds-check computed indexes, and write only on an explicit save/change event.

Back to the additional built-in index

Last updated