Calculating the Number of Steps for Fenix 3

Former Member
Former Member
I am seekin to calculate the total number of steps to enhance the DISPLAYS of indoor running.

Since I did not immediately found other data, I calculated it using the averageCadence as follows

TotSteps= 2 * elapsedTime.toFloat() / 60000 * avaerageCadence.toFloat;

(1) In the simulation environment everything works fine.

(2) When installed on the fenix the total number of steps - after coming to an halt without switching any button - fluctuates,e.g., between 170 and 180.

Which is nearly correct. However it bothers me that the counter increases AND decreases while being in the REST. So I thought that some wired rounding could be the cause. I modified the code to

var MaxStepsF=0.00;
var CurrStepsF=0.00;
var MaxStepsL=0;
var MaxStepsO=0;

CurrStepsF = AI.elapsedTime.toFloat()/60000*AI.averageCadence.toFloat();
if (CurrStepsF.toFloat() > MaxStepsF) {
MaxStepsF=CurrStepsF.toFloat();
MaxStepsO=MaxStepsL;
MaxStepsL=CurrStepsF.toLong();
}

with subsequent display of MaxStepsL;

Unfortunately, this is not the solution. The total number of steps MaxStepsL fluctuates further, and I am starting not to see the wood of the trees.

Any help ??
  • In ActivityMonitor.getInfo(), you'll find "steps". Why not just use that?

    You can use that, and track the number of steps taken during an activity, and do things like not counting steps while paused if you want.
  • you can also just download my data field here: https://apps.garmin.com/en-US/apps/2316ce8d-bd99-430b-b7ac-9f8490f2e912
    it does what you want and more...

    just set it as one of your data fields and off you go...

    source code available via the same link, so you can strip functionality if needed :)
  • Peter - just curious. With your public code, does it use the same UUID as your app in the store? I'm thinking that may be an issue if someone tries to installs your app and one that they build with your code. Is there some way to make sure they use their own UUID? (the ID in the manifest.xml)
  • To be honest I didn't think about that but (by coincidence) it's another manifest for the store data field as I re-created the tutorial one step by step to be able to upload it on a per tutorial chapter basis to my website.

    The good student following the tutorial will do it step by step and as such have their own uuid.

    But if people download the zip file and (two or more people) start from there for their own project that they want to redistribute what you point out could indeed be an issue...
    but this is an issue for anyone spreading code... do you have a suggestion?
  • What if in the public code, you put a bogus UUID in the manifest, like "Generate your own UUID for this". (and maybe note this in your main .mc) If someone misses doing this, there will be a compile error, so they'll see it.

    Even if it's just two users, and they keep an original UUID, if they both put it in the store, a conflict could arise for users. (if they want to compare the two versions)
  • it's an option, but I don't want to scare people too much in my "hello world"-type example with a project that doesn't compile out of the box... The samples shipped together with the connect iq sdk have the same issue and likely these samples will be used more as a starting project than my tutorial ever will be. :)

    I wonder whether the Garmin Store Uploader can not check whether the uuid is already in use, seems like a better place to handle the potential conflict to me. :)
  • IIRC, In the past, there was something that garmin mentioned about checking for dup UUIDs in the store, but there were cases where people used different builds of the same app for each target device (they would have a different version of the same app in the store for each device, but all with the same UUID), and it wasn't done.

    The samples have the same issue, but if you use the templates in Eclipse to start (file>new>CIQ Project), the project get's a unique UUID.

    I guess that's why I first asked how you managed the UUID for public source, as I didn't know of an easy way to do it.
  • Former Member
    Former Member over 8 years ago
    In ActivityMonitor.getInfo(), you'll find "steps". Why not just use that?

    You can use that, and track the number of steps taken during an activity, and do things like not counting steps while paused if you want.


    As this is a simple formula,

    I thought this would be the easiest way to calculate the number of steps with - when the cadence is calculated correctly / unrounded - no need to consider pauses and so on.


    And since I wanted to start with simple routines before appraching more complicated ones ....

    However, even this simple thing got complicated and I introduced corrective measures as stated by the lines above. And now I wonder why the code listed above does not guarantee a monotonically increasing number of steps ...
  • Former Member
    Former Member over 8 years ago
    you can also just download my data field here: https://apps.garmin.com/en-US/apps/2316ce8d-bd99-430b-b7ac-9f8490f2e912
    it does what you want and more...

    just set it as one of your data fields and off you go...

    source code available via the same link, so you can strip functionality if needed :)


    I am just starting and it was not intended to become a project, just a quick hack to see if it works. In the data field referenced above I was puzzeled by four identical labels (STEPS) on the second screen, so I did not get into the details, but now it seems that I will / must.

    Thank you.
  • What I wanted to show there was that you could use it in combination with other fields in a 4-field layout, but I can see where this pic can be confusing. So I'll change the second pic. :)