Enter / exit low power and onExitSleep / OnEnterSleep example

Hi,

could someone please post an example that shows how to display seconds in a custom watch face, i.e. when the user has lifted their hand to look at the watch face?

For example in onUpdate() how do I know if I'm in low power mode or not? Should I just set a flag in the onExitSleep/OnEnterSleep methods?!

Is this functionality ACTUALLY working in the current 920 firmware?

Ta.
  • I made a flag in those functions. And in onUpdate check the flag if to draw the seconds or not. Works in the simulator. On real hardware I don't know yet.
  • That what I did BUT there a problem, when it re-enters low power mode it doesn't call onLayout again so the old seconds are left shown until the next minute has passed.

    Any suggestions?!
  • Former Member
    Former Member over 10 years ago
    There no way to determine the current state. So if you don't have a need to do anything fancy, the simplest way is to set a flag.

    class MyWatchView extends Ui.WatchFace {
    var highPower = false;

    function onUpdate(dc) {
    if (highPower)
    {
    //code to display seconds
    }
    }

    //! The user has just looked at their watch. Timers and animations may be started here.
    function onExitSleep() {
    highPower = true;
    }

    //! Terminate any active timers and prepare for slow updates.
    function onEnterSleep() {
    highPower = false;

    //Force update
    Ui.requestUpdate();
    }

    }


    This functionality is not working in the current 920 firmware. You can however implement it, so your seconds become available with the next firmware update. I've done so for several watch faces that are in the store. I think when you load a watch face it's actually in high power, so after the firmware update, you could initialize with the flag set to true.
  • Former Member
    Former Member over 10 years ago
    That what I did BUT there a problem, when it re-enters low power mode it doesn't call onLayout again so the old seconds are left shown until the next minute has passed.

    Any suggestions?!


    See my example.
  • This is currently working on the vivoactive, but TeunMo is correct--this functionality is not yet available on the 920.