A watch face I built is having some high battery drainage compared to other faces. Is there some way to tell what in the code is draining the battery? Maybe some rough guidelines? i.e. avoid using Storage.setValue()
A watch face I built is having some high battery drainage compared to other faces. Is there some way to tell what in the code is draining the battery? Maybe some rough guidelines? i.e. avoid using Storage.setValue()
Hi,
so basicaly avoid calculating things on onUpdate if not necessary, for exemple the sun event, can be calculated once a day.
(in this case Storage.setValue() can be very useful if not called everytime on onUpdate)
the less calculation is made on onUpdate everytime the less it will consume.
Beside this, keep in mind that watchface from CIQ will always drain more battery than stock one,
and you will always have users who will tell you that your wf drains too much battery.
Another thing maybe, on mine I put a power saving mode which display only time and date and can be turned off either on gesture or with DnD etc.
PS maybe something else:
if you use Background process, it will drain more battery if you use it every 5min
https://forums.garmin.com/developer/connect-iq/f/discussion/272214/reduce-memory-usage
some info here (less memory usage = less battery consumption)
Thanks for the reply. I will give this a try. Do you recommend using OnPartialUpdate?
hi, it is up to your needs but onPartialUpdate drains battery
Also avoid Storage.getValue() in onUpdate. Only do it on start of the watchface for example. Make seconds display with onPartialUpdate optional for the user
Same with Properties.getValue(). Only call it when the watchface starts or in response to onSettingschanged().
loadResource() is something else that should only be called when needed. That hits the file system, is expensive and is why you can't even call it in onPartialUpdate.
For "has" checks, I only do those when an app starts and set a boolean. Checking the boolean is cheaper than doing a "has" all the time..