Here are a few Complication samples

Hey folks, the Complication examples in the Core Topics documentation doesn't really help you build an end-to-end demo.

So, with the help of others here, I've prepped two Complication samples for System 6 devices that;

  1. Subscribe to Complication callbacks, and display their data in a watchface, and
  2. Pressing them within a bounding box (onPress) to launch the Complication widget.

This code deals with square press bounds;
https://github.com/sunpazed/garmin-complicate

While this one deals with round press bounds;
https://github.com/sunpazed/garmin-complicate-circle

Pick whichever works for your design or approach.

Here's a video of what the "onPress" does with one of my watchfaces;
https://www.youtube.com/watch?v=Gp-m-2xvfM0

The "onPress" doesn't do anything yet, but hopefully we'll see this change with a new SDK or firmware update in the future.

Happy to hear any feedback, and please contribute / improve these code samples for everyone.

  • No problem Franco!

    Another thing is there may be issues on some of the latest System 6 device files.  For example, "onPress" doesn't work for me with the 955 in the sim, and on some devices, onPress/exitTo works for a CIQ publisher, but not a native publisher.

  • Hello, I am currenlty facing a problem with  example. To make it clear: I am able to build and run the watchface on the sim and my actual Fenix 7S when I set the typecheck to 0. The chosen complication opens when I long press it.

    But I cannot get TemporalEvent anymore as soon as I had the following code in onStart(state) on my own watchface to integrate the demo:

     

    Complications.registerComplicationChangeCallback(self.method(blabla);
    Complications.subscribeToUpdates(new Complications.Id(Complications.COMPLICATION_TYPE_STEPS));
    Complications.subscribeToUpdates(new Complications.Id(blabla);

    If I set typecheck >0 (on both example and my own modified watchface) I get the following error: "Invalid '$.Toybox.Lang.Method(complicationId as Any) as Any' passed as parameter 1 of type 'PolyType<Null or $.Toybox.Complications.ComplicationChangedCallback>'"

    Anyone could help please ?

    N.B. : ComplicationSubcriber permission is set to "on" in both cases

  • Stick with typecheck=0 for now and sort out what you need to do for >0 later.  Recall that onStart() is called when your main app starts OR when the background starts.  I'd move the 3 lines you posted from onStart() to getInitialView() or into initialize() for the main view, and that way this only runs when the main app starts and not when the background runs..

  • You are right: moving the code to getInitialView() is a workaround: thank you!

  • Not really a work-around.  The way to do things if you are using a background service.  In AppBase, some things are only called for the main app, some, only when the background service runs, and some for both. onStart() is one that's called in both cases.

  • Right once again. But the error is still there if I stick to typecheck >  0. Not sure if it is a bug or if I am doing something wrong (that's why I said "workaround")?!

  • 4.2.2

    var c = new Complications.Id(Complications.COMPLICATION_TYPE_STEPS);

    Complications.exitTo(c);

    and:

    Error: Symbol Not Found Error
    Details: Failed invoking <symbol>
    Stack:
      - onPress()
      - handleEvent()

  • Which device (it needs to be System 6), which SDK (4.2.2 is the best) and do you have the permission set?

  • f7 sim & device, 4.2.2/4.2.1

    ftrimboli sample also crash in the same place

    -  had to comment <!-- <iq:uses-permission id="ComplicationSubscriber"/> --> because error Invalid permission provided: ComplicationSubscriber

    - I have also commented all in onStart becaouse I want to use only exitTo

  • w beta 4.2.0 no error without permission