How to force onUpdate() to be called every minute

Former Member
Former Member

I am making an analog watch face without a seconds hand. Thus, I would be able to save battery by not having to update the display every second and don't really need my function to be called every second. 

My onUpdate function: 

1. Clears any existing UI elements on screen.

2. Draws the minute hand using dc.drawLine

3. Draws the hour hand using dc.drawLine.

Thus, I don't really care about having my function being called every second.
However, onUpdate is called every second when the watch is not running in low power mode. Is there any way to force onUpdate to be called once per minute?

  • No, there's not.  But onUpdate() is only called every second for 10 seconds after a gesture, and you always want to update the screen when it's called.

  • Former Member
    Former Member over 4 years ago in reply to jim_m_58

    Okay, got it - thanks!

  • One other thing to mention here is the venu.  It's different than other watches due to the AMOLED display,  When you look at it, it will switch out of low power like the others, but when it's in low power, you are very limited as to what you can do without the screen going blank.

    See the AMOLED section in this post:

    https://forums.garmin.com/developer/connect-iq/b/news-announcements/posts/connect-iq-3-1-now-available

  • Former Member
    Former Member over 4 years ago in reply to jim_m_58

    Jeez, thanks - I was specifically building for the Venu, so this is awesome.
    Also, I'm worried about my algorithm. Am I correct in clearing out the screen (by using drawRectangle with black color) in onUpdate() and using drawLine() for the hands? Is this an inefficient algorithm?

  • I set the colors to be the background color, then call

    dc.clear()

    As far has the hands, that's one way to do it, but without some anti-alasing, it may not look that great. See:

    https://forums.garmin.com/developer/connect-iq/f/discussion/4953/my-technique-for-anti-aliased-animation-and-bitmaps

  • Former Member
    Former Member over 4 years ago in reply to jim_m_58

    Gotcha. Thanks!

  • I've done something very similar to this, but on the Fenix 6, and AFAIK once the watch goes into sleep mode it calls onUpdate() once per minute like you want anyway.  I just put some print statements into my code to verify this and when I click on the pulldown menu in the simulator to select "Low Power Mode" I see the onEnterSleep() method call execute, and from then on the onUpdate() method gets called at every minute interval (seconds = 00).  When I unselect "Low Power Mode" I see the onExitSleep() method call execute, and onUpdate() gets called once per second. 

    In my case I display the second hand when not in sleep, and remove it when in sleep.  On my watch it runs the same way as what I see in the simulator because the second hand displays for 10 seconds after a gesture, then it goes away until the next gesture.  Also, I set a flag going into sleep, and clear it coming out of sleep, and use that flag to determine if the second hand should be drawn or not.  That way when I get the one minute interval onUpdate() calls I don't inadvertently draw the second hand when I don't really want it.

    During sleep I see the onPartialUpdate() method called in the simulator once per second, but using the same sleep flag I do nothing during that method call.

  • You can accomplish the same thing by just commenting on the whole onPartialUpdate() function.  That's the way things worked prior to onPartialUpdate().

    Unless you want to do something every second in low power mode, there is no need for onPartialUpdate()