Skip to content

Instantly share code, notes, and snippets.

@hyakuhei
Created April 3, 2015 10:55
Show Gist options
  • Save hyakuhei/c543c41033891f8fccdf to your computer and use it in GitHub Desktop.
Save hyakuhei/c543c41033891f8fccdf to your computer and use it in GitHub Desktop.
using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
using Toybox.System as Sys;
using Toybox.Lang as Lang;
class TestWatchView extends Ui.WatchFace {
//! Load your resources here
function onLayout(dc) {
setLayout(Rez.Layouts.WatchFace(dc));
}
//! Restore the state of the app and prepare the view to be shown
function onShow() {
}
//! Update the view
function onUpdate(dc) {
// Get and show the current time
var clockTime = Sys.getClockTime();
var timeString = Lang.format("$1$:$2$:$3$", [clockTime.hour, clockTime.min.format("%.2d"), clockTime.sec.format("%.2d")]);
var view = View.findDrawableById("TimeLabel");
view.setText(timeString);
// Call the parent onUpdate function to redraw the layout
View.onUpdate(dc);
System.println("End of onUpdate");
}
//! The user has just looked at their watch. Timers and animations may be started here.
function onExitSleep() {
}
//! Terminate any active timers and prepare for slow updates.
function onEnterSleep() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment