Skip to content

Commit

Permalink
Add caloric intake
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkroell committed Apr 30, 2021
1 parent 8dbef6c commit ad7cbc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cmd/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ var uploadCmd = &cobra.Command{
visceralFat, _ := cmd.Flags().GetFloat64("visceral-fat")
metabolicAge, _ := cmd.Flags().GetFloat64("metabolic-age")
physiqueRating, _ := cmd.Flags().GetFloat64("physique-rating")
calories, _ := cmd.Flags().GetFloat64("calories")
maxTries, _ := cmd.Flags().GetInt("max-tries")

bc := bodycomposition.NewBodyComposition(weight, fat, hydration, bone, muscle, visceralFat, physiqueRating, metabolicAge, ts)
bc := bodycomposition.NewBodyComposition(weight, fat, hydration, bone, muscle, visceralFat, physiqueRating, metabolicAge, calories, ts)

email, _ := cmd.Flags().GetString("email")
password, _ := cmd.Flags().GetString("password")
Expand Down Expand Up @@ -69,6 +70,7 @@ func init() {
uploadCmd.Flags().Float64("hydration", 0, "Set your hydration in percent")
uploadCmd.Flags().Float64P("bone", "b", 0, "Set your bone mass in percent")
uploadCmd.Flags().Float64P("muscle", "m", 0, "Set your muscle mass in percent")
uploadCmd.Flags().Float64P("calories", "c", 0, "Set your caloric intake")
uploadCmd.Flags().Float64("visceral-fat", 0, "Set your visceral fat rating (valid values: 1-60)")
uploadCmd.Flags().Float64("metabolic-age", 0, "Set your metabolic age")
uploadCmd.Flags().Float64("physique-rating", 0, "Set your physique rating (valid values: 1-9)")
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type BodyComposition struct {
VisceralFatRating float64
PhysiqueRating float64
MetabolicAge float64
CaloriesActiveMet float64
}

func (bc BodyComposition) writeFitFile(writer io.Writer) error {
Expand All @@ -44,6 +45,7 @@ func (bc BodyComposition) writeFitFile(writer io.Writer) error {
VisceralFatRating: uint8(bc.VisceralFatRating),
PhysiqueRating: uint8(bc.PhysiqueRating),
MetabolicAge: uint8(bc.MetabolicAge),
ActiveMet: uint16(bc.CaloriesActiveMet),
},
}

Expand Down Expand Up @@ -79,7 +81,7 @@ func (bc BodyComposition) UploadWeight(email, password string) bool {
}

// NewBodyComposition creates a new bodycomposition type
func NewBodyComposition(weight, percentFat, percentHydration, percentBone, percentMuscle, visceralFatRating, physiqueRating, metabolicAge float64, timestamp int64) BodyComposition {
func NewBodyComposition(weight, percentFat, percentHydration, percentBone, percentMuscle, visceralFatRating, physiqueRating, metabolicAge, caloriesActiveMet float64, timestamp int64) BodyComposition {
ts := time.Now()
if timestamp != -1 {
ts = time.Unix(timestamp, 0)
Expand All @@ -95,5 +97,6 @@ func NewBodyComposition(weight, percentFat, percentHydration, percentBone, perce
VisceralFatRating: visceralFatRating,
PhysiqueRating: physiqueRating,
MetabolicAge: metabolicAge,
CaloriesActiveMet: caloriesActiveMet,
}
}

0 comments on commit ad7cbc5

Please sign in to comment.