Noob questions regarding low power mode handling on different devices

Hey guys!

I'm new to Garmin watchface development, just started monkeying around with it. But I have some questions regarding the best way to handle the low power mode for watchfaces.

I was thinking to hide different elements from the UI that I defined in layout xml, but I do not know how to do that.

Another way is to create a different layout for low power mode, but I do not know how to load the new layout when the power mode changes.

Also. there is the option to draw every icon and text programatically in the onUpdate() function and decide what to draw or not and where to draw it, depending of the device the watchface is running on, but I'm not a big fan of this idea...

Any tips and trick regarding these issues for noobs? Slight smile

Thanks.

  • When CIQ first came out, onEnterSleep() and onexitSleep() were used to determine when seconds could be displayed.  After onExitSleep(), yes, until onEnterSleep(), with that being triggered by a gesture, and lasting about 10 seconds.

    So yes. you can you it to change what's displayed.

    with onExterSleep()/onWexitSleep() you know what mode you are in and can display things accordingly.

    That said, there's now onPartialUpdate() which allows a WF to update a small section of the screen every second, which is how "seconds all the time" works, and some do the same with HR.

  • hi,

    i ve never used layout but here is how I do,

    put for exemple : var Sleeping = true;

    on "onExitSleep", Sleeping=false;

    on "onEnterSleep", Sleeping=true; WatchUi.requestUpdate;

    and in your OnUpdate

    if(Sleeping){do that.....} else {do this...}

    I hope it helps.

  • thank you for your answers. I managed to do it. Now, I have another question: let's say I have an icon in the layout xml file and, on some devices, like Venu, I want to remove that icon. Is it possible to remove or to hide an element from layout xml programatically? I can do different layouts for each model, but the easiest way is to just hide/show certain elements based on some conditions.

    Thank you.

  • hi, 

    if it is only for the Venu, it is easy since it is the only one to have 390x390 screen,

    i would say something like if(dc.getScreenHeigh!=390){ EXEMPLE=load the ressource;}

    if(EXEMPLE!=null){ blablabla;}

    else, you can see in Jungle side

  • I'm kind of wondering what is it you want to remove from the venu only.  For many things it's no different than say a va4/va4s.

    It's very different when it comes to low power, where there are restrictions as far as how many pixels can be on at one time and how long they can be on for - is it something to do with that?

  • Ok, not the best example. I will try again. Let's say I have a layout with time and date. In the settings, I have an option to hide date. How to hide this element defined in layout.xml programmatically, from monkey c code?

  • You can't really get rid of it, but you can set it so nothing displays:

    view.setText("");

  • You have many options. You can:

    1. load a different layout based on the options selected
    2. set the text of the given label to an empty string (as suggested by above)
    3. access the view's layout and remove the label
    4. explicitly render each drawable in the layout, skipping those you don't want to display
    5. avoid using layouts entirely and either hard-code or programmatically determine element placement

    There are other options, but these are the obvious ones.

  •  Thanks for the answer. I also wanted to choose method 3, but I don't know how to do that from monkey C, how to remove a label or how to change an image source etc.

    Method 1 also works, but there will be too many layouts to generate for each family of devices....

    Also explored method 5, but will be to much code for each device family.... Working with layouts will keep everything well organized.

  • With #3, something to consider is you may want to re-add the label.

    consider this.  User is using your watch face, and gets into app settings on their phone.  Changes a few things (including turning off the date, and saves that.  Then decides to re-add the date without restarting the watch face