System API
Overview
The System API in MatrixOS provides core system functions including timing, application management, device control, and system utilities. The System API is available as MatrixOS.SYS
and is imported by default.
The Python System API is implemented in Applications/Python/PikaPython/MatrixOS_SYS.py with type hints in Applications/Python/PikaPython/_MatrixOS_SYS.pyi.
Version Information
MatrixOS.SYS.GetVersion
def GetVersion() -> tuple
Returns the current MatrixOS version as a tuple of major, minor, and patch version numbers.
Returns:
tuple
: A tuple containing (major, minor, patch) version numbers
Example:
version = MatrixOS.SYS.GetVersion()
major, minor, patch = version
print(f"MatrixOS Version: {major}.{minor}.{patch}")
# Example: Check if version is at least 3.0.0
if version >= (3, 0, 0):
print("Version 3.0.0 or newer detected")
Device Control
MatrixOS.SYS.Reboot
def Reboot() -> None
Reboots the MatrixOS device. The device will restart and boot normally.
Example:
MatrixOS.SYS.Reboot() # Device will restart
MatrixOS.SYS.Bootloader
def Bootloader() -> None
Reboots the device into bootloader mode for firmware updates.
Example:
MatrixOS.SYS.Bootloader() # Enter bootloader for firmware update
Timing Functions
MatrixOS.SYS.DelayMs
def DelayMs(ms: int) -> None
Delays execution for the specified number of milliseconds.
Parameters:
ms
(int
): Delay duration in milliseconds
Example:
MatrixOS.SYS.DelayMs(1000) # Wait 1 second
print("One second has passed")
MatrixOS.SYS.Millis
def Millis() -> int
Returns the number of milliseconds since the device started.
Returns:
int
: Milliseconds since boot
Example:
start_time = MatrixOS.SYS.Millis()
# ... do some work ...
elapsed = MatrixOS.SYS.Millis() - start_time
print(f"Operation took {elapsed} ms")
MatrixOS.SYS.Micros
def Micros() -> int
Returns the number of microseconds since the device started.
Returns:
int
: Microseconds since boot
Example:
start_time = MatrixOS.SYS.Micros()
# ... precise timing operation ...
elapsed = MatrixOS.SYS.Micros() - start_time
print(f"Precise timing: {elapsed} microseconds")
Application Management
MatrixOS.SYS.OpenSetting
def OpenSetting() -> None
Opens the system settings application.
Example:
MatrixOS.SYS.OpenSetting() # Launch settings app