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



9401
9402
# File 'Monkeybrains.rb', line 9401

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



9387
9388
# File 'Monkeybrains.rb', line 9387

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



9427
9428
# File 'Monkeybrains.rb', line 9427

def exitTo(intent)
end

getClockTimeToybox::System::ClockTime

Get the current clock time.

Returns:

Since:

  • 1.0.0



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

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



9372
9373
# File 'Monkeybrains.rb', line 9372

def getDeviceSettings()
end

getSystemStatsToybox::System::Stats

Get the current system stats.

Returns:

Since:

  • 1.0.0



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

def getSystemStats()
end

getTimerToybox::Lang::Number

Get the current millisecond timer value.

Returns:

Since:

  • 1.0.0



9357
9358
# File 'Monkeybrains.rb', line 9357

def getTimer()
end

Print to the console.

Parameters:

Since:

  • 1.0.0



9351
9352
# File 'Monkeybrains.rb', line 9351

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



9344
9345
# File 'Monkeybrains.rb', line 9344

def println(output)
end