Skip to content

Repository files navigation

Battery Tracker

A Connect IQ widget for Garmin Instinct 2/3 watches that logs battery level in the background and shows drain history, rate, time-remaining, and a drain breakdown by inferred state. Fills the gap left by Garmin's Battery Manager, which isn't available on the Instinct series.

Install from the Connect IQ Store

Features

  • Glance: current %, drain rate, estimated time remaining
  • 3-day / long graphs: battery level history (sampled every 30 min, 30 days retained). The long graph's window is a setting — 14 days ("2 WEEKS") or 30 days ("1 MONTH"), edited in Garmin Connect Mobile; storage always keeps 30 days regardless.
  • Since charge: graph + elapsed time, total drain, and average rate since the last charge
  • Daily usage: total battery drained on each of the last 7 days (drain spanning local midnight is split proportionally)
  • Drain by state: Connect IQ exposes no per-feature power data, so drain is attributed to inferred states instead — sleep (profile sleep window), active (activity timer or step delta), idle, charging. Resets on full charge. Scroll with UP/DOWN.
  • Solar (solar models): live harvesting intensity on the main page ("sun 45%"), plus estimated battery gained since the last charge ("Sun est") on the drain page. The gain is an estimate derived from Garmin's published solar specs — Connect IQ exposes intensity only, no real energy data.

Architecture

File Role
source/BatteryApp.mc AppBase: registers the background event, wires views
source/BatteryService.mc Background service: samples battery every 30 min
source/BatteryHistory.mc Chunked ring buffer in Storage + glance summary
source/BatteryStates.mc State inference + per-state drain accumulators
source/BatteryGlanceView.mc Glance (reads only the summary key)
source/BatteryWidgetView.mc Paged full UI, graph renderer, rate fits
source/DemoSeed.mc Demo-build only: seeds fake history for testing
resources/settings/ App settings (long-graph window) edited in Garmin Connect

Constraints that shaped the design:

  • Glance + background share a ~32KB memory budget on Instinct, so history is split into 15 Storage chunks (96 samples each — the background loads one, the glance loads none) and the glance renders from a small precomputed summary.
  • Instinct 2 (API 3.4) predates WatchUi.getSubscreen, so the subscreen circle bounds are hardcoded from the device profiles; the semi-octagon display's cut corners constrain where text can go.

Building

Requires the Connect IQ SDK (device files + simulator fonts downloaded — fonts matter, the simulator segfaults without them) and a developer key:

openssl genrsa -out developer_key.pem 4096
openssl pkcs8 -topk8 -inform PEM -outform DER -in developer_key.pem \
    -out developer_key.der -nocrypt

Release build:

monkeyc -d instinct2 -f monkey.jungle -y developer_key.der -o bin/garmin-battery.prg

Sideload: plug the watch in via USB and copy the .prg to /GARMIN/APPS/.

Testing in the simulator

The demo variant seeds a month of fake history, skips the glance, and auto-advances through every page and scroll position so the UI can be verified (or screenshotted) without button input:

monkeyc -d instinct2 -f demo.jungle -y developer_key.der -o bin/demo.prg
connectiq          # launch the simulator
monkeydo bin/demo.prg instinct2

Demo-only code is annotated (:demo), release-only code (:prod); each jungle excludes the other's annotation.

Supported devices

Instinct 2 / 2S / 2X, Instinct 3 Solar 45mm, Instinct 3 AMOLED 45/50mm.

License

MIT © Rubens Farias

About

Battery history & drain tracker widget for Garmin Instinct (Connect IQ)

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages