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 = 0x01

Since:

  • 1.2.0

BUTTON_INPUT_UP = 0x02

Since:

  • 1.2.0

BUTTON_INPUT_DOWN = 0x04

Since:

  • 1.2.0

BUTTON_INPUT_MENU = 0x08

Since:

  • 1.2.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



9419
9420
# File 'Monkeybrains.rb', line 9419

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



9405
9406
# File 'Monkeybrains.rb', line 9405

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



9445
9446
# File 'Monkeybrains.rb', line 9445

def exitTo(intent)
end

getClockTimeToybox::System::ClockTime

Get the current clock time.

Returns:

Since:

  • 1.0.0



9381
9382
# File 'Monkeybrains.rb', line 9381

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



9390
9391
# File 'Monkeybrains.rb', line 9390

def getDeviceSettings()
end

getSystemStatsToybox::System::Stats

Get the current system stats.

Returns:

Since:

  • 1.0.0



9398
9399
# File 'Monkeybrains.rb', line 9398

def getSystemStats()
end

getTimerToybox::Lang::Number

Get the current millisecond timer value.

Returns:

Since:

  • 1.0.0



9375
9376
# File 'Monkeybrains.rb', line 9375

def getTimer()
end

Print to the console.

Parameters:

Since:

  • 1.0.0



9369
9370
# File 'Monkeybrains.rb', line 9369

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



9362
9363
# File 'Monkeybrains.rb', line 9362

def println(output)
end