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?
Answered! Go to the Best Answer.
Best AnswerI 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
@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 AnswerI do it in a very similar way as you originally posted, and it works fine for me! 🤷:male_sign:
Best Answer
@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 AnswerI 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 AnswerI 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