Apps supporting pool swims?

I've been looking through the latest SDK docs and I can't see how to start a pool swim.

I also can't see how you'd be able to read the laps or pool length if one was started.

I'm very interested writing some in-pool apps for guided workouts..
  • To create an activity in an app, you need to use the following code to create a session.

    using Toybox.ActivityRecording as Arc;
    var mActivity;
    mActivity = Arc.createSession( {
    :sport => Arc.SPORT_SWIMMING,
    :subSport => Arc.SUB_SPORT_LAP_SWIMMING,
    :name => "PoolSwim"} );


    Then you need to start and stop it. For my app, I used the enter button to start and stop so this is a snippet from the input delegate. mActivity is passed into the input delegate.

    using Toybox.WatchUi as Ui;
    using Toybox.Attention as Att;

    function onKey(evt) {
    .....

    else if (evt.getKey() == Ui.KEY_ENTER)
    {
    if (mActivity.isRecording() == false)
    {
    mActivity.start();
    mView.setBtnPress(START);
    Att.playTone(Att.TONE_START);
    Att.vibrate(mVibeShort);
    Ui.requestUpdate();
    }
    else if (mActivity.isRecording() == true)
    {
    mActivity.stop();
    mView.setBtnPress(STOP);
    Att.playTone(Att.TONE_STOP);
    Ui.requestUpdate();
    Att.vibrate(mVibeShort);
    }


    Note that the simulator doesn't support starting and stopping this way. You need to start and stop the Fit Data stream manually from the pull downs in the simulator window.

    Then you can get access to the available swimming data by:

    using Toybox.Activity as Act;
    var activityInfo = Act.getActivityInfo();

    if (activityInfo.currentHeartRate instanceof Toybox.Lang.Number)
    {
    hrData = activityInfo.currentHeartRate.format("%d");
    }


    It looks like the currently available swim metrics are (page 64 of Preview 2 Programmers Guide):
    //! Swim stroke type
    var swimStrokeType;
    //! Swim SWOLF
    var swimSwolf;
    //! Swim efficence
    var swimEfficency;
    //! Swim stroke average distance
    var averageDistance;

    e.g. Replace activityInfo.currentHeartRate with activityInfo.averageDistance in the code above.

    I don't know if the FIT data simulator simulates these metrics or not. You probably need to create a .FIT file with these metrics in it and then playback that to get these to show up in the simulator.
  • Thanks for the reply MoxyRoger. You've answered the first half of my question in terms of starting a swim.

    Do you know if it's possible to get the number of lengths or an event when a length is logged? That's probably the key thing. I guess the only other thing to try there is looking at the distance marker and seeing when it goes up?
  • I don't know anything about the swimming metrics or how they work natively on the watch. If they are available natively, you should ask Garmin to make them available in an App through getActivityInfo().
  • We plan to investigate making more of the pool functionality available. I'll add your specific case to our notes to make sure it is addressed.
  • We plan to investigate making more of the pool functionality available. I'll add your specific case to our notes to make sure it is addressed.


    Thanks - that's really appreciated. Could I also add to my request the ability to set a start/end of a drill to enable overriding the distance / stroke detection for a certain period of a swim please?

    So to summarise my requests:

    • Start a pool swim (already possible)
    • Query laps
    • Lap notifications / callbacks
    • Start drill mode
    • Stop drill mode (provide distance or turn count for FIT file)


    Thanks :)
  • Former Member
    Former Member
    The team has determined this isn't a priority at this time and had closed this ticket.