Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
Big improvement in kcal accuracy (Fix 0 kcal)...
Browse files Browse the repository at this point in the history
This will improve accuracy significantly, I'll put some examples:
Lets say kcal per min are 4 and time is 89s
 4 * (90 / 60) = 4 kcal
 (4 * 90) / 60 = 6 kcal
In big trains without much intervals that will be insignificant, but if we are talking about 12x90s intervals the difference is of 24 (72 - 48), which is a 50%! And if we increase interval's time, that percentage will be even higher
But it's even worse if we are talking about <60s intervals, because there kcal will be always 0:
4 * (59 / 60) = 0 kcal
(4 * 59) / 60 = 4 kcal
I just did a train and I exported to tcx and uploaded to strava, and there were just 7 kcal in ~15 mins, after looking the tcx, I found what I expected: just one of the intervals was >60s, and that one had 7 kcal, and all of the others had 0 kcal

Signed-off-by: Miguel <[email protected]>
  • Loading branch information
micrusa committed Jun 16, 2020
1 parent 1ef6364 commit 11e9f2f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/src/main/java/me/micrusa/amaztimer/utils/latestTraining.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ void saveDataToFile(Context context, int time){

public static int calculateKcal(int avgHr, int time, int age, int weight, boolean isMale){
if(avgHr==0||time==0||age==0||weight==0){return 0;}
double kcal;
double kcalPerMin;
//Formula from https://www.calculatorpro.com/calculator/calories-burned-by-heart-rate/
if(isMale){
kcal = (-55.0969 + (0.6309 * avgHr) + (0.1988 * weight) + (0.2017 * age)) / 4.184;
kcalPerMin = (-55.0969 + (0.6309 * avgHr) + (0.1988 * weight) + (0.2017 * age)) / 4.184;
}else{
kcal = (-20.4022 + (0.4472 * avgHr) + (0.1263 * weight) + (0.074) * age) / 4.184;
kcalPerMin = (-20.4022 + (0.4472 * avgHr) + (0.1263 * weight) + (0.074) * age) / 4.184;
}
//Convert time to mins and then multiply by kcal/min
return (int) kcal * (time / 60);
//Calculate kcal from kcal/min
return (int) (kcalPerMin * time) / 60;
}

void cleanAllValues(Context context){
Expand Down

0 comments on commit 11e9f2f

Please sign in to comment.