mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-26 16:41:43 +01:00
Garmin: Fix cycle unit per activity kind
This commit is contained in:
parent
bcc6c23097
commit
6d26fd9495
@ -160,6 +160,8 @@ public class GarminWorkoutParser implements ActivitySummaryParser {
|
||||
} else {
|
||||
activityKind = getActivityKind(session.getSport(), session.getSubSport());
|
||||
}
|
||||
final ActivityKind.CycleUnit cycleUnit = ActivityKind.getCycleUnit(activityKind);
|
||||
|
||||
summary.setActivityKind(activityKind.getCode());
|
||||
|
||||
if (session.getTotalElapsedTime() != null) {
|
||||
@ -178,8 +180,8 @@ public class GarminWorkoutParser implements ActivitySummaryParser {
|
||||
if (session.getAvgSwolf() != null) {
|
||||
summaryData.add(SWOLF_AVG, session.getAvgSwolf(), UNIT_NONE);
|
||||
}
|
||||
if (session.getTotalSteps() != null) {
|
||||
summaryData.add(STEPS, session.getTotalSteps(), UNIT_STEPS);
|
||||
if (session.getTotalCycles() != null) {
|
||||
summaryData.addTotal(session.getTotalCycles(), cycleUnit);
|
||||
}
|
||||
if (session.getTotalCalories() != null) {
|
||||
summaryData.add(CALORIES_BURNT, session.getTotalCalories(), UNIT_KCAL);
|
||||
@ -215,10 +217,10 @@ public class GarminWorkoutParser implements ActivitySummaryParser {
|
||||
summaryData.add(STRESS_AVG, session.getAvgStress(), UNIT_NONE);
|
||||
}
|
||||
if (session.getAverageCadence() != null) {
|
||||
summaryData.add(CADENCE_AVG, session.getAverageCadence(), UNIT_SPM);
|
||||
summaryData.addCadenceAvg(session.getAverageCadence(), cycleUnit);
|
||||
}
|
||||
if (session.getMaxCadence() != null) {
|
||||
summaryData.add(CADENCE_MAX, session.getMaxCadence(), UNIT_SPM);
|
||||
summaryData.addCadenceMax(session.getMaxCadence(), cycleUnit);
|
||||
}
|
||||
if (session.getTotalAscent() != null) {
|
||||
summaryData.add(ASCENT_DISTANCE, session.getTotalAscent(), UNIT_METERS);
|
||||
|
@ -360,4 +360,84 @@ public enum ActivityKind {
|
||||
activityKind.name().contains("TREADMILL") || activityKind.name().contains("WALK");
|
||||
}
|
||||
|
||||
public static CycleUnit getCycleUnit(final ActivityKind activityKind) {
|
||||
switch (activityKind) {
|
||||
case BUNGEE_JUMPING:
|
||||
case JUMP_ROPING:
|
||||
case JUMPMASTER:
|
||||
case TRAMPOLINE:
|
||||
return CycleUnit.JUMPS;
|
||||
case BIKE_COMMUTE:
|
||||
case CYCLING:
|
||||
case E_BIKE:
|
||||
case HANDCYCLING:
|
||||
case HANDCYCLING_INDOOR:
|
||||
case INDOOR_CYCLING:
|
||||
case OUTDOOR_CYCLING:
|
||||
case SPINNING:
|
||||
return CycleUnit.REVOLUTIONS;
|
||||
case FLEXIBILITY:
|
||||
case BARBELL:
|
||||
case BATTLE_ROPE:
|
||||
case CORE_TRAINING:
|
||||
case CROSSFIT:
|
||||
case DUMBBELL:
|
||||
case FITNESS_EXERCISES:
|
||||
case FUNCTIONAL_TRAINING:
|
||||
case PILATES:
|
||||
case PLANK:
|
||||
case PULL_UPS:
|
||||
case PUSH_UPS:
|
||||
case SIT_UPS:
|
||||
case SMITH_MACHINE:
|
||||
case STRENGTH_TRAINING:
|
||||
case YOGA:
|
||||
return CycleUnit.REPS;
|
||||
case ARTISTIC_SWIMMING:
|
||||
case KAYAKING:
|
||||
case KITESURFING:
|
||||
case PADDLING:
|
||||
case POOL_SWIM:
|
||||
case RAFTING:
|
||||
case ROWING:
|
||||
case ROWING_MACHINE:
|
||||
case STAND_UP_PADDLEBOARDING:
|
||||
case SURFING:
|
||||
case SWIMMING:
|
||||
case SWIMMING_OPENWATER:
|
||||
case WAKEBOARDING:
|
||||
case WATER_SKIING:
|
||||
case WINDSURFING:
|
||||
return CycleUnit.STROKES;
|
||||
case BADMINTON:
|
||||
case GOLF:
|
||||
case HOCKEY:
|
||||
case LACROSSE:
|
||||
case PICKLEBALL:
|
||||
case PINGPONG:
|
||||
case RACKET:
|
||||
case RACQUETBALL:
|
||||
case SHUTTLECOCK:
|
||||
case SQUASH:
|
||||
case TABLE_TENNIS:
|
||||
case TENNIS:
|
||||
case BASEBALL:
|
||||
case CRICKET:
|
||||
case SOFTBALL:
|
||||
return CycleUnit.SWINGS;
|
||||
}
|
||||
|
||||
return CycleUnit.STEPS;
|
||||
}
|
||||
|
||||
public enum CycleUnit {
|
||||
NONE,
|
||||
UNKNOWN,
|
||||
STEPS,
|
||||
STROKES,
|
||||
JUMPS,
|
||||
REPS,
|
||||
REVOLUTIONS,
|
||||
SWINGS,
|
||||
}
|
||||
}
|
||||
|
@ -161,4 +161,61 @@ public class ActivitySummaryData {
|
||||
public String toJson() {
|
||||
return GSON.toJson(entries);
|
||||
}
|
||||
|
||||
public void addTotal(final Number value, final ActivityKind.CycleUnit unit) {
|
||||
switch (unit) {
|
||||
case STROKES:
|
||||
add(ActivitySummaryEntries.STROKES, value, ActivitySummaryEntries.UNIT_STROKES);
|
||||
break;
|
||||
case JUMPS:
|
||||
add(ActivitySummaryEntries.JUMPS, value, ActivitySummaryEntries.UNIT_JUMPS);
|
||||
break;
|
||||
case REPS:
|
||||
add(ActivitySummaryEntries.REPETITIONS, value, ActivitySummaryEntries.UNIT_REPS);
|
||||
break;
|
||||
case REVOLUTIONS:
|
||||
add(ActivitySummaryEntries.REVOLUTIONS, value, ActivitySummaryEntries.UNIT_REVS);
|
||||
break;
|
||||
default:
|
||||
add(ActivitySummaryEntries.STEPS, value, ActivitySummaryEntries.UNIT_STEPS);
|
||||
}
|
||||
}
|
||||
|
||||
public void addCadenceAvg(final Number value, final ActivityKind.CycleUnit unit) {
|
||||
switch (unit) {
|
||||
case STROKES:
|
||||
add(ActivitySummaryEntries.STROKE_RATE_AVG, value, ActivitySummaryEntries.UNIT_STROKES_PER_MINUTE);
|
||||
break;
|
||||
case JUMPS:
|
||||
add(ActivitySummaryEntries.JUMP_RATE_AVG, value, ActivitySummaryEntries.UNIT_JUMPS_PER_MINUTE);
|
||||
break;
|
||||
case REPS:
|
||||
add(ActivitySummaryEntries.CADENCE_AVG, value, ActivitySummaryEntries.UNIT_REPS_PER_MINUTE);
|
||||
break;
|
||||
case REVOLUTIONS:
|
||||
add(ActivitySummaryEntries.CADENCE_AVG, value, ActivitySummaryEntries.UNIT_REVS_PER_MINUTE);
|
||||
break;
|
||||
default:
|
||||
add(ActivitySummaryEntries.CADENCE_AVG, value, ActivitySummaryEntries.UNIT_SPM);
|
||||
}
|
||||
}
|
||||
|
||||
public void addCadenceMax(final Number value, final ActivityKind.CycleUnit unit) {
|
||||
switch (unit) {
|
||||
case STROKES:
|
||||
add(ActivitySummaryEntries.STROKE_RATE_MAX, value, ActivitySummaryEntries.UNIT_STROKES_PER_MINUTE);
|
||||
break;
|
||||
case JUMPS:
|
||||
add(ActivitySummaryEntries.JUMP_RATE_MAX, value, ActivitySummaryEntries.UNIT_JUMPS_PER_MINUTE);
|
||||
break;
|
||||
case REPS:
|
||||
add(ActivitySummaryEntries.CADENCE_MAX, value, ActivitySummaryEntries.UNIT_REPS_PER_MINUTE);
|
||||
break;
|
||||
case REVOLUTIONS:
|
||||
add(ActivitySummaryEntries.CADENCE_MAX, value, ActivitySummaryEntries.UNIT_REVS_PER_MINUTE);
|
||||
break;
|
||||
default:
|
||||
add(ActivitySummaryEntries.CADENCE_MAX, value, ActivitySummaryEntries.UNIT_SPM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -136,6 +136,8 @@ public class ActivitySummaryEntries {
|
||||
public static final String CYCLING_POWER_MAX = "cyclingPowerMax";
|
||||
|
||||
public static final String SETS = "workoutSets";
|
||||
public static final String REPETITIONS = "workout_repetitions";
|
||||
public static final String REVOLUTIONS = "workout_revolutions";
|
||||
|
||||
public static final String UNIT_BPM = "bpm";
|
||||
public static final String UNIT_BREATHS_PER_MIN = "breaths_per_min";
|
||||
@ -163,7 +165,11 @@ public class ActivitySummaryEntries {
|
||||
public static final String UNIT_STROKES_PER_SECOND = "strokes_second";
|
||||
public static final String UNIT_STROKES_PER_LENGTH = "strokes_per_length";
|
||||
public static final String UNIT_JUMPS = "jumps_unit";
|
||||
public static final String UNIT_REPS = "unit_repetitions";
|
||||
public static final String UNIT_REVS = "unit_revolutions";
|
||||
public static final String UNIT_JUMPS_PER_MINUTE = "jumps_minute";
|
||||
public static final String UNIT_REPS_PER_MINUTE = "unit_repetitions_per_minute";
|
||||
public static final String UNIT_REVS_PER_MINUTE = "unit_revolutions_per_minute";
|
||||
public static final String UNIT_YARD = "yard";
|
||||
public static final String UNIT_DEGREES = "degrees";
|
||||
public static final String UNIT_STRING = "string";
|
||||
|
@ -99,7 +99,7 @@ public class GlobalFITMessage {
|
||||
new FieldDefinitionPrimitive(7, BaseType.UINT32, "total_elapsed_time"), // with pauses
|
||||
new FieldDefinitionPrimitive(8, BaseType.UINT32, "total_timer_time"), // no pauses
|
||||
new FieldDefinitionPrimitive(9, BaseType.UINT32, "total_distance"),
|
||||
new FieldDefinitionPrimitive(10, BaseType.UINT32, "total_steps"),
|
||||
new FieldDefinitionPrimitive(10, BaseType.UINT32, "total_cycles"),
|
||||
new FieldDefinitionPrimitive(11, BaseType.UINT16, "total_calories"),
|
||||
new FieldDefinitionPrimitive(16, BaseType.UINT8, "average_heart_rate"),
|
||||
new FieldDefinitionPrimitive(17, BaseType.UINT8, "max_heart_rate"),
|
||||
|
@ -71,7 +71,7 @@ public class FitSession extends RecordData {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getTotalSteps() {
|
||||
public Long getTotalCycles() {
|
||||
return (Long) getFieldByNumber(10);
|
||||
}
|
||||
|
||||
|
@ -2333,6 +2333,12 @@
|
||||
<string name="strokes_unit">str</string>
|
||||
<string name="jumps_minute">jumps/min</string>
|
||||
<string name="jumps_unit">jumps</string>
|
||||
<string name="unit_repetitions">reps</string>
|
||||
<string name="unit_revolutions">revs</string>
|
||||
<string name="unit_repetitions_per_minute">reps/min</string>
|
||||
<string name="unit_revolutions_per_minute">revs/min</string>
|
||||
<string name="workout_repetitions">Repetitions</string>
|
||||
<string name="workout_revolutions">Revolutions</string>
|
||||
<string name="seconds">sec</string>
|
||||
<string name="milliseconds">milliseconds</string>
|
||||
<string name="milliseconds_ms">ms</string>
|
||||
|
Loading…
Reference in New Issue
Block a user