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, 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

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



7656
7657
# File 'Monkeybrains.rb', line 7656

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



7642
7643
# File 'Monkeybrains.rb', line 7642

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



7682
7683
# File 'Monkeybrains.rb', line 7682

def exitTo(intent)
end

getClockTimeToybox::System::ClockTime

Get the current clock time.

Returns:

Since:

  • 1.0.0



7618
7619
# File 'Monkeybrains.rb', line 7618

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



7627
7628
# File 'Monkeybrains.rb', line 7627

def getDeviceSettings()
end

getSystemStatsToybox::System::Stats

Get the current system stats.

Returns:

Since:

  • 1.0.0



7635
7636
# File 'Monkeybrains.rb', line 7635

def getSystemStats()
end

getTimerToybox::Lang::Number

Get the current millisecond timer value.

Returns:

Since:

  • 1.0.0



7612
7613
# File 'Monkeybrains.rb', line 7612

def getTimer()
end

Print to the console.

Parameters:

Since:

  • 1.0.0



7606
7607
# File 'Monkeybrains.rb', line 7606

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



7599
7600
# File 'Monkeybrains.rb', line 7599

def println(output)
end