I'm considering a minor change to my computationally demanding data fields to improve battery life and responsiveness.
When running three of my data fields, the time between calls to compute() can grow to a few seconds.
I'm considering adding logic at the start of compute() that only runs this function every 3rd time it enters the function. Since onUpdate() is also called, asynchronously every second, the compute() gate would also turn on/off a Boolean so that onUpdate() also ran every 3rd time, after compute() ran.
Thinking this would still provide me, an ultra distance cyclists, with updates frequently enough for my needs. And reduce the compute burden on the device, increasing battery life and impacting responsiveness less (especially when also running a turn-by-turn course).
Any reason why doing this would cause issues with the accuracy of the underlying device metrics?
function compute(info) {
if (loopNum >= 3) { doUpdate = true; loopNum = 1; } else { doUpdate = false; loopNum++; return; }
function onUpdate(dc) {
if (doUpdate == false) { return; }
Well it doesn't work to run onUpdate() every three seconds, because something blanks the screen! So compute() can be run every 3rd time, but onUpdate() must run every time to prevent the screen flash/blanking.