Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Api in dependent library #7

Closed
davidkroell opened this issue Sep 30, 2020 · 0 comments
Closed

New Api in dependent library #7

davidkroell opened this issue Sep 30, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@davidkroell
Copy link
Owner

The maintainer of a dependency released a new feature to create .fit-files from scratch to his library. Needed functionality added in tormoder/fit#49

bodycomposition/main.go

Lines 24 to 68 in 42fecfc

func (bc BodyComposition) writeFitFile(writer io.Writer) error {
weightfile := fit.WeightFile{
UserProfile: nil,
WeightScales: []*fit.WeightScaleMsg{
{
Timestamp: bc.TimeStamp,
Weight: fit.Weight(bc.Weight * 100),
PercentFat: uint16(bc.PercentFat * 100),
PercentHydration: uint16(bc.PercentHydration * 100),
BoneMass: uint16(bc.Weight * bc.PercentBone),
MuscleMass: uint16(bc.Weight * bc.PercentMuscle),
VisceralFatRating: uint8(bc.VisceralFatRating),
PhysiqueRating: uint8(bc.PhysiqueRating),
MetabolicAge: uint8(bc.MetabolicAge),
},
},
}
fitfile := fit.File{
FileId: struct {
Type fit.FileType
Manufacturer fit.Manufacturer
Product uint16
SerialNumber uint32
TimeCreated time.Time
Number uint16
ProductName string
}{Type: fit.FileTypeWeight, Manufacturer: fit.ManufacturerTanita},
Header: struct {
Size byte
ProtocolVersion byte
ProfileVersion uint16
DataSize uint32
DataType [4]byte
CRC uint16
}{Size: 14, ProtocolVersion: 16, ProfileVersion: 2092, DataType: [4]byte{46, 70, 73, 84}},
}
err := fitfile.SetWeight(&weightfile)
if err != nil {
panic(err)
}
return fit.Encode(writer, &fitfile, binary.BigEndian)
}

Tasks:

  • re-implement using the new version of the package
@davidkroell davidkroell added the enhancement New feature or request label Sep 30, 2020
@davidkroell davidkroell self-assigned this Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant