Skip to content

Commit fd9ecc7

Browse files
committed
convert workTime to seconds as well
1 parent a5f3019 commit fd9ecc7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/models/workoutsummary.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import '../helpers.dart';
77
/// This takes care of dealing with byte endianness, combining multiple high and low bytes .etc so that applications using the data only have to deal with flutter [int] types
88
class WorkoutSummary {
99
final DateTime timestamp;
10-
final int workTime;
10+
final double workTime;
1111
final double workDistance;
1212
final int avgSPM;
1313
// final int endHeartRate;
@@ -20,7 +20,8 @@ class WorkoutSummary {
2020

2121
WorkoutSummary.fromBytes(Uint8List data)
2222
: timestamp = timeFromBytes(data.sublist(0, 4)),
23-
workTime = bytesToInt(data.sublist(4, 7), Endian.little),
23+
workTime = bytesToInt(data.sublist(4, 7), Endian.little) /
24+
100, //divide by 100 to convert to seconds
2425
workDistance = bytesToInt(data.sublist(7, 10), Endian.little) /
2526
10, //divide by 10 to convert to meters
2627
avgSPM = bytesToInt(data.sublist(10, 11), Endian.little);

test/workoutsummary_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ void main() {
77
test('can extract values from a workout summary byte list', () {
88
final summary = WorkoutSummary.fromBytes(Uint8List.fromList(
99
[0, 0, 0, 0, 128, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]));
10-
expect(summary.workTime, 128);
10+
expect(summary.workTime, 1.28);
1111
expect(summary.workDistance, 25.5);
1212
});
1313
}

0 commit comments

Comments
 (0)