Moving the hands on an Instinct Crossover watch face?

I've been trying to make a watchface for the Instinct Crossover. The problem is that I cannot get the hands to move properly on the device, although everything works ok on the simulator. More precisely, the call to setClockHandPosition always fails on the device with "Exception: Invalid state for the clock provided", no matter what AnalogClockState value I set for clockState. Please note that all clockState values (resting, holding, system time) are accepted and work properly on the simulator.

For reference, here's the code in onUpdate:

function onUpdate(dc as Dc) as Void {
  var clockTime = System.getClockTime();
   var timeString = Lang.format("$1$:$2$", [clockTime.hour, clockTime.min.format("%02d")]);
   var view = View.findDrawableById("TimeLabel") as Text;
   view.setText(timeString);

  View.onUpdate(dc);

  try {
    var dict = {:clockState=>ANALOG_CLOCK_STATE_SYSTEM_TIME};
    setClockHandPosition(dict);
  } catch (ex instanceof Lang.Exception) {
    System.println("exception thrown " + ex.getErrorMessage());
    ex.printStackTrace();
  }
}

  • hi,

    try to put it into initialize(), here is how I do and it seems to work:

    if(Ui.View has :setClockHandPosition){Ui.View.setClockHandPosition({:clockState=>1});}
  • Same here.  I  do it in the view's initialize()

  • Thanks for the reply. That doesn't work either, I had tried it before posting initially, I get the same error:

    Exception: Invalid state for the clock provided
    Stack:
      - pc: 0x30002cd1
      - pc: 0x1000014d
        File: /Users/cotyso/projects/garmin/ctyface4/source/ctyface4View.mc
        Line: 21
        Function: initialize
      - pc: 0x100002c3
        File: /Users/cotyso/projects/garmin/ctyface4/source/ctyface4App.mc
        Line: 21
        Function: getInitialView

    A possible hint though, when I try exactly as you posted (with {:clockState=>1}) I get the following error:

    ERROR: instinctcrossover: /Users/cty/projects/garmin/ctyface4/source/ctyface4View.mc:21,16: Invalid '$.Toybox.Lang.Dictionary{:clockState as $.Toybox.Lang.Number}' passed as parameter 1 of type '$.Toybox.Lang.Dictionary{:clockState as $.Toybox.WatchUi.AnalogClockState, :minute as Null or $.Toybox.Lang.Number, :hour as Null or $.Toybox.Lang.Number}'.

    I can make it work if i use {:clockState=>ANALOG_CLOCK_STATE_SYSTEM_TIME}. Does it work for you with 1 instead of the constant name? Maybe something is wrong with the way I put together the arguments... although, as mentioned, it works on the simulator :|

  • hi, yes that works for me with the 1 because I don't use type, I don't use import but using.

    (I don't use the "as" system, I use the "old" system, with typeChecking = 0)

    Have you used "import Toybox.Lang"? "import Toybox.WatchUi.View"?

  • It does work on sim but can't tell on real since I don't have a real crossOver, but I've never had feedback about it.