I’m trying to write 10 Hz data to the fit file in a ConnectIQ App. The fit file only updates once per second so I’m putting the 10 Hz data into a 10 element array. I have one field that is an array of time stamps and two fields that are corresponding arrays of data. I have a script written in Intervals.icu to unpack and graph the data as a post process.
This works pretty well except that occasionally, the setData and the actual fit file writing are out of sync. I’m using a 1000 msec timer to drive the calls to setData(). Sometimes I get two data points written twice and one skipped. So instead of getting data sets 0,1,2,3,4,5,6…, I get data sets 0,1,2,3,3,5,6 in the .fit file.
Is there a good way to handle this in a ConnectIQ app? I’m not seeing any way to know when the fit file has actually been written so I could buffer the data that I’m putting in to setData().
The workaround that I’m considering is doubling the array lengths to contain 2 seconds worth of data. So the first call to setData has data set 0, the second setData has data set 0-1, the third setData has data set 1-2, etc. I have to write an unpacking script anyway so the only drawback is that I’m writing twice as much data as necessary.
The total fit contribution seems to be limited to 256 bytes but I think I can stay under that.
Is there a better approach to this?