Workout Creator

When I go out on a bike ride, I log all my data with my Wahoo Elemnt Bolt. This device is able to record gps, speed, cadence, heartrate and much more. It is one of the best cycling computers out there.

Since I was curious what kind of functionalities the Wahoo had in store, I stumbled upon workout plans. You can follow workouts plans as a training.

I immediately thought about making a package where I could construct my own workout via code and make it an open-source package for everybody else to use.

Usage

You can create an empty workout with the following code. This workout does not include any data, yet.

import { Workout } from "@stefanfortuin/workout-creator"

let workout = new Workout();

Next, let's create an interval that we can use in our workout. You can define an interval with the duration and the amount of effort you should do in that specific interval.

import { Interval } from "@stefanfortuin/workout-creator"
let duration = 120; // duration in seconds
let percentage = 70;
let interval = new Interval(duration, percentage)

After creating an interval, you are able to add the interval in the workout.

workout.add(interval);

It is also possible to add an array of intervals to your workout.

import { Interval } from "@stefanfortuin/workout-creator"

let intervals = [
    new Interval(46, 50),
    new Interval(10, 100),
    new Interval(98, 50),
    new Interval(30, 100),
    new Interval(90, 50),
    new Interval(111, 150),
    new Interval(76, 50),
    new Interval(85, 80),
    new Interval(23, 50),
]

workout.add(intervals);

The workout is being saved by using the following function. You can specify which file format you wish to save the workout in.

workout.save('mrc')
workout.save('erg')

The output of the workout is as follows.

[COURSE HEADER]
VERSION = 2
UNITS = ENGLISH
DESCRIPTION = A description
FILE NAME = blah.mrc
MINUTES PERCENT
[END COURSE HEADER]
[COURSE DATA]
0.00 50
6.60 50
6.60 140
7.98 140
7.98 50
9.07 50
9.07 150
10.10 150
10.10 50
14.07 50
14.07 115
22.07 115
22.07 50
32.08 50
32.08 115
40.08 115
40.08 50
51.88 50
[END COURSE DATA]

This article may get updated in the future when I update the package.