Sailing Timer

Former Member
Former Member
I've built a straight forward timer for sailing race starts.

https://apps.garmin.com/en-US/apps/b5aead02-e9ba-40ee-a88c-1f67b8e43304

It vibrates every minute and emits a beep on signals (ISAF 5-4-1-0 sequence).
At the start emits an alarm, vibrates and then times up for the race duration.
The timer can be synchronised to the nearest minute, up or down.

It has two modes:
  • Standard mode: starts at 5 minutes.
  • Pursuit mode: allows offset to be configured. Main timer shows 5 minute sequence, offset timer shows your start.


I have the Fenix 3, so have only tested it on that. The other devices are tested in the simulator and should work in theory, but I'd be grateful for feedback from other watch owners.
  • Doing a "beep" on the vivoactive will crash your app, as the va doesn't support "tones".. Only vibration. But it will run fine in the simulator.

    You may want to have your code check for the vivoactive, and then not use "tones" if that's the case. There are device settings you can check in CIQ 1.2.x.
  • Former Member
    Former Member over 9 years ago
    Doing a "beep" on the vivoactive will crash your app, as the va doesn't support "tones".. Only vibration. But it will run fine in the simulator.

    You may want to have your code check for the vivoactive, and then not use "tones" if that's the case. There are device settings you can check in CIQ 1.2.x.


    Thanks Jim. I've uploaded a new version. Do you have the Vivoactive? Could you test the new version?
  • Just downloaded it and it's counting down. No crashes!

    couple things. For the time, when seconds are less that 10, you get someing like 2:5 instead of 2:05. You can use a format of "seconds.format("%02d") to fix this. Also, when it starts counting up, you may want to do a similar thing.

    Right now the time is "0:0:7", where 00:00:07, might look better. Again, the format thing and maybe the next font side down so it will fit

    Seems the time is always in 24hr mode. Here's a bit of code to allow 12 or 24 based on system settings:
    var settings=Sys.getDeviceSettings();
    var AMPM;
    var hour;
    ...

    // 24hr format
    if(settings.is24Hour)
    {
    AMPM="";
    hour=today.hour;
    }
    //12hr format
    else
    {
    hour = today.hour % 12;
    hour = (hour == 0) ? 12 : hour;

    AMPM = (today.hour>11) ? "P" : "A";
    }

    and then user hour, today.min, and AMPM to display the time. This will handle 12/24 and allow for am/pm if you want, based on the device settings.
  • Former Member
    Former Member over 9 years ago
    Just downloaded it and it's counting down. No crashes!

    Thanks, much appreciated.

    couple things. For the time, when seconds are less that 10, you get someing like 2:5 instead of 2:05. You can use a format of "seconds.format("%02d") to fix this. Also, when it starts counting up, you may want to do a similar thing.

    Right now the time is "0:0:7", where 00:00:07, might look better. Again, the format thing and maybe the next font side down so it will fit

    This is weird. It formats fine on the Fenix 3. I'm using "%.2d" at the moment, in code that I ripped out of one of the watchface samples, so I thought it should work fine.

    To quote the c spec for sprintf:

    [table="class: grid"]
    [tr]
    [td].number[/td]
    [td]For integer specifiers (d, i, o, u, x, X): precision specifies the minimum number of digits to be written. If the value to be written is shorter than this number, the result is padded with leading zeros.[/td]
    [/tr]
    [/table]

    Looks like a bug in the Vivoactive VM to me. Anyway, if %02d works, I'll use that.

    Seems the time is always in 24hr mode.

    Yeah, to be honest I did this on purpose because 24Hr time is pretty much ubiquitous in sailing, but you are right, I should honour the user setting.
  • Former Member
    Former Member over 9 years ago
    Again, the format thing and maybe the next font side down so it will fit

    Does the font really need to be smaller for the VA? Again on F3 it fits fine. I thought the fonts were reduced in size on the VA because of the smaller screen? The docs seem to suggest so and I adjusted the positioning so that it all fits on the simulator.

    If you are thinking that the count up might need to go above 9 hours, I don't think this is an issue, because sailing races are rarely more than an hour. Any very long races (ocean going, etc.) won't be using this for timing the race, even if they do use it for the start.
  • The "%.2d" in the sample is wrong, but does work on the f3 for some reason. This has been brought up by other folks.

    "%02d" is the correct format. The "0" says zero fill, and the "2" is at least 2 digits.
  • Former Member
    Former Member over 9 years ago
    The "%.2d" in the sample is wrong, but does work on the f3 for some reason. This has been brought up by other folks.

    "%02d" is the correct format. The "0" says zero fill, and the "2" is at least 2 digits.


    I beg to differ. The API docs state:
    Use format() to format the Number using the given formatting String. The format string is similar to the format string that can be passed in to printf in c stdio (the [length] option is not available):

    "%[flags][width][.precision]specifier"
    The supported specifiers are: d, i, u, o, x, X, f, e, E, g, G.

    flags
    supports only + and 0
    width
    supports only numbers (* is not supported)
    .precision
    supports only numbers (* is not supported)
    For more details on each of these, please see www.cplusplus.com/reference/cstdio/printf/

    The C++ docs linked to there are what I quoted above. Namely, that .precision pads with zeros.

    I think the f3 behaviour is correct and the VA isn't.
  • Former Member
    Former Member over 9 years ago
    Version 1.2.2 released

    Just uploaded version 1.2.2

    Should fix the format issues on Vivoactive and possibly others.
    Now honours 12/24hr time format system setting.
  • Former Member
    Former Member over 9 years ago
    Please add larger numbers, a rolling timer and please make it vibrate more often

    Please add larger numbers, a rolling timer option and please make it vibrate every 30 seconds for the first three minutes, and then every 15 seconds until the last 10 seconds.

    Thanks