Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

250 step counter on watchface

ANSWERED

Ok, first of all, I know this has been touched on before, but for an amateur coder like me, I understand 0% of what anyone is saying. I just want to be able to see how many steps i've taken this hour without having to swipe up on my versa to get to the stats page. I really would like a simple explanation of what code to put to make this happen. If that's possible, I would be very happy.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

There is an SDK feature request to support implementing reminders to move clock faces: https://community.fitbit.com/t5/Feature-Suggestions/Enable-developing-clock-faces-that-support-Remin...

You might want to vote for it.

 

For the hourly problem when the watch is not running, there are 2 solutions that I'm aware of:

  1. I use setInterval to update various things every 5 seconds.  This works pretty well for the steps as well as keeping the time relatively current on the display.  The latter avoids a problem I've seen where when you first turn on the display the time is old for a fraction of a second until the next clock tick.  I found that annoying so I update it every 5 seconds (along with handling the hourly step counts).
  2. Some use setTimer and set it to run at the next hour.  This should be a little more efficient than using setInterval but I get 5 days on a charge using setInterval so I've stayed with that.

Hope this helps,

John

View best answer in original post

Best Answer
9 REPLIES 9

If you are just looking for a clock face that shows this, check out Move It!

 

John

Best Answer
0 Votes

Thank you for replying so fast, but that’s not exactly what I’m asking for. What I was trying to ask for is the actual code used to implement the 250 step counter into my own watchface so 1: I can finally have the 250 step counter on my watch face and 2: learn what the code actually means so I don’t have to ask for every single peice of code I want to implement. 

Also, is there any way to view the code of another watch face? If there was, that’s would be really cool. 

Best Answer
0 Votes

There is a GitHub repository with sample code for some apps at https://github.com/Fitbit/ossapps.

But I don't know if there are any samples for hourly step counts.  

 

I suggest you go through a couple of those, as well as the generated sample code, to make sure you understand the overall process and to get familiar with code for other statistics.  What information do you need other than what is included in the various threads in this forum?

 

The face i mentioned does have code that runs in the ontick event as well as a setInterval handler.  It uses an array to hold the step counts for each hour that is displayed.

 

You will probably get better answers if you post specific questions about code that you have already tried.

 

John

Best Answer
0 Votes

This question was discussed here: https://community.fitbit.com/t5/SDK-Development/Current-hour-s-steps/td-p/2685569. Basically, you need to save the total daily steps at the beginning of each hour. Then, when you want to display the current hour's steps, you get the current total daily steps at the time, and subtract the number you saved at the beginning of the hour. I think there are code examples in the above link. Too bad you can't just request the current hour's steps from the API :).

Best Answer
0 Votes

The biggest problem I have found is that if the watch is 'not running' (i.e. the user is running another app) at the top of the hour then you can't get the exact steps at that point.  You'll only have the last step figure you recorded and the step figure when your clock runs again and from those you'll need to estimate the top of hour figure.

I agree that it would be nice to be able to get the 'steps in hour' from the API.

 

Best Answer
0 Votes

There is an SDK feature request to support implementing reminders to move clock faces: https://community.fitbit.com/t5/Feature-Suggestions/Enable-developing-clock-faces-that-support-Remin...

You might want to vote for it.

 

For the hourly problem when the watch is not running, there are 2 solutions that I'm aware of:

  1. I use setInterval to update various things every 5 seconds.  This works pretty well for the steps as well as keeping the time relatively current on the display.  The latter avoids a problem I've seen where when you first turn on the display the time is old for a fraction of a second until the next clock tick.  I found that annoying so I update it every 5 seconds (along with handling the hourly step counts).
  2. Some use setTimer and set it to run at the next hour.  This should be a little more efficient than using setInterval but I get 5 days on a charge using setInterval so I've stayed with that.

Hope this helps,

John

Best Answer

Hi,

 

I realized some clockfaces with hourly step counter but the problem is already mentioned. You can't store the number of steps correctly for calculating the hourly steps if another app is running during the full hour change.

 

So you have to be aware that if you realize this feature that it's not always working correctly because of the technical limitations...

 

Regards

Capitano

Best Answer
0 Votes

Sorry for not answering in a while, but thanks for all who posted. I will try to to work with what you have given me, and will try to figure it out. 

Best Answer

>> I just want to be able to see how many steps i've taken this hour without having to swipe up on my versa to get to the stats page. I really would like a simple explanation of what code to put to make this happen. If that's possible, I would be very happy.

 

I wrote a watch face, ILuvChrono, that does this (pardon the ad). I use a combination of the clock tick function and the setinterval function. Whenever the tick fires or the interval triggers, the current steps and time are recorded. Step difference between the previous record and the current are pro-rated to the hours that have passed.

 

For example, if the last record was at 20 till 5 and the next is at 5 minutes past five, a 250 step increase would attribute 200 additional steps to the 4 hour and 50 steps to the five hour leaving 200 more steps. Granted this is an approximation, but it does work very well, especially if the watch face is actually available to run on the hour.

 

Every time the setInterval function fires, the amount of time remaining in the hour is used to set the time till the next setInterval fires:

 

clearTimeout(stepTimeout)
stepTimeout = setTimeout(processSteps, (msPerHour - currMsPastTheHour) )

 

ILuvChrono animated gif file

 

App gallery is at https://gallery.fitbit.com/details/bda6f514-3946-49ba-a4ed-75e8470ab034

Best Answer
0 Votes