forked from 4kbt/ParseVivosmartHR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseFITs.sh
More file actions
executable file
·49 lines (38 loc) · 771 Bytes
/
Copy pathparseFITs.sh
File metadata and controls
executable file
·49 lines (38 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
#This code licensed under GPL v3. CAH.
bin/fitdump *.fit | grep -e heart -e timestamp |
sed 's/(//g' | sed 's/)//g' |
awk 'BEGIN{
#initialize variables
realTime = 0;
timestamp = 0;
timestamp16 = 0;
hrm = 0;
}
{
if( $1 == "timestamp")
{
timestamp = $NF;
}
if( $1 == "timestamp_16" )
{
timestamp16 = $NF;
}
if( $1 == "heart_rate")
{
hrm = $NF;
#Attempt to synthesize clock
newTime = int( timestamp / 2^16 ) * 2^16 + timestamp16;
#These blocks correct for base-16 rollover before timestamp update
if( newTime >= realTime ){
realTime = newTime;
}
else{
realTime = newTime + 2^16;
}
#Output!
#print int(timestamp/2^16)*2^16 "\t" timestamp16 "\t" hrm
print realTime "\t" hrm
}
}
'