1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 21:06:50 +01:00

Zepp OS: Decode workout elevation and altitude

This commit is contained in:
José Rebelo 2022-10-15 01:17:41 +01:00
parent 89251d27e1
commit 962efd51b4
4 changed files with 37 additions and 4 deletions

View File

@ -22,8 +22,6 @@ import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Date; import java.util.Date;
import nodomain.freeyourgadget.gadgetbridge.proto.HuamiProtos; import nodomain.freeyourgadget.gadgetbridge.proto.HuamiProtos;
@ -84,6 +82,7 @@ public class Huami2021ActivitySummaryParser extends HuamiActivitySummaryParser {
summary.setBaseLatitude(summaryProto.getLocation().getBaseLatitude()); summary.setBaseLatitude(summaryProto.getLocation().getBaseLatitude());
summary.setBaseAltitude(summaryProto.getLocation().getBaseAltitude() / 2); summary.setBaseAltitude(summaryProto.getLocation().getBaseAltitude() / 2);
// TODO: Min/Max Latitude/Longitude // TODO: Min/Max Latitude/Longitude
addSummaryData("baseAltitude", summaryProto.getLocation().getBaseAltitude() / 2, "meters");
} }
if (summaryProto.hasHeartRate()) { if (summaryProto.hasHeartRate()) {
@ -132,5 +131,19 @@ public class Huami2021ActivitySummaryParser extends HuamiActivitySummaryParser {
addSummaryData("currentWorkoutLoad", summaryProto.getTrainingEffect().getCurrentWorkoutLoad(), ""); addSummaryData("currentWorkoutLoad", summaryProto.getTrainingEffect().getCurrentWorkoutLoad(), "");
addSummaryData("maximumOxygenUptake", summaryProto.getTrainingEffect().getMaximumOxygenUptake(), "ml/kg/min"); addSummaryData("maximumOxygenUptake", summaryProto.getTrainingEffect().getMaximumOxygenUptake(), "ml/kg/min");
} }
if (summaryProto.hasAltitude()) {
addSummaryData("maxAltitude", summaryProto.getAltitude().getMaxAltitude() / 200, "meters");
addSummaryData("minAltitude", summaryProto.getAltitude().getMinAltitude() / 200, "meters");
addSummaryData("averageAltitude", summaryProto.getAltitude().getAvgAltitude() / 200, "meters");
// TODO totalClimbing
addSummaryData("elevationGain", summaryProto.getAltitude().getElevationGain() / 100, "meters");
addSummaryData("elevationLoss", summaryProto.getAltitude().getElevationLoss() / 100, "meters");
}
if (summaryProto.hasElevation()) {
addSummaryData("ascentSeconds", summaryProto.getElevation().getUphillTime(), "seconds");
addSummaryData("descentSeconds", summaryProto.getElevation().getDownhillTime(), "seconds");
}
} }
} }

View File

@ -158,7 +158,7 @@ public class ActivitySummaryJsonSummary {
put("Elevation", Arrays.asList( put("Elevation", Arrays.asList(
"ascentMeters", "descentMeters", "maxAltitude", "minAltitude", "averageAltitude", "ascentMeters", "descentMeters", "maxAltitude", "minAltitude", "averageAltitude",
"baseAltitude", "ascentSeconds", "descentSeconds", "flatSeconds", "ascentDistance", "baseAltitude", "ascentSeconds", "descentSeconds", "flatSeconds", "ascentDistance",
"descentDistance", "flatDistance" "descentDistance", "flatDistance", "elevationGain", "elevationLoss"
)); ));
put("Speed", Arrays.asList( put("Speed", Arrays.asList(
"averageSpeed", "maxSpeed", "minSpeed", "averageKMPaceSeconds", "minPace", "averageSpeed", "maxSpeed", "minSpeed", "averageKMPaceSeconds", "minPace",

View File

@ -11,14 +11,17 @@ message WorkoutSummary {
Steps steps = 11; Steps steps = 11;
Time time = 7; Time time = 7;
Pace pace = 10; Pace pace = 10;
Altitude altitude = 13;
HeartRate heartRate = 19; HeartRate heartRate = 19;
Calories calories = 16; Calories calories = 16;
TrainingEffect trainingEffect = 21; TrainingEffect trainingEffect = 21;
HeartRateZones heartRateZones = 22; HeartRateZones heartRateZones = 22;
Elevation elevation = 23;
} }
message Location { message Location {
// TODO 1, 2, 3 // TODO 2, 3
uint32 startTimestamp = 1; // unix epoch, seconds
int32 baseLatitude = 5; // /6000000 -> coords int32 baseLatitude = 5; // /6000000 -> coords
int32 baseLongitude = 6; // /-6000000 -> coords int32 baseLongitude = 6; // /-6000000 -> coords
int32 baseAltitude = 7; // /2 -> meters int32 baseAltitude = 7; // /2 -> meters
@ -61,6 +64,15 @@ message Pace {
float best = 2; // val * 1000 / 60 -> min/km float best = 2; // val * 1000 / 60 -> min/km
} }
message Altitude {
int32 maxAltitude = 1; // /200 -> meters
int32 minAltitude = 2; // /200 -> meters
int32 avgAltitude = 3; // /200 -> meters
int32 totalClimbing = 4; // cm
int32 elevationGain = 5; // cm
int32 elevationLoss = 6; // cm
}
message Calories { message Calories {
int32 calories = 1; // kcal int32 calories = 1; // kcal
} }
@ -72,6 +84,12 @@ message HeartRateZones {
repeated int32 zoneTime = 3; // seconds repeated int32 zoneTime = 3; // seconds
} }
message Elevation {
// TODO 1, 2?
uint32 uphillTime = 3; // sec
uint32 downhillTime = 4; // sec
}
message TrainingEffect { message TrainingEffect {
float aerobicTrainingEffect = 4; float aerobicTrainingEffect = 4;
float anaerobicTrainingEffect = 5; float anaerobicTrainingEffect = 5;

View File

@ -1360,6 +1360,8 @@
<string name="descentMeters">Downhill</string> <string name="descentMeters">Downhill</string>
<string name="ascentDistance">Uphill distance</string> <string name="ascentDistance">Uphill distance</string>
<string name="descentDistance">Downhill distance</string> <string name="descentDistance">Downhill distance</string>
<string name="elevationGain">Elevation gain</string>
<string name="elevationLoss">Elevation loss</string>
<string name="maxAltitude">Maximum</string> <string name="maxAltitude">Maximum</string>
<string name="minAltitude">Minimum</string> <string name="minAltitude">Minimum</string>
<string name="averageAltitude">Average</string> <string name="averageAltitude">Average</string>