Module: Toybox.System

Overview

The System module provides basic system information, including access to the clock time, device settings, battery level, and memory use.

Since:

API Level 1.0.0

Classes Under Namespace

Classes: AppNotInstalledException, ClockTime, ConnectionInfo, DeviceSettings, Intent, PreviousOperationNotCompleteException, ServiceDelegate, Stats, UnexpectedAppTypeException

Constant Summary

UnitsSystem

Since:

API Level 1.0.0

Name Value Since Description See Also
UNIT_METRIC 0

API Level 1.0.0

Display units in metric units

UNIT_STATUTE 1

API Level 1.0.0

Display units in statute units

ScreenShape

Since:

API Level 1.0.0

Name Value Since Description See Also
SCREEN_SHAPE_ROUND 1

API Level 1.2.0

SCREEN_SHAPE_SEMI_ROUND 2

API Level 1.2.0

SCREEN_SHAPE_RECTANGLE 3

API Level 1.2.0

SCREEN_SHAPE_SEMI_OCTAGON 4

API Level 3.3.0

ButtonInputs

Since:

API Level 1.0.0

Name Value Since Description See Also
BUTTON_INPUT_SELECT 0x00000001

API Level 1.2.0

BUTTON_INPUT_UP 0x00000002

API Level 1.2.0

BUTTON_INPUT_DOWN 0x00000004

API Level 1.2.0

BUTTON_INPUT_MENU 0x00000008

API Level 1.2.0

BUTTON_INPUT_CLOCK 0x00000010

API Level 3.1.0

BUTTON_INPUT_DOWN_LEFT 0x00000020

API Level 3.1.0

BUTTON_INPUT_DOWN_RIGHT 0x00000040

API Level 3.1.0

BUTTON_INPUT_ESC 0x00000080

API Level 3.1.0

BUTTON_INPUT_FIND 0x00000100

API Level 3.1.0

BUTTON_INPUT_LAP 0x00000200

API Level 3.1.0

BUTTON_INPUT_LEFT 0x00000400

API Level 3.1.0

BUTTON_INPUT_LIGHT 0x00000800

API Level 3.1.0

BUTTON_INPUT_MODE 0x00001000

API Level 3.1.0

BUTTON_INPUT_PAGE 0x00002000

API Level 3.1.0

BUTTON_INPUT_POWER 0x00004000

API Level 3.1.0

BUTTON_INPUT_RESET 0x00008000

API Level 3.1.0

BUTTON_INPUT_RIGHT 0x00010000

API Level 3.1.0

BUTTON_INPUT_SPORT 0x00020000

API Level 3.1.0

BUTTON_INPUT_START 0x00040000

API Level 3.1.0

BUTTON_INPUT_UP_LEFT 0x00080000

API Level 3.1.0

BUTTON_INPUT_UP_RIGHT 0x00100000

API Level 3.1.0

BUTTON_INPUT_ZIN 0x00200000

API Level 3.1.0

BUTTON_INPUT_ZOUT 0x00400000

API Level 3.1.0

ConnectionState

Since:

API Level 1.0.0

Name Value Since Description See Also
CONNECTION_STATE_NOT_INITIALIZED 0

API Level 3.0.0

Indicates that the connection is not setup or is inactive.

CONNECTION_STATE_NOT_CONNECTED 1

API Level 3.0.0

Indicates that the connection has been setup but is not in range.

CONNECTION_STATE_CONNECTED 2

API Level 3.0.0

Indicates that the connection is available for use.

Language

Since:

API Level 1.0.0

Name Value Since Description See Also
LANGUAGE_ARA 8389920

API Level 3.1.0

Arabic

LANGUAGE_BUL 8389921

API Level 3.1.0

Bulgarian

LANGUAGE_CES 8389352

API Level 3.1.0

Czech

LANGUAGE_CHS 8389372

API Level 3.1.0

Chinese (Simplified)

LANGUAGE_CHT 8389371

API Level 3.1.0

Chinese (Traditional)

LANGUAGE_DAN 8389353

API Level 3.1.0

Danish

LANGUAGE_DEU 8389358

API Level 3.1.0

German

LANGUAGE_DUT 8389354

API Level 3.1.0

Dutch

LANGUAGE_ENG 8389355

API Level 3.1.0

English

LANGUAGE_EST 8390796

API Level 3.1.0

Estonian

LANGUAGE_FIN 8389356

API Level 3.1.0

Finnish

LANGUAGE_FRE 8389357

API Level 3.1.0

French

LANGUAGE_GRE 8389359

API Level 3.1.0

Greek

LANGUAGE_HEB 8389919

API Level 3.1.0

Hebrew

LANGUAGE_HRV 8389361

API Level 3.1.0

Croatian

LANGUAGE_HUN 8389360

API Level 3.1.0

Hungarian

LANGUAGE_IND 8389578

API Level 3.1.0

Bahasa Indonesia

LANGUAGE_ITA 8389362

API Level 3.1.0

Italian

LANGUAGE_JPN 8389373

API Level 3.1.0

Japanese

LANGUAGE_KOR 8389696

API Level 3.1.0

Korean

LANGUAGE_LAV 8390797

API Level 3.1.0

Latvian

LANGUAGE_LIT 8390798

API Level 3.1.0

Lithuanian

LANGUAGE_NOB 8389363

API Level 3.1.0

Norwegian

LANGUAGE_POL 8389364

API Level 3.1.0

Polish

LANGUAGE_POR 8389365

API Level 3.1.0

Portuguese

LANGUAGE_RON 8390799

API Level 3.1.0

Romanian

LANGUAGE_RUS 8389366

API Level 3.1.0

Russian

LANGUAGE_SLO 8389367

API Level 3.1.0

Slovak

LANGUAGE_SLV 8389368

API Level 3.1.0

Slovenian

LANGUAGE_SPA 8389369

API Level 3.1.0

Spanish

LANGUAGE_SWE 8389370

API Level 3.1.0

Swedish

LANGUAGE_THA 8389548

API Level 3.1.0

Thai

LANGUAGE_TUR 8389774

API Level 3.1.0

Turkish

LANGUAGE_UKR 8390800

API Level 3.1.0

Ukrainian

LANGUAGE_VIE 8390206

API Level 3.1.0

Vietnamese

LANGUAGE_ZSM 8389579

API Level 3.1.0

Standard (Bahasa) Malay

DisplayMode

Enum class for display mode

Since:

API Level 5.0.0

Name Value Since Description See Also
DISPLAY_MODE_HIGH_POWER 0

API Level 5.0.0

Display in high power mode.

Toybox::WatchUi::View::onUpdate
  • are not subject to burn-in protection.

  • DISPLAY_MODE_LOW_POWER 1

    API Level 5.0.0

    Display in low power mode, including watch face always-on mode.

      [Toybox::WatchUi::View::onUpdate] or (other functions
    

    that draw on display) subject to burn-in protection.

    DISPLAY_MODE_OFF 2

    API Level 5.0.0

    Display is off.

    Instance Method Summary collapse

    Instance Method Details

    error(msg as Lang.String) as Void

    Write an error to the console and exit the system.

    Note:

    There are never really too many bananas.

    Parameters:

    • msg(Lang.String)

      The error message to output

    Example:

    using Toybox.System;
    const MAX_BANANAS = 8;
    var bananasInBunch = 10;
    if (bananasInBunch > MAX_BANANAS) {
        System.error("Too many bananas!")
    }
    

    Since:

    API Level 1.0.0

    exit() as Void

    End execution of the current app.

    This will exit the system cleanly from any point within an app.

    Since:

    API Level 1.0.0

    exitTo(intent as System.Intent) as Void

    Exit the current app and launch a new app.

    This may only be called by watch-apps and widgets, and may only target watch-apps (both native activities and Connect IQ apps) and widgets. This is an asynchronous request that presents a confirmation dialog to launch the Intent. If confirmed, the current app will exit. Otherwise, the app will continue to run without exiting.

    Parameters:

    Example:

    using Toybox.System;
    var targetApp = new System.Intent(
        "manifest-id://12345678-1234-1234-1234-123412341234",
        {"arg"=>"CurrentAppName"}
    );
    System.exitTo(targetApp);
    

    See Also:

    Since:

    API Level 2.2.0

    Throws:

    getClockTime() as System.ClockTime

    Get the current clock time.

    Returns:

    Since:

    API Level 1.0.0

    getDeviceSettings() as System.DeviceSettings

    Get the current device settings.

    Example:

    using Toybox.System;
    var mySettings = System.getDeviceSettings();
    

    Returns:

    Since:

    API Level 1.0.0

    getDisplayMode() as System.DisplayMode

    Get the current display mode, only available in devices with AMOLED or LCD screens.

    Supported Devices:

    Since:

    API Level 5.0.0

    getSystemStats() as System.Stats

    Get the current system stats.

    Example:

    using Toybox.System;
    var myStats = System.getSystemStats();
    

    Returns:

    Since:

    API Level 1.0.0

    getTimer() as Lang.Number

    Get the current millisecond timer value.

    Note:

    The returned value typically starts at zero on device boot and will roll over periodically. Assuming the timer starts at zero, this will happen ~25 days after a reboot, and every ~50 days thereafter.

    Returns:

    Since:

    API Level 1.0.0

    isAppInstalled(uri as Lang.String) as Lang.Boolean

    Check the installation status of an app.

    Parameters:

    • uri(Lang.String)

      The URI that specifies an app

    Example:

    Valid URI formats

    manifest-id://[manifest ID in the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx]
    store-id://[app store ID in the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx]
    

    Returns:

    • Lang.Boolean

      true if the app is installed, otherwise false

    Since:

    API Level 3.2.0

    Throws:

    Print to the console.

    Parameters:

    Since:

    API Level 1.0.0

    println(output as Lang.Object or Null) as Void

    Print to the console with a line terminator.

    Parameters:

    Example:

    using Toybox.System;
    System.println("Hello Monkey C!");
    

    Since:

    API Level 1.0.0


    Generated Apr 17, 2024 9:40:38 AM