Odd data replaying fit file in simulator

Former Member
Former Member
I'm interested in creating a data field that will display both heart rate and cadence, with coloured background much like TeunMo's 'heart rate with zone' datafield. I would like both in one field so that I can overcome the three fields limit in the Vivoactive, and only being able to use two ConnectIQ datafields in an activity (why?).

To start exploring, I've taken the sensor example (yes - it's a widget, but I need to start somewhere!) and modified it to show cadence sensor data, and graph it below the existing HR graph.

Seems to work using the simulator data, but when I get the simulator to use a fit file from a spin session that I've done the data seems a bit odd - in that it starts at 180 rpm, drops down to something normal, then goes up again to 188 rpm (no - I don't spin that fast). Viewing the data in Connect shows completely different data.

The code snippet shows I don't do anything difficult with the data - it just gets written out
function onSnsr(sensor_info)
{
var HR = sensor_info.heartRate;
var CD = sensor_info.cadence;
var bucket;
if( sensor_info.heartRate != null && sensor_info.cadence != null)
{
string_HR = HR.toString() + "bpm";
string_CD = CD.toString() + "rpm";

//Add value to graph
CD_graph.addItem(CD);
HR_graph.addItem(HR);

etc....
}


So not sure what's going on with the fit data. How can I 'see' what's in the fit file?

A couple of comments on the development docs:
1. Be useful if the UXguide had the number of data fields, and perhaps their layout, in Appendix A - devices (and details for the edge1000?)
2. More detail on permissions would be useful
3. A list of examples and a description of which features they demonstrate would be handy rather than having to look in each example every time.
  • Former Member
    Former Member over 9 years ago
    I'm interested in creating a data field that will display both heart rate and cadence, with coloured background much like TeunMo's 'heart rate with zone' datafield. I would like both in one field so that I can overcome the three fields limit in the Vivoactive, and only being able to use two ConnectIQ datafields in an activity (why?).

    To start exploring, I've taken the sensor example (yes - it's a widget, but I need to start somewhere!) and modified it to show cadence sensor data, and graph it below the existing HR graph.


    I would recommend you use a data field and use the Activity.Info data instead of the Sensor.Info. The Activity.Info object is available in the Compute function that fires every second and you don't have to do anything to retrieve it.


    Seems to work using the simulator data, but when I get the simulator to use a fit file from a spin session that I've done the data seems a bit odd - in that it starts at 180 rpm, drops down to something normal, then goes up again to 188 rpm (no - I don't spin that fast). Viewing the data in Connect shows completely different data.


    I'm guessing here (and if I'm guessing right, it's probably a bug), but cadence for running used to be measured in rpm in the passed, but nowadays it's measured in steps (which is twice as many). I think the raw fit data might still contain the rpm value and if the simulator does not take the activity profile into account, it won't make a difference between running and cycling cadence and simply double your value. (Just guessing here...)

    A couple of comments on the development docs:
    1. Be useful if the UXguide had the number of data fields, and perhaps their layout, in Appendix A - devices (and details for the edge1000?)


    You can make easily find this out with the simulator. I've created sheets for a couple of devices, which you can use:

    Edge 520:


    Edge 1000:


    Fenix 3:


    Forerunner 230:
  • Former Member
    Former Member over 9 years ago
    Thanks for the rapid answer...

    use the Activity.Info data instead of the Sensor.Info. The Activity.Info object is available in the Compute function that fires every second and you don't have to do anything to retrieve it.


    That sounds great - I was only using the Sensor.info as that was what was used in the sensor example. I can see that Activity.info would be better for a data field. Is there a good datafield example in the SDK?

    I see what you mean regarding the fit data - is there decoder for fit files? I meant to get the widget on my watch for todays spinning but ran out of time!

    The sheets are great - thanks - didn't really think of using the simulator in that way - I'll explore further.
  • I'm guessing here (and if I'm guessing right, it's probably a bug), but cadence for running used to be measured in rpm in the passed, but nowadays it's measured in steps (which is twice as many).


    Actually, it varies based on the type of activity, at least on the vivoactive. I have my own app that records walking, running or hiking (SPORT_*), and for hiking, you have to double the number for cadence to get steps, while for avg and max you have to double the cadence for all three SPORT_* types to get steps.

    I've posted about this before, but if they fix it now, it will mess up my code! :) (just kidding. I'd have to change about 5 lines of code!)
  • I can see that Activity.info would be better for a data field. Is there a good datafield example in the SDK?


    The SimpleDataField example. Compute is called with "info", and "info" is the Activity.info. You're passed the Activity.info when your compute is called.
  • Former Member
    Former Member over 9 years ago
    Thanks Jim,

    The SimpleDataField example. Compute is called with "info", and "info" is the Activity.info. You're passed the Activity.info when your compute is called.


    but I was explicitly looking for something that used DataFiled, rather than SimpleDatafiled to see how the resources may be handled. the Programmers guide says
    In Garmin activities, the user controls the data page layout; specifically, whether it displays one, two, three, or more fields. The Connect IQ data field must handle displaying in all of those layouts, and the developer can use the simulator to test their field in all layouts supported by devices.


    It's that bit I'm missing - as I want to be able to display multiple bits of information in one field, and manipulate the background colour.
  • Former Member
    Former Member over 9 years ago
    It's that bit I'm missing - as I want to be able to display multiple bits of information in one field, and manipulate the background colour.


    That's all in the Complex data field template (what you get when you create a new Data field and choose Complex).
    Make sure you do all your calculations in the compute method and all the screen updating in onUpdate.
    For complex data fields (like my Heart Rate width Zone data field) I always do layout in onLayout, so it only gets calculated once (on device, simulator does onLayout every second).