I'm working on my first watchface. Lots of experiences in Java, Perl, Python, Ruby, etc. but Zero in ConnectIQ / monkeyc.
The watchface is just a simple data dump, and runs fine in the simulator. However, whenever I pull it to my 920XT, it flashes quickly to my watchface and then INSTANTLY goes to the Forerunner's default "digital" face. I even filmed it with a slow motion camera to make sure it wasn't my imagination. My watch face is there for a fraction of second.
This probably has a quick and easy explanation. What gives?
Here is my code:
[FONT=Courier New]using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
using Toybox.System as Sys;
using Toybox.Lang as Lang;
using Toybox.ActivityMonitor as ActMon;
class NoTimeWatchFaceView extends Ui.WatchFace {
function initialize() {
}
//! Load your resources here
//function onLayout(dc) {
// setLayout(Rez.Layouts.WatchFace(dc));
//}
function onLayout() {
}
//! Called when this View is brought to the foreground. Restore
//! the state of this View and prepare it to be shown. This includes
//! loading resources into memory.
function onShow() {
}
//! Called when this View is removed from the screen. Save the
//! state of this View here. This includes freeing resources from
//! memory.
function onHide() {
}
//! 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() {
//}
//! Update the view
function onUpdate(dc) {
var clockTime = Sys.getClockTime();
var activityInfo = ActMon.getInfo();
var stepGoal = activityInfo.stepGoal;
var steps = activityInfo.steps;
var calories = activityInfo.calories;
var battery = Sys.getSystemStats().battery.format("%.0f");
var notifications = Sys.getDeviceSettings().notificationCount;
var alarms = Sys.getDeviceSettings().alarmCount;
var screenWidth = dc.getWidth();
var screenHeight = dc.getHeight();
// Clear the screen
dc.setColor(Gfx.COLOR_BLACK, Gfx.COLOR_WHITE);
dc.fillRectangle(0,0,dc.getWidth(), dc.getHeight());
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT);
dc.drawText(30, 10, Gfx.FONT_MEDIUM, steps, Gfx.TEXT_JUSTIFY_LEFT);
dc.setColor(Gfx.COLOR_BLUE, Gfx.COLOR_TRANSPARENT);
dc.drawText(screenWidth / 2, 25, Gfx.FONT_SMALL,"/" + stepGoal, Gfx.TEXT_JUSTIFY_LEFT);
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT);
dc.drawText(30, 45, Gfx.FONT_MEDIUM, calories, Gfx.TEXT_JUSTIFY_LEFT);
dc.setColor(Gfx.COLOR_BLUE, Gfx.COLOR_TRANSPARENT);
dc.drawText(screenWidth / 2, 60, Gfx.FONT_SMALL, "calories" , Gfx.TEXT_JUSTIFY_LEFT);
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT);
dc.drawText(30, 80, Gfx.FONT_MEDIUM, battery + "%", Gfx.TEXT_JUSTIFY_LEFT);
dc.setColor(Gfx.COLOR_BLUE, Gfx.COLOR_TRANSPARENT);
dc.drawText(screenWidth / 2, 95, Gfx.FONT_SMALL, "battery" , Gfx.TEXT_JUSTIFY_LEFT);
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT);
dc.drawText(30, 115, Gfx.FONT_MEDIUM, notifications, Gfx.TEXT_JUSTIFY_LEFT);
dc.setColor(Gfx.COLOR_BLUE, Gfx.COLOR_TRANSPARENT);
dc.drawText(screenWidth / 2, 130, Gfx.FONT_SMALL, "notices" , Gfx.TEXT_JUSTIFY_LEFT);
//if (screenHeight > 180) {
// dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT);
// dc.drawText(30, 150, Gfx.FONT_MEDIUM, alarms, Gfx.TEXT_JUSTIFY_LEFT);
//
// dc.setColor(Gfx.COLOR_BLUE, Gfx.COLOR_TRANSPARENT);
// dc.drawText(screenWidth / 2, 165, Gfx.FONT_SMALL, "alarms" , Gfx.TEXT_JUSTIFY_LEFT);
//}
}
}
[/FONT]