Widget: Battery Gauge

Former Member
Former Member
Battery Gauge

Battery Gauge Widget v2.1




Widget showing battery history for a selected period. Currently it is a bit limited, since it isn't possible to have a process running in the background storing the battery state continuosly. The way the widget currently works is that every time the widget is started, the battery charge value is read and saved. The value is compared to the previous one, and the graph is updated. Each bar in the graph represents an hour (in week view), so if the widget for instance is started at 12 o'clock and later at 4 o'clock, the values at 12 and 4 are real values. The values at 1, 2 and 3 o'clock are calculated based on the difference between 12 and 4. If one starts the widget at regular intervals, the graph should give a quite good representation of the battery state.

Widget menu (press Start/Enter button)
  • Statistics screen, showing battery drain the last hour, the last day, since a user defined time and since last log reset.
  • Switch the graph scale between 1 month, 2 weeks, 1 week, 4 days and 1 day (Log data is no longer deleted when changing scale).
  • Switch between no graph markers, high/low markers or markers for each step on the x-axis.
  • Switch between black or white background.
  • Reset the log.

Please note:
  • Since each bar represents one hour, there will be no data visible for the first hour after the widget is run the first time. If after several hours no graph is visible, try clearing the log from the widget menu.
  • It is recommended to clear the log after installing a new version.
  • If after clearing the log problems still persist, it may be necessary to manually delete the log file. Instructions in this post: Deleting log file manually


Updates:

Version 2.1 - September 18, 2016
  • Support for Vivoactive HR
  • Fixed layout issues on new Forerunner and Fenix series watches
  • Improved the ability to scroll past the widget in the widget list


Version 1.9b - November 23, 2015
  • Added experimental support for FR230, FR235 and FR630. Please regard this as beta software for the time being.

Version 1.8 - June 24, 2015
  • Updated to Connect IQ v1.1.2.
  • Added support for D2 Bravo.

Version 1.7 - May 27, 2015
  • Improved precision on statistics calculations.
  • Added version number to statistics screen.

Version 1.6.5 - May 17, 2015
  • Fixed a bug regarding 'last hour' and 'last day' statistics.

Version 1.6.2 - May 10, 2015
  • Increased size of graph marker font.

Version 1.6 - May 9, 2015
  • Thanks to Gigios (Vivoactive) andMourk.D (Fenix 3) for beta testing!
  • Added 'Statistics' screen, showing battery drain over various periods.
  • Added experimental Vivoactive support. Please regard this as beta software for the time being.
  • Added ForeAthlete 920XTJ support.
  • Renamed 'Clear Log' to 'Reset Log'
  • Bug fixes.

Version 1.2 - April 28, 2015
  • Added option to select between graph markers.
  • Added 1 month scale option.

Version 1.1 - April 17, 2015
  • Data is no longer cleared when changing scale.
  • When selecting a new scale in the menu, view is immediately returned to graph.
  • Added 2 week scale option.

Version 1.0 - April 13, 2015
  • Added possibility to change graph scale.
  • Added possibility to change background color.
  • Added marker showing highest value of graph.
  • Bug fixes.

Version 0.8 beta - April 08, 2015
  • Forerunner 920XT support - NOTE: Only tested in simulator.
  • Added possibility to delete log file via widget menu.
  • Small tweaks to graph.

Version 0.7 beta - April 07, 2015
  • Bug fixes.
  • Added version number to screen.

Version 0.6 beta - April 07, 2015
  • Initial version.
  • OK, I ugrades through USB cable, the data are there, but 1 month graph is empty, no data. The others are absolutely OK.
  • Former Member
    Former Member over 10 years ago
    Interesting to hear that you can keep the old log, the widget is compatible with old files, so in theory it should work for everyone...

    The reason you don't see any data in the 1 month graph is simply that the old version didn't have that option, so it there is no previous data to show. You should however see the month graph starting to fill up as the days go by.

    -Torstein
  • Aha! Yes, it works, I see a thin line in a 1 month preview. But I thought, that the data are stored in a file and each selection choose only appropriate view, so if I have data for 2 weeks, I thought in 1 month preview I will see a half of graph.
  • Former Member
    Former Member over 10 years ago
    To save space and make the widget as efficient as possible I actually save data for each period separately.
  • Mystery solved. Till now is working perfect thats my today feedback.
    A non serious question:
    Sometimes the settings battery indicator is 1% higher than the app.
    My thought is that garmin rounds the indicator to upper value and your app does the down road.
    E.g. the actual battery level from the watch is reporting 7.48%. Garmin settings shows 8% (to make us fee better) and your battery app 7% (correct round up value).
    Is that correct?
  • Former Member
    Former Member over 10 years ago
    I have seen the same, and after looking into it a bit I think you are right :)

    In the widget i use the 'System.getSystemStats().battery' float value presented by the ConnectIQ API. When displaying the value I simply format it without any decimals, and that rounds the value down. So a value of 16.78% is shown in the widget as 16%, but the Settings screen probably rounds it up to 17%.

    I'll see if I can fix that in the next version som the widget and Settings screen show the same value.
  • I wish i could help more , im just a simple architect engineer (buildings not codes and 'System.getSystemStats().battery' stuff )
    As i have some spare time (in greece now there is not so much of a cuntruction buildings fever) i have more questions
    In a future firmware update (3.30 tha we wait for example) will battery stats remain?
    On a master reset will remain? (my guess is no)
    have a good day :D
  • To save space and make the widget as efficient as possible I actually save data for each period separately.


    now I understand. Thank you! Perfect app! But one more question. If you save data for each period you have more data then if some of them are shared to more graphs. No?
  • Former Member
    Former Member over 10 years ago
    I'll try to explain my reasoning:
    The graph contains 171 vertical bars, so if you use the day period each bar represents about 8 minutes. For the month period however, each bar represents about 4 hours. In an ideal world with unlimited memory and resources, I would just store the whole month's data with an 8 minute resolution. Then I could just pick the values I needed for each display period. But storing one month's data with that amount of detail, would require an array with 5130 values.

    There's a lot I could do to reduce the 5130 values to something more manageable, and keep everything in one array, but that would require more logic and calculations to display the correct graph, which would mean even longer startup times for the widget.

    The way I do it now I use 5 arrays, each with a size of 171 for a total of 855 values, and there is very little logic involved when displaying the graph.
  • Former Member
    Former Member over 10 years ago
    thank you very much TORSTEINVH.
    I can hardly read the graph markers. Can you increase the size? like other widgets (altimeter, temperature ...), at least for the graph values "High and Low".