Watch timer Class: Toybox::Timer::Timer

Former Member
Former Member
Can someone show me the format/example for using:

(Object) start(callback, time, repeat)

I want to update the UI once every 60 seconds, using this in an app and not a watch face

https://developer.garmin.com/downloads/connect-iq/monkey-c/doc/Toybox/Timer/Timer.html#start-instance_method

Thanks!
  • Exactly. A condition in onExitSleep and onLayout and onShow checking if the last update was earlier than the threshold will be simpler than handling the timer, because it will probably happen many times a day. 

  • no, it's simpler than that.  You don't need a timer.

    In onUpdate, you know the time as you're displaying it.  Check the current hour against the last time you checked the location.  If it's been more than X hours, check the location again.

  • Finally I came up even with simpler solution: shared locate() function in app, launched from: 
    1. View: onUpdate refresh location daily for sunrise/sunset times even for watches without background process support (as you suggested)
    2. Background: onTemporalEvent gets location before reading weather forecast

    Boolean in locate(save) disables saving location as property from background, that would lead to crash.