1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-12 13:09:24 +01:00

Garmin: display pace for runing and swim workouts

This commit is contained in:
a0z 2024-10-03 18:43:45 +02:00 committed by José Rebelo
parent 2ee17bd52f
commit 5cbbe82846
3 changed files with 23 additions and 1 deletions

View File

@ -193,6 +193,22 @@ public class GarminWorkoutParser implements ActivitySummaryParser {
summaryData.add(DESCENT_DISTANCE, session.getTotalDescent(), UNIT_METERS);
}
if (session.getEnhancedAvgSpeed() != null) {
if (ActivityKind.isPaceActivity(activityKind)) {
summaryData.add(PACE_AVG_SECONDS_KM, Math.round((60 / (session.getEnhancedAvgSpeed() * 3.6)) * 60), UNIT_SECONDS);
} else {
summaryData.add(SPEED_AVG, Math.round((session.getEnhancedAvgSpeed() * 3600 / 1000) * 100.0) / 100.0, UNIT_KMPH);
}
}
if (session.getEnhancedMaxSpeed() != null) {
if (ActivityKind.isPaceActivity(activityKind)) {
summaryData.add(PACE_MAX, Math.round((60 / (session.getEnhancedMaxSpeed() * 3.6)) * 60), UNIT_SECONDS);
} else {
summaryData.add(SPEED_MAX, Math.round((session.getEnhancedMaxSpeed() * 3600 / 1000) * 100.0) / 100.0, UNIT_KMPH);
}
}
for (final FitTimeInZone fitTimeInZone : timesInZone) {
// Find the first time in zone for the session (assumes single-session)
if (fitTimeInZone.getReferenceMessage() != null && fitTimeInZone.getReferenceMessage() == 18) {

View File

@ -349,4 +349,10 @@ public enum ActivityKind {
|| activityKind == ActivityKind.REM_SLEEP
|| activityKind == ActivityKind.AWAKE_SLEEP;
}
public static boolean isPaceActivity(final ActivityKind activityKind) {
return activityKind.name().contains("RUN") || activityKind.name().contains("SWIM") ||
activityKind.name().contains("TREADMILL") || activityKind.name().contains("WALK");
}
}

View File

@ -57,7 +57,7 @@ public class ActivitySummaryJsonSummary {
summary.add("baseAltitude", item.getBaseAltitude(), UNIT_METERS);
}
if (!summary.has("averageSpeed") && summary.has("distanceMeters") && summary.has("activeSeconds")) {
if (!summary.has("averageKMPaceSeconds") && !summary.has("averageSpeed") && summary.has("distanceMeters") && summary.has("activeSeconds")) {
double distance = summary.getNumber("distanceMeters", 0).doubleValue();
double duration = summary.getNumber("activeSeconds", 1).doubleValue();
summary.add("averageSpeed", distance / duration, UNIT_METERS_PER_SECOND);