Need help for Timer / onExitSleep()

Hi i'm new here 

because i want to run specific function on high power mode, i use Timer to call callback function on onExitSleep() event .

function onExitSleep() {

   myTimer.start(method(:DoSomething), 1000, true);

}


function onEnterSleep() {

   myTimer.stop();
}

on device (Forerunner 645), it works well until Move bar notification appears.  (Move and move bar clear)

after that, Watch face somehow doesn't respond to gesture anymore but other function on onUpdate()  still works fine.

Is Move bar notification somehow interrupt onExitSleep() event or Timer ?

Is there way to manage move bar notification ? 

  • I'm guessing that maybe onShow() is somehow involved here, but I've never used a timer in a watch face.

    Which brings up the question, why are you using one?

    In normal running, here's what happens:

    onUpdate() is getting called every minute

    there's a gesture and onExitSleep() is called

    onUpdate is called every second for about 10 seconds

    onEnterSleep() is called

    onUpdate() is again called every minute

    So, by setting/clearing a flag in onEnterSleep()/onExitSleep(), onUpdate could be doing something every second without a timer when not in low power mode.  The use case is to display the seconds, but only when not in low power mode.

    so...

    function onUpdate(dc) {
    ...
      if(!inLowPower) {
        //do something
      }
    ...
    }
    
    function onEnterSleep() {inLowPower=true;}
    
    function onExitSleep() {inLowPower=false;}
      

    allows you to do something every second for 10 seconds after a gesture without using a timer

    With watches like the f5 and newer, there's also onPartialUpdate(), where that's called every second, regardless of low power or not, but there are limits on how much can be done each time it's called.  This is how "seconds all the time" is done. Update a small section of the screen every second.

  • i just have finished the test below.

    class testSleepView extends WatchUi.WatchFace {
    	var sleep = true;
    	var text = "test";
    
        function initialize() {
            WatchFace.initialize();
        }
    
        // Load your resources here
        function onLayout(dc) {
            setLayout(Rez.Layouts.WatchFace(dc));
        }
    
        // 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() {
        }
    
        // Update the view
        function onUpdate(dc) {
            // Get and show the current time
            var clockTime = System.getClockTime();
            var timeString = Lang.format("$1$:$2$", [clockTime.hour, clockTime.min.format("%02d")]);
            var view = View.findDrawableById("TimeLabel");
            view.setText(timeString);
    
            // Call the parent onUpdate function to redraw the layout
            View.onUpdate(dc);
            
       
    		   if (sleep) {
    		       	dc.setColor(Graphics.COLOR_RED, Graphics.COLOR_TRANSPARENT);
    		   } else {
    		        dc.setColor(Graphics.COLOR_GREEN, Graphics.COLOR_TRANSPARENT);
    		   }
    		
    		    dc.drawText(120,50,Graphics.FONT_MEDIUM,text,Graphics.TEXT_JUSTIFY_CENTER);
    	}
    
    
        // 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() {
        	sleep = false;
        }
    
        // Terminate any active timers and prepare for slow updates.
        function onEnterSleep() {
        	sleep = true;
        }
    
    }
     

    result still the same. After "Move!" notification is shown, Gesture doesn't work anymore.

    i need to "wake" device again by changing to other widget then back to the watch face to make it work properly.

  • Ok, so this takes any potential of something with the timer away.

    With the 645, what FW are you running?  I know the 645 has fallen a bit begin the 645m, and APAC is always behind the ROW devices.

    Also, gestures in general can be tricky on many devices, and sometime, you have to try a few times to trigger it.  With onPartialUpdate(), you don't often see it, because if you're using a gesture to trigger displaying seconds, the seconds are already being displayed all the time.