Picking hours, minutes and seconds

Hi all,

I'm trying to build an app for myself that has a countdown timer, the length of which the user can specify when starting the app, where you can increase or decrease the number of hours, minutes and seconds to start from. This is basically the same functionality as the inbuilt Timer app on my watch. I've looked at some of the example apps, like the Timer and the Picker ones, but I can't find one that replicates that screen. 

Does anyone know of an example countdown timer app I could look at that works in the same way as the inbuilt Timer app on a Garmin watch?

Thanks.

  • I don't have an example, but just through inspection, I can tell you how I think it works

    If you start the timer, you'll notice that the rightmost digit flips between 1 and 6. This is because the shortest duration you can have a timer is 50ms. So you'd think that's the most accurate it can be, but if it's stopped, we can figure out with more precision when it was stopped with System.getTimer(), which is the amount of milliseconds since the watch has powered on.

    Store a var System.getTimer() when the timer starts and compare it with a new System.getTimer() when the user stops the timer. Keep in mind that the value of System.getTimer() is an unsigned 32-bit integer, so it will overflow after about 30 days. You don't want to take this risk, so & both variables as you collect them with 0xFFFFFFFF [ UINT32_MAX ]. This way, in case of an overflow, your app will still work break.

    After assigning the current time, assign time delta [ change in time ] as the absolute value of the current time minus the time when they started the clock. Format it to however you are storing the time [ I'd do milliseconds for parity ] and override what the 50ms timer was doing with your new time delta. The whole thing will still only stop on 50ms intervals, but that's the best I could do.

    -- I'm making a chess clock called "Rapid" that should be released to the app store in a few days. I'll post the source code on GitHub afterwards if you wanna give it a look. Might be a bit messy, but RapidDelegate.mc has the timer logic. In the meantime though, I hope this helps a bit !

  • I think OP is asking about the UI/UX of the timer picker itself (the look and feel of the controls), not how to implement a countdown timer or stopwatch in CIQ (or in general).

    I agree that the best way to do it is how you described it though.