Should I be concerned about battery life in my DataField?

I've recently released a DataField - it doesn't do anything particularly unusual, just grabs some data from the available activity info and renders it to the screen. However, for the last few days I've observed a sharp decline in the battery life of my fenix 5X watch - so much so that I got in touch with support today about getting it repaired (losing 10% of the battery in a little over an hour). Suffice to say that a repair was eye-wateringly expensive, so I decided to at least try a few things first, starting with turning my watch off and on again... which fixed it.

Anyway, the experience made me wonder if my DataField was somehow the cause of the battery drain, and that rebooting the watch told it to pack up it's screen rendering brush and go home. Could be that they're absolutely unrelated but I wanted to check with more experienced Monkey C devs whether I'm being a good citizen in my DataField with respect to battery life. Here are the headlines of what I'm doing:

  • In the compute method I do my calculations and save output to class variables.
  • I hook into most of the activity start/stop/lap handlers etc. just to set a few variables that get used in the compute method.
  • I hook into onShow and onHide to set a variable named "doUpdates" to false when the field is hidden.
  • The first line of my update method is: if (doUpdates == false) { return; }
  • If the above line doesn't short-circuit the method, I proceed to rendering. I do a certain amount of positional calculation in there - as little as I can, and I cache things like the icons I've loaded into memory so that I'm not continuously instantiating objects and pulling resources from disk.
  • I render the face of my DataField using direct calls to dc.drawText, dc.drawBitmap and dc.fillRectangle etc. Essentially I draw the whole screen on every cycle, starting with a background rectangle, then lines, labels, icons and so on. It's not a particularly complicated layout by any measure.

Is there anything about what I've said there that raises alarms about battery usage? I'm assuming that my DataField can't tick along in the background calling the compute method when I have no activity running?

Parents
  • First thing would be to remove the DF from the activity and see what the battery drain is then.  Things like GPS can consume a whole lot of battery.

    BTW, I don't think onHide() is even called in a DF.  And you want to update the screen on every call to onUpdate().

Reply
  • First thing would be to remove the DF from the activity and see what the battery drain is then.  Things like GPS can consume a whole lot of battery.

    BTW, I don't think onHide() is even called in a DF.  And you want to update the screen on every call to onUpdate().

Children