Has anyone used the Activity.WorkoutStep details available in 3.2?

I'm trying to develop a datafield that uses the new WorkoutStep, WorkoutIntervalStep and WorkoutStepInfo classes.  I can't find any information other than what is in the API documentation, but by playing around a bit I have found the following:

My environment is an F6 running 11.10 firmware, Eclipse with SDK 3.2.2 and I am using a running interval workout that was downloaded on my watch from TrainingPeaks via the Garmin Training API.  It has a couple warm up steps and then intervals repeating 4x with active and rest portions, followed by a cool down step.

1) There is no way to load a workout in the simulator.  This is a hassle since it means I have to do all of my debugging on my watch, but that's fine -- lots of System.println() and looking at the error log has gotten me pretty far.

2) Toybox.Activity.getCurrentWorkoutStep() works correctly and returns null when there is no workload loaded and returns an Activity.WorkoutStepInfo instance when one is loaded.

3) The information in the WorkoutStepInfo instance looks correct.  I mostly tested with the intensity attribute and it follows correctly as I progress through the workout.

4) Unless I am doing something wrong, the step attribute in the WorkoutStepInfo instance never has any information.  When I try to read it, has:activeStep and has:restStep always return false.  This may be due to the way that the workout file is constructed(?), but without having either of these attributes there is no way to get a WorkoutStep instance which has the detail information about the step including the target and duration information.

5) This may be user error on my part, but the WORKOUT_INTENSITY_xxxx enumerations aren't working.  It compiles when I use them but crashes runtime.  For my playing around I had to hardcode the values.

Thanks in advance for any guidance if anyone else has played with this new feature and been successful in getting it to work!

Top Replies

  • Hi,I am curious about the unit for targetValueLow/targetValueHigh when target type is speed.

    step: Obj: 143
    durationType: 0(time)

    durationValue: 10.000000
    targetType: 0(speed)
    targetValueLow…

  • I  found it is mm/s !!!

    That's what's in the FIT file, but how does the Connect IQ API report the same numbers? I would expect CIQ to use m/s for consistency, especially considering the numbers…

All Replies

  • Thanks .

    W/ regards to the workout fit file. From the documentation, there is only 

    getCurrentWorkoutStep()

    getNextWorkoutStep()

    This means that we only are able to get 2 immediate steps for the workout? We can't get the entire workout 1 shot right? eg: 

    step 1 - warmup

    step 2 - bike 30sec @ 100w

    step 3 - bike 30sec @ 50w

    step 4 - bike 30 @ 100w

    ...

    step 20 - cooldown

    At the start of the workout, I would only be able to get access to step 1 and step 2 and not step1-20?

  • Yes. That is how it works. I believe that the API that we use internally only exposes the current and next step, so we're giving you everything we have.

    Update: Confirmed. We have access to the current and next step only.

  • I would like to come back to the main topic of this thread.

    I have a training written in the app that starts with a warm-up of 10 minutes and then 7 iterations of 500 m high-speed run and then 200 m of relaxed running. My expectation was that I would be able to check for the WorkoutIntervalStep and get an active step (500 m), a rest step (200 m) and a repitionNumber (1 to 7).

    However, in reality I get one step after the other (as WorkoutStep), without any WorkoutIntervalStep.

    What needs to be done to get WorkoutIntervalSteps?

    When looking into the actual .fit file, the fact that there are 7 repetitions is clearly visible.

    Any clues?

  • on an off topic note I haven't really looked into WorkoutStepInfo object as a I think it's off-putting that you can not assign your workout data field to be the first screen you see when you do a workout (you always see the default workout screen first and you have to press up and down arrow until you reach the screen you've designed).

    This may not bother you, but personally I won't create a workout field as long as this is the behavior. 

    As to your question

    https://developer.garmin.com/connect-iq/api-docs/Toybox/Activity/WorkoutStepInfo.html

    Do you check the "step" value with the instanceof operator?

    if (x.step instanceof Activity.WorkoutIntervalStep) {

    ...

  • Yes, it is a bit inconvenient to always have to navigate to my own screen, but it is ok. I do so before I click "Start" and then do not bother again.

    I have tried both: use instanceof and use has:repititionCount. Both compile and run with no problem, but apparently always tell me that the workout step I am checking is indeed a WorkoutStep, not a WorkoutIntervalStep.

    I even tried to create an interval training on the watch itself, but same behaviour.

    Just wondering if there is any sample code out there that actually uses WorkoutIntervalStep successfully.

  • For a Cardio or Other activity which has steps I only ever seem to get back WorkoutStep, not a WorkoutIntervalStep.

    WorkoutStep.durationValue gives me the total expected time of the step, but is there anyway to get the actual current time of the step?

    Info.timerTime seems to mirror elapsed time of the whole activity pretty much. I am looking for the elapsed time of the individual current step. Is that possible? I don't see that this value is exposed in the Activity API anywhere.

  • Hi,I am curious about the unit for targetValueLow/targetValueHigh when target type is speed.

    step: Obj: 143
    durationType: 0(time)

    durationValue: 10.000000
    targetType: 0(speed)
    targetValueLow: 0.447000
    targetValueHigh: 4.470000 (4.47 minutes?)

  • Hi,I am curious about the unit for targetValueLow/targetValueHigh when target type is speed.

    step: Obj: 143
    durationType: 0(time)

    durationValue: 10.000000
    targetType: 0(speed)
    targetValueLow: 0.447000
    targetValueHigh: 4.470000 (4.47 minutes?)

    In the (sad) absence of documentation, I would assume that speed is in units of metres per second, like other speed values in Connect IQ.

    i.e. 0.447 m/s = 1.6092 km/h ~= 37:17 min/km

    4.47 = 16.092 km/h ~= 3:44 min/km

    Is it possible to create a workout in Connect, send it to your device, copy it from the watch and "install" it in the simulator? You could verify my educated guess. Workouts should be in the /garmin/workouts folder. (I've never tried it and I have no idea how you would select a workout in the sim.)

  • Good idea. I would upload this app to garmin connect for a check.