mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-24 19:06:53 +01:00
Zepp OS: Display HR zones and Training Effect in Activity Details
This commit is contained in:
parent
7d516a9c96
commit
d655f434f8
@ -113,11 +113,24 @@ public class Huami2021ActivitySummaryParser extends HuamiActivitySummaryParser {
|
||||
}
|
||||
|
||||
if (summaryProto.hasHeartRateZones()) {
|
||||
// TODO HR zones
|
||||
// TODO hr zones bpm?
|
||||
if (summaryProto.getHeartRateZones().getZoneTimeCount() == 6) {
|
||||
addSummaryData("hrZoneNa", summaryProto.getHeartRateZones().getZoneTime(0), "seconds");
|
||||
addSummaryData("hrZoneWarmUp", summaryProto.getHeartRateZones().getZoneTime(1), "seconds");
|
||||
addSummaryData("hrZoneFatBurn", summaryProto.getHeartRateZones().getZoneTime(2), "seconds");
|
||||
addSummaryData("hrZoneAerobic", summaryProto.getHeartRateZones().getZoneTime(3), "seconds");
|
||||
addSummaryData("hrZoneAnaerobic", summaryProto.getHeartRateZones().getZoneTime(4), "seconds");
|
||||
addSummaryData("hrZoneExtreme", summaryProto.getHeartRateZones().getZoneTime(5), "seconds");
|
||||
} else {
|
||||
LOG.warn("Unexpected number of HR zones {}", summaryProto.getHeartRateZones().getZoneTimeCount());
|
||||
}
|
||||
}
|
||||
|
||||
if (summaryProto.hasTrainingEffect()) {
|
||||
// TODO training effect
|
||||
addSummaryData("aerobicTrainingEffect", summaryProto.getTrainingEffect().getAerobicTrainingEffect(), "");
|
||||
addSummaryData("anaerobicTrainingEffect", summaryProto.getTrainingEffect().getAnaerobicTrainingEffect(), "");
|
||||
addSummaryData("currentWorkoutLoad", summaryProto.getTrainingEffect().getCurrentWorkoutLoad(), "");
|
||||
addSummaryData("maximumOxygenUptake", summaryProto.getTrainingEffect().getMaximumOxygenUptake(), "ml/kg/min");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,11 @@ import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiActivitySummaryParser;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummary;
|
||||
@ -144,20 +148,39 @@ public class ActivitySummaryJsonSummary {
|
||||
return defaultGroup;
|
||||
}
|
||||
private JSONObject createActivitySummaryGroups(){
|
||||
String groupDefinitions = "{'Strokes':['averageStrokeDistance','averageStrokesPerSecond','strokes'], " +
|
||||
"'Swimming':['swolfIndex','swimStyle'], " +
|
||||
"'Elevation':['ascentMeters','descentMeters','maxAltitude','minAltitude','averageAltitude', 'baseAltitude','ascentSeconds','descentSeconds','flatSeconds','ascentDistance','descentDistance','flatDistance'], " +
|
||||
"'Speed':['averageSpeed','maxSpeed','minSpeed','averageKMPaceSeconds','minPace','maxPace','averageSpeed2','averageCadence','maxCadence','minCadence'], " +
|
||||
"'Activity':['distanceMeters','steps','activeSeconds','caloriesBurnt','totalStride'," +
|
||||
"'averageHR','maxHR','minHR','averageStride','maxStride','minStride'], " +
|
||||
"'Laps':['averageLapPace','laps']}";
|
||||
JSONObject data = null;
|
||||
try {
|
||||
data = new JSONObject(groupDefinitions);
|
||||
} catch (JSONException e) {
|
||||
LOG.error("SportsActivity", e);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
final Map<String, List<String>> groupDefinitions = new HashMap<String, List<String>>() {{
|
||||
put("Strokes", Arrays.asList(
|
||||
"averageStrokeDistance", "averageStrokesPerSecond", "strokes"
|
||||
));
|
||||
put("Swimming", Arrays.asList(
|
||||
"swolfIndex", "swimStyle"
|
||||
));
|
||||
put("Elevation", Arrays.asList(
|
||||
"ascentMeters", "descentMeters", "maxAltitude", "minAltitude", "averageAltitude",
|
||||
"baseAltitude", "ascentSeconds", "descentSeconds", "flatSeconds", "ascentDistance",
|
||||
"descentDistance", "flatDistance"
|
||||
));
|
||||
put("Speed", Arrays.asList(
|
||||
"averageSpeed", "maxSpeed", "minSpeed", "averageKMPaceSeconds", "minPace",
|
||||
"maxPace", "averageSpeed2", "averageCadence", "maxCadence", "minCadence"
|
||||
));
|
||||
put("Activity", Arrays.asList(
|
||||
"distanceMeters", "steps", "activeSeconds", "caloriesBurnt", "totalStride",
|
||||
"averageHR", "maxHR", "minHR", "averageStride", "maxStride", "minStride"
|
||||
));
|
||||
put("HeartRateZones", Arrays.asList(
|
||||
"hrZoneNa", "hrZoneWarmUp", "hrZoneFatBurn", "hrZoneAerobic", "hrZoneAnaerobic",
|
||||
"hrZoneExtreme"
|
||||
));
|
||||
put("TrainingEffect", Arrays.asList(
|
||||
"aerobicTrainingEffect", "anaerobicTrainingEffect", "currentWorkoutLoad",
|
||||
"maximumOxygenUptake"
|
||||
));
|
||||
put("Laps", Arrays.asList(
|
||||
"averageLapPace", "laps"
|
||||
));
|
||||
}};
|
||||
|
||||
return new JSONObject(groupDefinitions);
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class DateTimeUtils {
|
||||
public static String formatDurationHoursMinutes(long duration, TimeUnit unit) {
|
||||
DurationFormatter df = DurationFormatter.Builder.SYMBOLS
|
||||
.maximum(TimeUnit.DAYS)
|
||||
.minimum(TimeUnit.MINUTES)
|
||||
.minimum(TimeUnit.SECONDS)
|
||||
.suppressZeros(DurationFormatter.SuppressZeros.LEADING, DurationFormatter.SuppressZeros.TRAILING)
|
||||
.maximumAmountOfUnitsToShow(2)
|
||||
.build();
|
||||
|
@ -1374,6 +1374,18 @@
|
||||
<string name="maxHR">Max Heartrate</string>
|
||||
<string name="minHR">Min Heartrate</string>
|
||||
<string name="averageKMPaceSeconds">Pace</string>
|
||||
<string name="HeartRateZones">Heart Rate Zones</string>
|
||||
<string name="hrZoneNa">N/A</string>
|
||||
<string name="hrZoneWarmUp">Warm-Up</string>
|
||||
<string name="hrZoneFatBurn">Fat Burn</string>
|
||||
<string name="hrZoneAerobic">Aerobic</string>
|
||||
<string name="hrZoneAnaerobic">Anaerobic</string>
|
||||
<string name="hrZoneExtreme">Extreme</string>
|
||||
<string name="TrainingEffect">Training Effect</string>
|
||||
<string name="aerobicTrainingEffect">Aerobic Effect</string>
|
||||
<string name="anaerobicTrainingEffect">Anaerobic Effect</string>
|
||||
<string name="currentWorkoutLoad">Workout Load</string>
|
||||
<string name="maximumOxygenUptake">Maximum Oxygen Uptake</string>
|
||||
<string name="averageStride">Average Stride</string>
|
||||
<string name="maxStride">Max Stride</string>
|
||||
<string name="minStride">Min Stride</string>
|
||||
|
Loading…
Reference in New Issue
Block a user