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

Update Steps on Screen Wake

ANSWERED

I want to have to steps update in my clockface constantly, like every second or so. It currently refreshes on screen-wake or when I go back to the clock face from another app, but there is a noticeable delay. 

 

This is the code I was using to have the steps update:

 

let txtSteps = document.getElementById("txtSteps");

function updateSteps() {
  let steps = (txtSteps.text = today.adjusted.steps || 0);
  txtSteps.text = `${steps}`;
}

display.onchange = () => updateSteps();
updateSteps();

display.onchange = function() {if (display.on) {
updateSteps();
} }

 

 

Any suggestions?

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

I finally figured out how to put it in my ontick() handler. For those curious, here is the code I used:

let txtSteps = document.getElementById("txtSteps");
clock.granularity = "seconds";
clock.addEventListener("tick", (evt) => {
  let steps = (txtSteps.text = today.adjusted.steps || 0);
  txtSteps.text = `Steps: ${steps}`; 
});

 

View best answer in original post

Best Answer
0 Votes
6 REPLIES 6

Do it in your ontick() handler.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

@Gondwana wrote:

Do it in your ontick() handler.


Thank you so much. Would you mind giving me the code fully written out? I am not a great programmer, so I am not quite sure how to do so.

Best Answer
0 Votes

I do it in a very similar way as you originally posted, and it works fine for me! 🤷‍:male_sign:

Best Answer
0 Votes

@Tnoff wrote:

I do it in a very similar way as you originally posted, and it works fine for me! 🤷‍


The code in my original post does work fine, but as mentioned before, there is a noticeable delay of the steps updating. What code are you using?

Best Answer
0 Votes

I have been fiddling around on the Fitbit Studio, but I have had no luck with being able to update the steps constantly. I was wondering if anyone else has any suggestions. Thanks in advance.

Best Answer
0 Votes

I finally figured out how to put it in my ontick() handler. For those curious, here is the code I used:

let txtSteps = document.getElementById("txtSteps");
clock.granularity = "seconds";
clock.addEventListener("tick", (evt) => {
  let steps = (txtSteps.text = today.adjusted.steps || 0);
  txtSteps.text = `Steps: ${steps}`; 
});

 

Best Answer
0 Votes