01-05-2021 01:19 - edited 01-05-2021 01:20
01-05-2021 01:19 - edited 01-05-2021 01:20
Hi all
New to posting and coding watch faces for the Versa but being in the UK and in and out of lock down (not being able to perform my photography job) I thought I'd give it a go!
I've managed to get one up and running however, I noticed it's draining the battery pretty quickly so assume it could be down to how much I'm calling things.
I have clock.granularity = "seconds"; which seems to be the accepted normal so I'm not thinking it's this. However I realised that I'm calling for Active Zone Minutes every millisecond (a little excessive) so is there an accepted figure for this please or a FitBit standard? Maybe 60000 (1 minute) or something similar?
function refresh_myAzm() {
myAzm.text = today.adjusted.activeZoneMinutes.total
};
setInterval(refresh_myAzm, 1);
Thanks for any help or pointing in the right direction.
01-05-2021 03:53
01-05-2021 03:53
I can empathise with the lockdown woes, I'm in Devon. Hang in there!
Rather than using setInterval, use the clock tick event. Interval runs even when the display is off, tick fires only when the display is on. This saves significant battery.
You can set your clock tick to minutes if you aren't displaying seconds on screen. That will conserve more power.
01-05-2021 04:29 - edited 01-05-2021 04:43
01-05-2021 04:29 - edited 01-05-2021 04:43
Hi @JonFitbit
Thank you for the answer and hope lockdown 3 is ok for you so far! I think we're all frustratingly used to it now 🙂
Thanks, I'm not displaying seconds so have changed this to minutes now. I had originally changed it as did start with seconds on the display.
Also, can I have multiple tick events or do I just add the azm code into the existing clock.tick please? I tried adding the refresh part of the azm code but it stopped showing the azm at all so reverted back.
This is my current azm code.
//AZM
import { goals, today } from "user-activity";
console.log(`${goals.activeZoneMinutes.total} activeZoneMinutes Goal`);
goals.addEventListener("reachgoal", (evt) => {
if (today.adjusted.activeZoneMinutes.total >= goals.activeZoneMinutes.total)
{
// AZM Goal has been met
}
});
console.log(`${today.local.activeZoneMinutes.fatBurn}`);
console.log(`${today.local.activeZoneMinutes.cardio}`);
console.log(`${today.local.activeZoneMinutes.peak}`);
console.log(`${today.adjusted.activeZoneMinutes.total}`);
let myAzm = document.getElementById("myAzm")
//REFRESH AZM
function refresh_myAzm() {
myAzm.text = today.adjusted.activeZoneMinutes.total
};
setInterval(refresh_myAzm, 1);
Apologies for the questions, I've tried following the docs but I seem to be going round in circles as always with code.
**EDIT
I've added myAzm.text = today.adjusted.activeZoneMinutes.total;
to
function updateActivity() {
stepsLabel.text = today.adjusted.steps;
So it pulls the data when screen comes on?!
01-05-2021 05:27
01-05-2021 05:27
import clock from "clock";
import { goals, today } from "user-activity";
clock.granularity = "minutes";
clock.ontick = (evt) => {
myAzm.text = today.adjusted.activeZoneMinutes.total || 0;
};
01-05-2021 08:50
01-05-2021 08:50
Thanks @JonFitbit
For some reason that wouldn't work so I've stuck with adding to updateActivity which seems to work. 🙂
Cheers again
01-05-2021 12:10
01-05-2021 12:10
AZM (and calories) only seems to be updated at the start of every new minute, so if you want to be really efficient, just check it then.
01-06-2021 00:20
01-06-2021 00:20
Thank you @Gondwana, appreciate your response and the info.
Mark. 🙂