Class: Toybox::WatchUi::WatchFace

Inherits:
View show all

Overview

Create a Watch Face that supports exiting/entering low power mode.

A WatchFace is a special View that provides notifications when the device changes power states.

A WatchFace will run in a high power mode for a short period when responding to a gesture (i.e., raising the watch to check the time) or when returning to the watch face from another application. While in high power mode, the watch face will perform full screen updates every second via calls to onUpdate(), and the application will have access to timers and animations.

After this period in high power mode (typically about ten seconds), the system will call onEnterSleep() to notify the application that it is preparing to enter low power mode.

During low power mode the system will call onUpdate() at the top of every minute. If partial update support is available, the onPartialUpdate() method will be called for the first 59 seconds of every minute. The application will not have access to timers or aimations while in low power mode.

When a gesture occurs while running in low power mode the system will call onExitSleep() to notify the application that the transition to high power mode has occurred.

Since:

  • 1.0.0

Instance Method Summary collapse

Methods inherited from View

addLayer, clearLayers, findDrawableById, getLayerIndex, getLayers, insertLayer, onHide, onLayout, onShow, onUpdate, removeLayer, setKeyToSelectableInteraction, setLayout

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initializeWatchFace

Returns a new instance of WatchFace

Since:

  • 1.0.0


13724
13725
# File 'Monkeybrains.rb', line 13724

def initialize()
end

Instance Method Details

onEnterSleepObject

The device is entering low power mode.

Terminate any active timers and prepare for once-per-minute updates.

See Also:

Since:

  • 1.0.0


13732
13733
# File 'Monkeybrains.rb', line 13732

def onEnterSleep()
end

onExitSleepObject

The device is exiting low power mode.

Timers and animations may be started here in preparation for once-per-second updates.

See Also:

Since:

  • 1.0.0


13741
13742
# File 'Monkeybrains.rb', line 13741

def onExitSleep()
end

onPartialUpdate(dc) ⇒ Object

Note:

See the Analog sample distributed with the SDK for an example of onPartialUpdate() using clipping regions

Update a portion of the screen.

Partial updates can be used to update a small part of the screen to allow for Always On Watch Faces.

This method is called each second as long as the device power budget is not exceeded. It is important to update as small of a portion of the display as possible in this method to avoid exceeding the allowed power budget. To do this, the application must set the clipping region for the Graphics.Dc object using the setClip() method. Calls to System.println() and System.print() will not execute on devices when this function is being invoked, but can be used in the device simulator.

If the call to this method exceeds the power budget of the device, the partial update will not draw and a call to onPowerBudgetExceeded() is made to report the limits that were exceeded.


13770
13771
# File 'Monkeybrains.rb', line 13770

def onPartialUpdate(dc)
end