1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-26 02:25:50 +01:00

Xiaomi: Parse HIIT workout summary

This commit is contained in:
José Rebelo 2024-07-15 20:09:12 +01:00
parent 8a6171962b
commit 6e2f7e01fc
2 changed files with 41 additions and 1 deletions

View File

@ -200,6 +200,7 @@ public class XiaomiActivityFileId implements Comparable<XiaomiActivityFileId> {
SPORTS_INDOOR_CYCLING(Type.SPORTS, 0x07), SPORTS_INDOOR_CYCLING(Type.SPORTS, 0x07),
SPORTS_FREESTYLE(Type.SPORTS, 0x08), SPORTS_FREESTYLE(Type.SPORTS, 0x08),
SPORTS_POOL_SWIMMING(Type.SPORTS, 0x09), SPORTS_POOL_SWIMMING(Type.SPORTS, 0x09),
SPORTS_HIIT(Type.SPORTS, 0x10),
SPORTS_ELLIPTICAL(Type.SPORTS, 0x0B), SPORTS_ELLIPTICAL(Type.SPORTS, 0x0B),
SPORTS_OUTDOOR_WALKING_V2(Type.SPORTS, 0x16), SPORTS_OUTDOOR_WALKING_V2(Type.SPORTS, 0x16),
SPORTS_OUTDOOR_CYCLING(Type.SPORTS, 0x17), SPORTS_OUTDOOR_CYCLING(Type.SPORTS, 0x17),

View File

@ -165,6 +165,10 @@ public class WorkoutSummaryParser extends XiaomiActivityParser implements Activi
summary.setActivityKind(ActivityKind.TYPE_SWIMMING); summary.setActivityKind(ActivityKind.TYPE_SWIMMING);
parser = getPoolSwimmingParser(fileId); parser = getPoolSwimmingParser(fileId);
break; break;
case SPORTS_HIIT:
summary.setActivityKind(ActivityKind.TYPE_EXERCISE);
parser = getHiitParser(fileId);
break;
case SPORTS_ELLIPTICAL: case SPORTS_ELLIPTICAL:
summary.setActivityKind(ActivityKind.TYPE_ELLIPTICAL_TRAINER); summary.setActivityKind(ActivityKind.TYPE_ELLIPTICAL_TRAINER);
// TODO // TODO
@ -424,7 +428,42 @@ public class WorkoutSummaryParser extends XiaomiActivityParser implements Activi
} }
@Nullable @Nullable
private XiaomiSimpleActivityParser getPoolSwimmingParser(final XiaomiActivityFileId fileId){ private XiaomiSimpleActivityParser getHiitParser(final XiaomiActivityFileId fileId){
final int version = fileId.getVersion();
final int headerSize;
switch (version) {
case 5:
headerSize = 3;
break;
default:
LOG.warn("Unable to parse workout summary version {}", fileId.getVersion());
return null;
}
final XiaomiSimpleActivityParser.Builder builder = new XiaomiSimpleActivityParser.Builder();
builder.setHeaderSize(headerSize);
builder.addInt(TIME_START, UNIT_UNIX_EPOCH_SECONDS);
builder.addInt(TIME_END, UNIT_UNIX_EPOCH_SECONDS);
builder.addInt(ACTIVE_SECONDS, UNIT_SECONDS);
builder.addShort(CALORIES_BURNT, UNIT_KCAL);
builder.addByte(HR_AVG, UNIT_BPM);
builder.addByte(HR_MAX, UNIT_BPM);
builder.addByte(HR_MIN, UNIT_BPM);
builder.addFloat(TRAINING_EFFECT_AEROBIC, UNIT_NONE);
builder.addUnknown(1);
builder.addUnknown(1);
builder.addShort(RECOVERY_TIME, UNIT_HOURS);
builder.addInt(HR_ZONE_EXTREME, UNIT_SECONDS);
builder.addInt(HR_ZONE_ANAEROBIC, UNIT_SECONDS);
builder.addInt(HR_ZONE_AEROBIC, UNIT_SECONDS);
builder.addInt(HR_ZONE_FAT_BURN, UNIT_SECONDS);
builder.addInt(HR_ZONE_WARM_UP, UNIT_SECONDS);
return builder.build();
}
@Nullable
private XiaomiSimpleActivityParser getPoolSwimmingParser(final XiaomiActivityFileId fileId) {
final int version = fileId.getVersion(); final int version = fileId.getVersion();
final int headerSize; final int headerSize;
switch (version) { switch (version) {