tormoder / fit

A Go package for decoding and encoding Garmin FIT files
MIT License
245 stars 42 forks source link

Looks like LeftRightBalance is incorrectly calculated #86

Closed AAZANOVICH closed 8 months ago

AAZANOVICH commented 9 months ago

I.e. RecordMsg.LeftRightBalance what does 174 value mean ? Real value is 46% left / 54% right.

tormoder commented 9 months ago

A bitmask needs to be applied to this value to get the distribution, 0x7F will give right side (if it's set, that can be checked by value % 0x80 != 0).

174 % 0x7F is 47. So that would be right 47% / left 53 %.

Ideally we should generate an IsSet, RightValue and LeftValue for the LeftRightBalance type.

AAZANOVICH commented 9 months ago

Thanks for clarification! Definitely dealing with binary values and masks is not very transparent.

AAZANOVICH commented 8 months ago

@tormoder What about Altitude value in decoded Activity, fit.RecordMsg.Altitude = 3090 .. actual value 118m ???

AAZANOVICH commented 8 months ago

@tormoder What about Altitude value in decoded Activity, fit.RecordMsg.Altitude = 3090 .. actual value 118m ???

tormoder commented 8 months ago

@tormoder What about Altitude value in decoded Activity, fit.RecordMsg.Altitude = 3090 .. actual value 118m ???

It's a scaled field wih offset, (alt / 5) - 500.

See https://github.com/tormoder/fit/blob/52784557089cbcd87823f3d8002df1aba6e7f586/messages.go#L2652

AAZANOVICH commented 8 months ago

@tormoder Got it, so basically Get*Scaled() functions should be used to access record values all the time, I'm I correct ?

tormoder commented 8 months ago

@tormoder Got it, so basically Get*Scaled() functions should be used to access record values all the time, I'm I correct ?

Normally, yes.