mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-11 10:25:49 +01:00
Xiaomi: Workout parser for jump roping (#4389)
workout parser for jump roping incl. new field names, units und a group Co-authored-by: AndrewP <> Reviewed-on: https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/4389 Co-authored-by: AndrewP <andrewp@noreply.codeberg.org> Co-committed-by: AndrewP <andrewp@noreply.codeberg.org>
This commit is contained in:
parent
c5714746fb
commit
cd7c7092b2
@ -104,6 +104,10 @@ public class ActivitySummaryEntries {
|
||||
public static final String STROKE_RATE_MAX = "maxStrokeRate";
|
||||
public static final String STROKES = "strokes";
|
||||
|
||||
public static final String JUMP_RATE_AVG = "avgJumpRate";
|
||||
public static final String JUMP_RATE_MAX = "maxJumpRate";
|
||||
public static final String JUMPS = "totalJumps";
|
||||
|
||||
public static final String SWIM_STYLE = "swimStyle";
|
||||
public static final String SWOLF_INDEX = "swolfIndex";
|
||||
public static final String SWOLF_AVG = "swolfAvg";
|
||||
@ -149,6 +153,8 @@ public class ActivitySummaryEntries {
|
||||
public static final String UNIT_STROKES = "strokes_unit";
|
||||
public static final String UNIT_STROKES_PER_MINUTE = "strokes_minute";
|
||||
public static final String UNIT_STROKES_PER_SECOND = "strokes_second";
|
||||
public static final String UNIT_JUMPS = "jumps_unit";
|
||||
public static final String UNIT_JUMPS_PER_MINUTE = "jumps_minute";
|
||||
public static final String UNIT_YARD = "yard";
|
||||
public static final String UNIT_DEGREES = "degrees";
|
||||
public static final String UNIT_STRING = "string";
|
||||
@ -161,6 +167,7 @@ public class ActivitySummaryEntries {
|
||||
public static final String GROUP_ELEVATION = "Elevation";
|
||||
public static final String GROUP_HEART_RATE_ZONES = "HeartRateZones";
|
||||
public static final String GROUP_STROKES = "Strokes";
|
||||
public static final String GROUP_JUMPS = "Jumps";
|
||||
public static final String GROUP_SWIMMING = "Swimming";
|
||||
public static final String GROUP_TRAINING_EFFECT = "TrainingEffect";
|
||||
public static final String GROUP_LAPS = "laps";
|
||||
|
@ -180,6 +180,9 @@ public class ActivitySummaryJsonSummary {
|
||||
STROKE_DISTANCE_AVG, STROKE_AVG_PER_SECOND, STROKES,
|
||||
STROKE_RATE_AVG, STROKE_RATE_MAX
|
||||
));
|
||||
put(GROUP_JUMPS, Arrays.asList(
|
||||
JUMPS, JUMP_RATE_AVG, JUMP_RATE_MAX
|
||||
));
|
||||
put(GROUP_SWIMMING, Arrays.asList(
|
||||
SWOLF_INDEX, SWOLF_AVG, SWOLF_MAX, SWOLF_MIN, SWIM_STYLE
|
||||
));
|
||||
|
@ -205,7 +205,7 @@ public class XiaomiActivityFileId implements Comparable<XiaomiActivityFileId> {
|
||||
SPORTS_HIIT(Type.SPORTS, 0x10),
|
||||
SPORTS_ELLIPTICAL(Type.SPORTS, 0x0B),
|
||||
SPORTS_ROWING(Type.SPORTS, 0x0D),
|
||||
SPORTS_ROPESKIPPING(Type.SPORTS, 0x0E), // TODO
|
||||
SPORTS_JUMP_ROPING(Type.SPORTS, 0x0E),
|
||||
SPORTS_OUTDOOR_WALKING_V2(Type.SPORTS, 0x16),
|
||||
SPORTS_OUTDOOR_CYCLING(Type.SPORTS, 0x17),
|
||||
;
|
||||
|
@ -45,6 +45,9 @@ import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.STEPS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.STROKES;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.STROKE_RATE_AVG;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.JUMPS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.JUMP_RATE_AVG;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.JUMP_RATE_MAX;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.SWIM_STYLE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.SWOLF_AVG;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.TIME_END;
|
||||
@ -66,6 +69,8 @@ import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_STEPS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_STROKES;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_STROKES_PER_MINUTE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_JUMPS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_JUMPS_PER_MINUTE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.UNIT_UNIX_EPOCH_SECONDS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.WORKOUT_LOAD;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.activity.impl.XiaomiSimpleActivityParser.XIAOMI_WORKOUT_TYPE;
|
||||
@ -225,6 +230,10 @@ public class WorkoutSummaryParser extends XiaomiActivityParser implements Activi
|
||||
summary.setActivityKind(ActivityKind.ROWING.getCode());
|
||||
parser = getRowingParser(fileId);
|
||||
break;
|
||||
case SPORTS_JUMP_ROPING:
|
||||
summary.setActivityKind(ActivityKind.JUMP_ROPING.getCode());
|
||||
parser = getJumpRopingParser(fileId);
|
||||
break;
|
||||
default:
|
||||
LOG.warn("No workout summary parser for {}", fileId.getSubtypeCode());
|
||||
break;
|
||||
@ -794,4 +803,46 @@ public class WorkoutSummaryParser extends XiaomiActivityParser implements Activi
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private XiaomiSimpleActivityParser getJumpRopingParser(final XiaomiActivityFileId fileId) {
|
||||
final int version = fileId.getVersion();
|
||||
final int headerSize;
|
||||
switch (version) {
|
||||
case 3:
|
||||
headerSize = 5;
|
||||
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.addUnknown(7);
|
||||
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);
|
||||
builder.addUnknown(2);
|
||||
builder.addInt(JUMPS, UNIT_JUMPS);
|
||||
builder.addShort(JUMP_RATE_AVG, UNIT_JUMPS_PER_MINUTE);
|
||||
builder.addUnknown(2);
|
||||
builder.addShort(JUMP_RATE_MAX, UNIT_JUMPS_PER_MINUTE);
|
||||
builder.addUnknown(43);
|
||||
builder.addUnknown(2); // configuredJumpsGoal, UNIT_JUMPS
|
||||
builder.addUnknown(2);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2246,6 +2246,9 @@
|
||||
<string name="avgStrokeRate">Average Stroke Rate</string>
|
||||
<string name="maxStrokeRate">Max Stroke Rate</string>
|
||||
<string name="strokes">Total Strokes</string>
|
||||
<string name="avgJumpRate">Average Jump Rate</string>
|
||||
<string name="maxJumpRate">Max Jump Rate</string>
|
||||
<string name="totalJumps">Total Jumps</string>
|
||||
<string name="averageLapPace">Average Lap Pace</string>
|
||||
<string name="swolfIndex">SWOLF</string>
|
||||
<string name="swolfAvg">Average swolf</string>
|
||||
@ -2301,6 +2304,8 @@
|
||||
<string name="strokes_second">str/s</string>
|
||||
<string name="strokes_minute">str/min</string>
|
||||
<string name="strokes_unit">str</string>
|
||||
<string name="jumps_minute">jumps/min</string>
|
||||
<string name="jumps_unit">jumps</string>
|
||||
<string name="seconds">sec</string>
|
||||
<string name="milliseconds">milliseconds</string>
|
||||
<string name="milliseconds_ms">ms</string>
|
||||
@ -2319,6 +2324,7 @@
|
||||
<string name="Pace">Pace</string>
|
||||
<!-- activity summary groups-->
|
||||
<string name="Strokes">Strokes</string>
|
||||
<string name="Jumps">Jumps</string>
|
||||
<string name="Swimming">Swimming</string>
|
||||
<string name="Distance">Distance</string>
|
||||
<string name="Elevation">Elevation</string>
|
||||
|
Loading…
Reference in New Issue
Block a user