Noob Watchface question

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]
  • Pulled this from the watch's APPS/LOGS/CIQ_LOG.TXT:

    WARNING: Failed invoking <symbol>
    STORE_ID: 00000000000000000000000000000000

    ERROR: Circular Dependency Error
    DETAILS: Unfreed memory on exit
    STORE_ID: DA7D5C56C368414F99FBECD88B7344CC
    ERROR: Unhandled Exception
    DETAILS: Failed invoking <symbol>
    STORE_ID: 00000000000000000000000000000000
    ERROR: Circular Dependency Error
    DETAILS: Unfreed memory on exit
    STORE_ID: DA7D5C56C368414F99FBECD88B7344CC
    ERROR: Unhandled Exception
    DETAILS: Failed invoking <symbol>
    STORE_ID: 00000000000000000000000000000000
    WARNING: Unfreed memory on exit
    STORE_ID: 00000000000000000000000000000000

    ERROR: Circular Dependency Error
    DETAILS: Unfreed memory on exit
    STORE_ID: DA7D5C56C368414F99FBECD88B7344CC
    ERROR: Unhandled Exception
    DETAILS: Failed invoking <symbol>
    STORE_ID: 00000000000000000000000000000000
    WARNING: Unfreed memory on exit
    STORE_ID: 00000000000000000000000000000000

    ERROR: Circular Dependency Error
    DETAILS: Unfreed memory on exit
    STORE_ID: DA7D5C56C368414F99FBECD88B7344CC
    ERROR: Unhandled Exception
    DETAILS: Failed invoking <symbol>
    STORE_ID: 00000000000000000000000000000000
    WARNING: Unfreed memory on exit
    STORE_ID: 00000000000000000000000000000000

    ERROR: Circular Dependency Error
    DETAILS: Unfreed memory on exit
    STORE_ID: DA7D5C56C368414F99FBECD88B7344CC
    ERROR: Circular Dependency Error
    DETAILS: Unfreed memory on exit
    STORE_ID: DA7D5C56C368414F99FBECD88B7344CC
    ERROR: Unhandled Exception
    DETAILS: Failed invoking <symbol>
    STORE_ID: 47172B62E63849F497D0A4DCC41B1B74
    WARNING: Unfreed memory on exit
    STORE_ID: 47172B62E63849F497D0A4DCC41B1B74
  • Former Member
    Former Member over 9 years ago
    I am surprised it even compiled, given all those unhandled exceptions. Did you try deleting the *.SET and *.PRG files from your systems %TEMP%/garmin (windows) folder? I have run into situations where following this method busted the ghost in the machine.

    PROBLEM STATEMENT:
    Failed invoking <symbol>
    Unexpected Type Error
    in findDrawableById (d:\1_2_1\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:554)
    in onUpdate (C:\Users\Jeff\_my_garmin_workspace\GarminApps\CleanWatchFace\source\MyGridView.mc:125)
    Unexpected Type Error

    Here is the offending code:
    var dTime = View.findDrawableById("TimeLabel");

    "TimeLabel" is still clearly defined in my rez code (in layouts/layout.xml, to be exact). Now, this error unto itself wouldn't be a surprise since I had been reformatting my *View.mc code.

    The rub is that after doing a 'git reset --hard <sha>' to a previous commit that I know was working (wouldn't have committed otherwise) I am still seeing this error. Anyone have insight into what could have gone wrong here?
    SOLUTION:
    There have been problems with the plugin where it continues to use a version of the .prg that should have been replaced. You can often fix this by exiting the simulator, deleting the offending files (on windows systems delete the %TEMP%\Garmin folder), and then building the program again.
  • It runs fine in the simulator. It crashes on the actual ForeRunner 920XT watch.
  • Found the answer.

    MonkeyC is loosely typed. Usually, loosely typed languages are good at letting you draw numbers.

    What we have here is a "worst case scenario." Functions like dc.drawText(30, 10, Gfx.FONT_MEDIUM, steps, Gfx.TEXT_JUSTIFY_LEFT) compile, run in the IDE, and work great in the Simulator. . . but then puke in the ForeRunner giving obtuse errors. Can a brother get a "type mismatch on line 57" please?!?

    The key is to convert steps into a String using toString();

    No error message pointed me at this, which kinda sucks. And the inconsistency between compiler, IDE, simulator, and actual physical product is very bad.

    But hey, I've got it working now!
  • Performance wise, one thing jumped out at me, is the calls to getWitdth() and getHeight() and how that's used in onUpdate().

    for example "screenWidth / 2" is used a few times on each call to onUpdate(), but if you did "var center=screenWidth / 2" and the used "center" in those calls you'd save a bit of battery ( the "divide" only happens once per onUpdate(), but more than needed).

    What I do, is in onLayout() (the dc is passed there), is to get/save the height, width, center, etc there and save them off and then just reference them as locals after that ...

    The way you do it works, and this is just a way to make it work a tiny bit faster!
  • Can a brother get a "type mismatch on line 57" please?!?


    You win for making me lol today. :D

    I agree that this could be handled a lot better, and I know we have some tasks already on our list to address some specific situations similar to this. I'll look into this and make sure we have plans to deal with this case, too.