Skip to main content
Version: Matrix OS 4.0 🚧

SYS API

Overview​

MatrixOS.SYS provides system time, app lifecycle, and system actions.

import MatrixOS

now = MatrixOS.SYS.millis()
version = MatrixOS.SYS.version()
print(now, version)

Standalone Python apps that should keep running define loop() in their main file. Matrix OS calls loop() repeatedly after the file has loaded. A script with no loop() runs once and then exits.

MatrixOS.SYS.millis​

millis() -> int

Returns Matrix OS uptime in milliseconds.

Returns:

  • int: Millisecond tick value.

MatrixOS.SYS.micros​

micros() -> int

Returns Matrix OS uptime in microseconds.

Returns:

  • int: Microsecond tick value.

MatrixOS.SYS.sleep_ms​

sleep_ms(ms: int) -> None

Delays the current Python app for a fixed number of milliseconds.

Parameters:

  • ms: Delay duration in milliseconds.

Use sleep_ms() when you need an actual delay. Normal Python app loop() functions do not need to call task_yield(); return from loop() after the current batch of work instead.


MatrixOS.SYS.task_yield​

task_yield() -> None

Cooperatively yields from the current Python app.

Most apps should not call this from loop(). Use it only for unusual blocking code that cannot return to Matrix OS promptly.


MatrixOS.SYS.exit_app​

exit_app() -> None

Exits the current Python app and returns control to Matrix OS.

import MatrixOS

# Leave the LEDs in a known state before exiting.
MatrixOS.LED.clear()
MatrixOS.LED.update()

# Return control to Matrix OS.
MatrixOS.SYS.exit_app()

MatrixOS.SYS.reboot​

reboot() -> None

Requests a system reboot. If it succeeds, the current Python app stops running.


MatrixOS.SYS.bootloader​

bootloader() -> None

Requests bootloader mode. If it succeeds, the current Python app stops running.


MatrixOS.SYS.open_setting​

open_setting() -> None

Opens Matrix OS settings. If the app switch succeeds, the current Python app may stop running.


MatrixOS.SYS.execute_app (by app ID)​

execute_app(app_id: int) -> None

Launches an app by numeric app ID.

Parameters:

  • app_id: Numeric Matrix OS app ID.

MatrixOS.SYS.execute_app (by author and name)​

execute_app(author: str, app_name: str, args: list[str] = []) -> None

Launches an app by author and app name.

Parameters:

  • author: App author string.
  • app_name: App name string.
  • args: Optional argument list passed to the target app.

MatrixOS.SYS.version​

version() -> str

Returns the Matrix OS version string.

Returns:

  • str: Version string.

MatrixOS.SYS.version_id​

version_id() -> int

Returns the numeric Matrix OS version ID.

Returns:

  • int: Version ID.

Comments