1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-15 06:29:24 +01:00

Garmin: Fix overcounting of steps

When going past midnight we were not resetting the number of steps,
resulting in a negative value, which would cause the next sample to
overcount.
This commit is contained in:
José Rebelo 2024-05-08 21:41:38 +01:00 committed by Daniele Gobbetti
parent 709afc5df7
commit f210b3b732

View File

@ -137,7 +137,11 @@ public class GarminActivitySampleProvider extends AbstractSampleProvider<GarminA
cal.setTimeInMillis(s2.getTimestamp() * 1000L - 1000L);
final LocalDate d2 = LocalDate.of(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH));
if (d1.equals(d2) && s2.getSteps() > 0) {
if (!d1.equals(d2)) {
// went past midnight - reset steps
prevSteps = s2.getSteps() > 0 ? s2.getSteps() : 0;
} else if (s2.getSteps() > 0) {
// New steps sample for the current day - subtract the previous seen sample
int bak = s2.getSteps();
s2.setSteps(s2.getSteps() - prevSteps);
prevSteps = bak;