Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

How to decode left_right_balance field?

Rank

Total Posts: 6

Joined 2016-03-21

PM

Hello:

I need to decode the left_right_balance data from a FIT, and I don't know how to do it. I see the field is of type FIT_LEFT_RIGHT_BALANCE, which is actually a FIT_UINT8. I see also in the tye definition the types FIT_LEFT_RIGHT_BALANCE_MASK, FIT_LEFT_RIGHT_BALANCE_RIGHT, and FIT_LEFT_RIGHT_BALANCE_COUNT, but I don't know how to deal with them. Could anyone tell me how to decode the data?

Thanks      
RankRankRankRank

Total Posts: 122

Joined 2010-10-25

PM

Fairly sure it's going to be straight as from the Bike power profile. Read that doc for the bits about power balance and try decoding as per that.      
RankRank

Total Posts: 44

Joined 2013-04-07

PM

jgpallero - 24 March 2016 06:28 AM

decode the left_right_balance

Welcome to the forum, it is no secret: (I hope so)

left_right_balance (uint8)
mask 0x7F % contribution
right 0x80 data corresponds to right if set, otherwise unknown

left_right_balance_100 (uint16)
mask 0x3FFF % contribution scaled by 100
right 0x8000 data corresponds to right if set, otherwise unknown

left_right_balance e.g. in Python:
right = (value 0b01111111

left 100 right

set_right 
= (value 0b10000000) >> 7

if set_right:
    
decode 'L/R 'str(left) + '%-' str(right)+'%'

else:
    
decode '?/? ' str(left) + '%-' str(right)+'%' 

     
Rank

Total Posts: 6

Joined 2016-03-21

PM

edge-python - 29 March 2016 01:25 PM
jgpallero - 24 March 2016 06:28 AM

decode the left_right_balance

Welcome to the forum, it is no secret: (I hope so)

left_right_balance (uint8)
mask 0x7F % contribution
right 0x80 data corresponds to right if set, otherwise unknown

left_right_balance_100 (uint16)
mask 0x3FFF % contribution scaled by 100
right 0x8000 data corresponds to right if set, otherwise unknown

left_right_balance e.g. in Python:
right = (value 0b01111111

left 100 right

set_right 
= (value 0b10000000) >> 7

if set_right:
    
decode 'L/R 'str(left) + '%-' str(right)+'%'

else:
    
decode '?/? ' str(left) + '%-' str(right)+'%' 



Thank you for your answer. Finally I've found some code in C and along with your instructions I've written my code:

int right=0;
if((
record->left_right_balance!=FIT_LEFT_RIGHT_BALANCE_INVALID)&&
   (
record->left_right_balance&FIT;_LEFT_RIGHT_BALANCE_RIGHT))
{
    right 
record->left_right_balance&FIT;_LEFT_RIGHT_BALANCE_MASK;
    
printf("Right = %d\n",right);
    
printf("Left  = %d\n",100.0-right);


where FIT_LEFT_RIGHT_BALANCE_INVALID is the value for no data, FIT_LEFT_RIGHT_BALANCE_RIGHT is the checking value for "data corresponds to right if set, otherwise unknown" and FIT_LEFT_RIGHT_BALANCE_MASK is the value to decode the contribution.

I'm a bit confused about the "data corresponds to right if set, otherwise unknown" statement. What is the meaning of "unknown"? Means that there is no data as it can be checked via FIT_LEFT_RIGHT_BALANCE_INVALID?, means that there is a value but it is meaningless?, or maybe means that the value is for the left leg?

Thanks      
RankRank

Total Posts: 44

Joined 2013-04-07

PM

jgpallero - 30 March 2016 01:19 AM
I'm a bit confused about the "data corresponds to right if set, otherwise unknown" statement. What is the meaning of "unknown"?

it means:
if set (1):     balance value is for right
if not set (0): balance value is for right or for leftit is unknown 

(and please: reduce the quote grin )      
Rank

Total Posts: 6

Joined 2016-03-21

PM

edge-python - 30 March 2016 07:51 AM

it means:
if set (1):     balance value is for right
if not set (0): balance value is for right or for leftit is unknown 

(and please: reduce the quote grin )


Thank you