goworkouts

package module
v0.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2025 License: MIT Imports: 17 Imported by: 0

README

goworkouts

Read & write FIT workout files, translate them to JSON

Documentation

Index

Constants

View Source
const MaxUint = ^uint32(0)

MaxUint maximum int value (default in fit)

Variables

This section is empty.

Functions

func AddRepeats added in v0.10.13

func AddRepeats(stepslist []string, idxlist []typedef.MessageIndex, idx typedef.MessageIndex, nr_repeats uint32) []string

func FitHRConversion added in v0.10.13

func FitHRConversion(step WorkoutStep) (string, error)

FitHRConversion converts Power to zone or value

func FitPowerConversion added in v0.10.13

func FitPowerConversion(step WorkoutStep) (string, error)

FitPowerConversion converts Power to zone or value

func TransformRepeats added in v0.10.18

func TransformRepeats(input string) string

Helper function for ToIntervals

func WriteFit

func WriteFit(f string, w *proto.FIT, overwrite bool) (ok bool, err error)

WriteFit writes FIT file from Workout

Types

type ListOfPlans added in v0.9.1

type ListOfPlans struct {
	Plans []TrainingPlan `json:"plans" yaml:"plans"`
}

ListOfPlans storing list of plans

type NewTrainingPlan added in v0.9.1

type NewTrainingPlan struct {
	Filename     string        `json:"filename" yaml:"filename"`
	Name         string        `json:"name" yaml:"name"`
	TrainingDays []TrainingDay `json:"trainingDays" yaml:"trainingDays"`
	Duration     uint32        `json:"duration" yaml:"duration"` // in number of calendar days
	Description  string        `json:"description" yaml:"description"`
}

NewTrainingPlan type for training plans that do not exist yet

type TrainingDay

type TrainingDay struct {
	Order    uint32    `json:"order" yaml:"order"` // how manieth calendar day
	Workouts []Workout `json:"workouts" yaml:"workouts"`
}

TrainingDay is a training day in the training plan

type TrainingPlan

type TrainingPlan struct {
	ID           uuid.UUID     `json:"ID" yaml:"ID"`
	Filename     string        `json:"filename" yaml:"filename"`
	Name         string        `json:"name" yaml:"name"`
	TrainingDays []TrainingDay `json:"trainingDays" yaml:"trainingDays"`
	Duration     uint32        `json:"duration" yaml:"duration"` // in number of calendar days
	Description  string        `json:"description" yaml:"description"`
}

TrainingPlan is a training plan

type Workout

type Workout struct {
	Filename    string        `json:"filename" yaml:"filename"`
	Name        string        `json:"workoutName" yaml:"workoutName"`
	Steps       []WorkoutStep `json:"steps" yaml:"steps"`
	Sport       string        `json:"sport" yaml:"sport"`
	Description string        `json:"description" yaml:"description"`
}

Workout is a Workout

func FromJSON

func FromJSON(s string) (Workout, error)

FromJSON returns workout from json string

func FromYAML added in v0.9.0

func FromYAML(s string) (Workout, error)

FromYAML returns workout from YAML

func ReadFit

func ReadFit(f string) (Workout, error)

ReadFit Read FIT file

func (*Workout) ToFIT

func (w *Workout) ToFIT() (proto.FIT, error)

ToFIT exports to FIT

func (*Workout) ToIntervals added in v0.10.13

func (w *Workout) ToIntervals() (string, error)

ToIntervals exports to intervals.icu workout description language Each step is turned into a string like "- 10m @ 200W Comment"

func (*Workout) ToJSON

func (w *Workout) ToJSON() ([]byte, error)

ToJSON export to JSON

func (*Workout) ToYAML added in v0.9.0

func (w *Workout) ToYAML() ([]byte, error)

ToYAML export to YAML

type WorkoutStep added in v0.10.5

type WorkoutStep struct {
	MessageIndex          typedef.MessageIndex `json:"stepId" yaml:"stepId"`
	WktStepName           string               `json:"wkt_step_name" yaml:"wkt_step_name"`
	DurationType          string               `json:"durationType" yaml:"durationType"`
	DurationValue         uint32               `json:"durationValue" yaml:"durationValue"`
	TargetType            string               `json:"targetType" yaml:"targetType"`
	TargetValue           uint32               `json:"targetValue" yaml:"targetValue"`
	CustomTargetValueLow  uint32               `json:"targetValueLow" yaml:"targetValueLow"`
	CustomTargetValueHigh uint32               `json:"targetValueHigh" yaml:"targetValueHigh"`
	Intensity             string               `json:"intensity" yaml:"intensity"`
	Notes                 string               `json:"description" yaml:"description"`
}

WorkoutStep is the container of a Workout Step

func GetStepByIndex added in v0.10.13

func GetStepByIndex(w Workout, idx typedef.MessageIndex) (WorkoutStep, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL