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:

  • 1.0.0

Defined Under Namespace

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

Constant Summary

UNIT_METRIC = 0

Display units in metric units

Since:

  • 1.0.0

UNIT_STATUTE = 1

Display units in statute units

Since:

  • 1.0.0

SCREEN_SHAPE_ROUND = 1

Since:

  • 1.2.0

SCREEN_SHAPE_SEMI_ROUND = 2

Since:

  • 1.2.0

SCREEN_SHAPE_RECTANGLE = 3

Since:

  • 1.2.0

BUTTON_INPUT_SELECT = 0x00000001

Since:

  • 1.2.0

BUTTON_INPUT_UP = 0x00000002

Since:

  • 1.2.0

BUTTON_INPUT_DOWN = 0x00000004

Since:

  • 1.2.0

BUTTON_INPUT_MENU = 0x00000008

Since:

  • 1.2.0

BUTTON_INPUT_CLOCK = 0x00000010

Since:

  • 3.1.0

BUTTON_INPUT_DOWN_LEFT = 0x00000020

Since:

  • 3.1.0

BUTTON_INPUT_DOWN_RIGHT = 0x00000040

Since:

  • 3.1.0

BUTTON_INPUT_ESC = 0x00000080

Since:

  • 3.1.0

BUTTON_INPUT_FIND = 0x00000100

Since:

  • 3.1.0

BUTTON_INPUT_LAP = 0x00000200

Since:

  • 3.1.0

BUTTON_INPUT_LEFT = 0x00000400

Since:

  • 3.1.0

BUTTON_INPUT_LIGHT = 0x00000800

Since:

  • 3.1.0

BUTTON_INPUT_MODE = 0x00001000

Since:

  • 3.1.0

BUTTON_INPUT_PAGE = 0x00002000

Since:

  • 3.1.0

BUTTON_INPUT_POWER = 0x00004000

Since:

  • 3.1.0

BUTTON_INPUT_RESET = 0x00008000

Since:

  • 3.1.0

BUTTON_INPUT_RIGHT = 0x00010000

Since:

  • 3.1.0

BUTTON_INPUT_SPORT = 0x00020000

Since:

  • 3.1.0

BUTTON_INPUT_START = 0x00040000

Since:

  • 3.1.0

BUTTON_INPUT_UP_LEFT = 0x00080000

Since:

  • 3.1.0

BUTTON_INPUT_UP_RIGHT = 0x00100000

Since:

  • 3.1.0

BUTTON_INPUT_ZIN = 0x00200000

Since:

  • 3.1.0

BUTTON_INPUT_ZOUT = 0x00400000

Since:

  • 3.1.0

CONNECTION_STATE_NOT_INITIALIZED = 0

Indicates that the connection is not setup or is inactive.

Since:

  • 3.0.0

CONNECTION_STATE_NOT_CONNECTED = 1

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

Since:

  • 3.0.0

CONNECTION_STATE_CONNECTED = 2

Indicates that the connection is available for use.

Since:

  • 3.0.0

BLUETOOTH = 0

Since:

  • 1.0.0

WIFI = 1

Since:

  • 1.0.0

Instance Method Summary collapse

Instance Method Details

error(msg) ⇒ Object

Note:

There are never really too many bananas.

Write an error to the console and exit the system.

Examples:

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

Parameters:

Since:

  • 1.0.0


9642
9643
# File 'Monkeybrains.rb', line 9642

def error(msg)
end

exitObject

End execution of the current app.

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

Since:

  • 1.0.0


9628
9629
# File 'Monkeybrains.rb', line 9628

def exit()
end

exitTo(intent) ⇒ Object

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.

Examples:

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

Parameters:

Raises:

See Also:

Since:

  • 2.2.0


9668
9669
# File 'Monkeybrains.rb', line 9668

def exitTo(intent)
end

getClockTimeToybox::System::ClockTime

Get the current clock time.

Returns:

Since:

  • 1.0.0


9604
9605
# File 'Monkeybrains.rb', line 9604

def getClockTime()
end

getDeviceSettingsToybox::System::DeviceSetting

Get the current device settings.

Examples:

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

Returns:

  • (Toybox::System::DeviceSetting)

Since:

  • 1.0.0


9613
9614
# File 'Monkeybrains.rb', line 9613

def getDeviceSettings()
end

getSystemStatsToybox::System::Stats

Get the current system stats.

Returns:

Since:

  • 1.0.0


9621
9622
# File 'Monkeybrains.rb', line 9621

def getSystemStats()
end

getTimerToybox::Lang::Number

Get the current millisecond timer value.

Returns:

Since:

  • 1.0.0


9598
9599
# File 'Monkeybrains.rb', line 9598

def getTimer()
end

Print to the console.

Parameters:

Since:

  • 1.0.0


9592
9593
# File 'Monkeybrains.rb', line 9592

def print(output)
end

println(output) ⇒ Object

Print to the console with a line terminator.

Examples:

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

Parameters:

Since:

  • 1.0.0


9585
9586
# File 'Monkeybrains.rb', line 9585

def println(output)
end