Temperature from FIT/GPX in the profile chart, splits and summary
This commit is contained in:
1 parent
e3f08f2267
commit
ebd4852e98
5 files changed
+27
-12
No files matched your search
+6
-4
@@ -72,16 +72,16 @@ class FitTest < Minitest::Test
|
||||
body << [0b00000001].pack("C") << [sport].pack("C")
|
||||
end
|
||||
|
||||
record_definition = [0, 0].pack("CC") + [20].pack("S<") + [6].pack("C") +
|
||||
record_definition = [0, 0].pack("CC") + [20].pack("S<") + [7].pack("C") +
|
||||
[0, 4, 0x85].pack("C3") + [1, 4, 0x85].pack("C3") +
|
||||
[3, 1, 0x02].pack("C3") + [4, 1, 0x02].pack("C3") + [6, 2, 0x84].pack("C3") + [7, 2, 0x84].pack("C3")
|
||||
[3, 1, 0x02].pack("C3") + [4, 1, 0x02].pack("C3") + [6, 2, 0x84].pack("C3") + [7, 2, 0x84].pack("C3") + [13, 1, 0x01].pack("C3")
|
||||
body << [0b01000000].pack("C") << record_definition
|
||||
|
||||
records.each do |r|
|
||||
body << [0b00000000].pack("C") << le32(r[:lat]) << le32(r[:lon])
|
||||
body << [r[:heart_rate] || 0xFF].pack("C") << [r[:cadence] || 0xFF].pack("C")
|
||||
speed_raw = r[:speed_mps] ? (r[:speed_mps] * 1000).round : 0xFFFF
|
||||
body << [speed_raw].pack("S<") << [r[:power] || 0xFFFF].pack("S<")
|
||||
body << [speed_raw].pack("S<") << [r[:power] || 0xFFFF].pack("S<") << [r[:temperature] || 0x7F].pack("c")
|
||||
end
|
||||
|
||||
header = [12, 16, 0, 0].pack("C2S<") + le32(body.bytesize) + ".FIT"
|
||||
@@ -110,7 +110,7 @@ class FitTest < Minitest::Test
|
||||
|
||||
def test_profile_carries_heart_rate_cadence_and_speed_treating_0xff_as_absent
|
||||
path = write_activity_fit([
|
||||
{ lat: 100_000_000, lon: 200_000_000, heart_rate: 140, cadence: 80, speed_mps: 3.5, power: 250 },
|
||||
{ lat: 100_000_000, lon: 200_000_000, heart_rate: 140, cadence: 80, speed_mps: 3.5, power: 250, temperature: -4 },
|
||||
{ lat: 100_000_100, lon: 200_000_100 }, # no extras -> 0xFF/0xFFFF sentinels
|
||||
])
|
||||
|
||||
@@ -121,6 +121,8 @@ class FitTest < Minitest::Test
|
||||
assert_in_delta 3.5, profile[0]["speed_mps"]
|
||||
assert_equal 250, profile[0]["power_w"]
|
||||
assert_nil profile[1]["power_w"]
|
||||
assert_equal(-4, profile[0]["temperature_c"])
|
||||
assert_nil profile[1]["temperature_c"]
|
||||
assert_nil profile[1]["heart_rate_bpm"]
|
||||
assert_nil profile[1]["speed_mps"]
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user