FitContributor Question

Hello,

I am trying to capture some data from the watch and save it to the fit file.
All works fine, but I have one question. I started an timer with 1 second, and every second I will save one data in the fit-file with .setData(value)
This works fine, I get the expected result in the fit file.
My question is, is it possible to save data, lets say twice a second (timer of 500ms), into the fit file?

I tried it with simple numbers (simple increment per timer-intervall) and therefore I got 0,1,2,3,4 at an interval of 1 second and 0,2,4,6,.. at an interval of 0,5 seconds.
So the Counter got incremented but was not saved into the fit file.
Any tips to solve this?
  • hi,

    you cannot write faster than one sec. you find the info in the docu,
    https://developer.garmin.com/downloads/connect-iq/monkey-c/doc/Toybox/FitContributor.html


    MESG_TYPE_RECORD = 20Mesg Type for Record Messages Depending on device recording type written once a second or when new data is available (Smart Recording). Never written faster than once a second. Used for instantaneous values (eg. Current Speed)

  • There are two recording modes on garmin watches. Some have one, some have both.

    1 second and 'Smart". "Smart" records only when it needs to (which is never more often than once a second, but can be every 5+ seconds).

    So the fastest the .fit can be written is once a second.

    When you do the .setData(value), all you're doing is setting the value for the next write of the data type you specified (record, lap, or session), and with the 500ms timer, you change it twice before a write occur. (with 1 sec recording. You could be changing it more times with "smart" before it's written)

    In the Api doc it says this:

    MESG_TYPE_RECORD = 20
    Mesg Type for Record Messages Depending on device recording type written once a second or when new data is available (Smart Recording). Never written faster than once a second. Used for instantaneous values (eg. Current Speed)
  • Thank you for the fast answer!


    So the fastest the .fit can be written is once a second.


    But it should be possible to save multiple values (accleration data 5x in a second) in a variable and then save it to a fit file concenating them (or as a String) ?
  • The problem is that you cannot write strings within a record message (this is also in the docu).
    The solution would be to combine all 5 accelerometer data within one double or long, in a way that you are able to recover afterwards each data. A long has 64 bits, you can some how use 12 bits for each data. Maybe feasible, but not easy to handle. You have to get the longs out if the fit file and then decode each data.
    I considered doing this, but I felt too lazy..... 😁
  • Former Member
    Former Member over 8 years ago
    The FitContributor module supports storing array type values to the record message. You can use any of the supported data types (e.g. uint16), and set the count parameter to specify how many values are in the record (e.g. 5).
  • Wow, I didn't know that!

    Cool info, thanks!