mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 09:01:55 +01:00
Switch from kcal to cal in samples
This allows for higher precision in devices that support it.
This commit is contained in:
parent
d807909b25
commit
600629e7ed
@ -1363,7 +1363,7 @@ public class GBDaoGenerator {
|
||||
activitySample.addIntProperty("calories").notNull().codeBeforeGetter(
|
||||
"@Override\n" +
|
||||
" public int getActiveCalories() {\n" +
|
||||
" return getCalories() == HuaweiActivitySample.NOT_MEASURED ? HuaweiActivitySample.NOT_MEASURED : Math.round(getCalories() / 1000f);\n" +
|
||||
" return getCalories();\n" +
|
||||
" }\n"
|
||||
);
|
||||
activitySample.addIntProperty("distance").notNull().codeBeforeGetter(
|
||||
|
@ -172,6 +172,8 @@ public class CaloriesDailyFragment extends AbstractChartFragment<CaloriesDailyFr
|
||||
activeBurnt += sample.getActiveCalories();
|
||||
}
|
||||
}
|
||||
// Convert calories to kcal
|
||||
activeBurnt = activeBurnt / 1000;
|
||||
totalBurnt = restingBurnt + activeBurnt;
|
||||
|
||||
return new CaloriesData(totalBurnt, activeBurnt, restingBurnt);
|
||||
|
@ -108,6 +108,7 @@ public class GarminActivitySampleProvider extends AbstractSampleProvider<GarminA
|
||||
convertCumulativeSteps(samples, GarminActivitySampleDao.Properties.Steps);
|
||||
}
|
||||
|
||||
convertCalories(samples);
|
||||
overlaySleep(samples, timestamp_from, timestamp_to);
|
||||
|
||||
final long nanoEnd = System.nanoTime();
|
||||
@ -119,6 +120,15 @@ public class GarminActivitySampleProvider extends AbstractSampleProvider<GarminA
|
||||
return samples;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the calories from kcal to cal
|
||||
*/
|
||||
private void convertCalories(List<GarminActivitySample> samples) {
|
||||
for (GarminActivitySample sample : samples) {
|
||||
sample.setActiveCalories(sample.getActiveCalories() * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
public void overlaySleep(final List<GarminActivitySample> samples, final int timestamp_from, final int timestamp_to) {
|
||||
// The samples provided by Garmin are upper-bound timestamps of the sleep stage
|
||||
final RangeMap<Long, ActivityKind> stagesMap = new RangeMap<>(RangeMap.Mode.UPPER_BOUND);
|
||||
|
@ -78,7 +78,7 @@ public interface ActivitySample extends TimeStamped {
|
||||
int getDistanceCm();
|
||||
|
||||
/**
|
||||
* Returns the calories burned during the period of this sample, in kcal. -1 if unknown.
|
||||
* Returns the calories burned during the period of this sample, in calories. -1 if unknown.
|
||||
*/
|
||||
int getActiveCalories();
|
||||
|
||||
|
@ -75,7 +75,8 @@ public class DashboardUtils {
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Could not calculate total amount of active calories: ", e);
|
||||
}
|
||||
return totalActiveCalories;
|
||||
// Convert calories to kcal
|
||||
return totalActiveCalories / 1000;
|
||||
}
|
||||
|
||||
public static int getRestingCaloriesTotal(DashboardFragment.DashboardData dashboardData) {
|
||||
|
Loading…
Reference in New Issue
Block a user