@@ -22,17 +22,35 @@ func WriteWeight(w io.Writer, weights ...*core.Weight) error {
2222 scale .Timestamp = weight .Date
2323 scale .Weight = typedef .Weight (weight .Weight * 100 )
2424
25- scale .Bmi = uint16 (weight .BMI * 10 )
26- scale .PercentFat = uint16 (weight .BodyFat * 100 )
27- scale .PercentHydration = uint16 (weight .BodyWater * 100 )
28- scale .BoneMass = uint16 (weight .BoneMass * 100 )
25+ if weight .BMI != 0 {
26+ scale .Bmi = uint16 (weight .BMI * 10 )
27+ }
28+ if weight .BodyFat != 0 {
29+ scale .PercentFat = uint16 (weight .BodyFat * 100 )
30+ }
31+ if weight .BodyWater != 0 {
32+ scale .PercentHydration = uint16 (weight .BodyWater * 100 )
33+ }
34+ if weight .BoneMass != 0 {
35+ scale .BoneMass = uint16 (weight .BoneMass * 100 )
36+ }
2937
30- scale .MetabolicAge = uint8 (weight .MetabolicAge )
31- scale .MuscleMass = uint16 (weight .SkeletalMuscleMass * 100 )
32- scale .PhysiqueRating = uint8 (weight .PhysiqueRating )
33- scale .VisceralFatRating = uint8 (weight .VisceralFat )
38+ if weight .MetabolicAge != 0 {
39+ scale .MetabolicAge = uint8 (weight .MetabolicAge )
40+ }
41+ if weight .SkeletalMuscleMass != 0 {
42+ scale .MuscleMass = uint16 (weight .SkeletalMuscleMass * 100 )
43+ }
44+ if weight .PhysiqueRating != 0 {
45+ scale .PhysiqueRating = uint8 (weight .PhysiqueRating )
46+ }
47+ if weight .VisceralFat != 0 {
48+ scale .VisceralFatRating = uint8 (weight .VisceralFat )
49+ }
3450
35- scale .BasalMet = uint16 (weight .BasalMetabolism * 4 )
51+ if weight .BasalMetabolism != 0 {
52+ scale .BasalMet = uint16 (weight .BasalMetabolism * 4 )
53+ }
3654
3755 //scale.ActiveMet = 0
3856 //scale.VisceralFatMass = 0
0 commit comments