01-13-2022 23:19 - edited 01-13-2022 23:21
01-13-2022 23:19 - edited 01-13-2022 23:21
The source code I've developed on GitHub
The code works beautifully in the simulator but naturally the real thing has a couple pretty serious problems that maybe you could help me with. The two major issues are:
1 ) This watch face eats the battery like crazy. I went to sleep with it at 50% and woke up with it at 14% power. From what I understand, this is because too much code/computing is being run on the device itself. I'm not 100% sure on how messaging works and I'm sure that's where it falls short as well. I'm sure there's a sort of programming best practice I'm not following here.
On a tangent to that, I looked at the log and it seems the messaging socket opens and passes info to the device every minute or two, which is probably why it eats up so much power. Is there a way to make it only send an updated message once something in the Nutrition database changes?
2 ) I keep getting a notification on my phone that says, "We were unable to update / install one or more apps. Please try again." This only shows up when I have my watch face loaded onto the device/app. I have a feeling it's related to the first issue.
I'm a beginner at javascript. A lot of this was copied and pasted and altered, if that helps.
EDIT: I made it to imitate, almost exactly, the aesthetics of the default Spectrum watch face features.
01-13-2022 23:42
01-13-2022 23:42
I'll confess that I haven't looked at your source code, but I'd be surprised if it's your comms that are draining the battery. I could be wrong.
A possible culprit is WiFi, which is used for the dev bridge. Disable the dev bridge when you're not devving.
The display is another possibility. If your comms are resulting in the display coming on whenever they happen (eg, .poke), that could be wasteful. But I doubt this is the issue.
01-13-2022 23:54
01-13-2022 23:54
I was under the impression that the dev bridge turned off after a while but I'll give that a shot. I'll report back if that resolved it. Thanks!
01-14-2022 17:15
01-14-2022 17:15
Well I'm pleased to report that battery consumption is MUCH better now. I was under the impression the dev bridge deactivated on its own after a while, now we know!
Now this makes the second issue more clear- when I update something in my food log, I start getting the notification: "We were unable to update / install one or more apps. Please try again." The device doesn't display the proper numbers until I go into my Sense's Developer Menu and click Login again. Once that happens, the log shows "Companion launched by [settingsChanged]" and the proper numbers are updated on the device.
I'm sure there's one line of code or something that solves this. An event listener to trigger the [settingsChanged] operation once something does change?
This feels like a different topic than regarding battery consumption so I can make this a separate thread if necessary?
01-15-2022 09:54