04-22-2021 06:15 - edited 04-30-2021 07:06
04-22-2021 06:15 - edited 04-30-2021 07:06
I want to have to battery level update in my clockface constantly, like every minute or so. It currently refreshes only when I go back to the clock face from another app, and there is a noticeable delay.
This is the code I have:
const batteryHandle = document.getElementById("batteryLabel");
batteryHandle.text = `${battery.chargeLevel} `;
Any suggestions?
Answered! Go to the Best Answer.
04-30-2021 07:46
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
04-30-2021 07:46
Yeah, something like
import clock from "clock";
import { battery } from "power";
const batteryHandle = document.getElementById("batteryLabel");
clock.granularity = "minutes"; // seconds, minutes, or hours
clock.addEventListener("tick", (evt) => {
// tick every minute
batteryHandle.text = `${battery.chargeLevel} `;
});
Best Answer04-30-2021 06:34
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
04-30-2021 06:34
Move this inside your clock tick event.
batteryHandle.text = `${battery.chargeLevel}`;
Best Answer04-30-2021 07:06
04-30-2021 07:06
I am slightly confused by what you mean. Would you mind being a bit more specific?
Best Answer04-30-2021 07:46
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
04-30-2021 07:46
Yeah, something like
import clock from "clock";
import { battery } from "power";
const batteryHandle = document.getElementById("batteryLabel");
clock.granularity = "minutes"; // seconds, minutes, or hours
clock.addEventListener("tick", (evt) => {
// tick every minute
batteryHandle.text = `${battery.chargeLevel} `;
});
Best Answer04-30-2021 08:07 - edited 04-30-2021 08:18
04-30-2021 08:07 - edited 04-30-2021 08:18
Thank you so much. Your solution worked!