Skip to content

Latest commit

 

History

History
63 lines (50 loc) · 4.63 KB

File metadata and controls

63 lines (50 loc) · 4.63 KB

AAPS 1-min CGM patches

Timing fixes for AndroidAPS on a 1-minute CGM source (e.g. Libre 2 via Juggluco). Large parts of the AAPS loop/delivery timing were built on 5-min CGM assumptions; on a 1-min source with a short SMBInterval those assumptions cost you half the loop runs and ~45s of latency.

None of these patches change dosing MATH — insulin amounts stay governed by smb_delivery_ratio, iobTH and maxBolus. They only change when the loop runs and whether an already-approved SMB survives its timing checks.

⚠️ Custom DIY fork changes — test carefully, use at your own risk. Authored and live-tested on AAPS 3.4.2.3 + autoISF 3.2.0 (Medtrum pump, Libre 2 / Juggluco 1-min). Only useful on a 1-min CGM source; on 5-min CGM the stock timing is fine.

Core series (0032–0039)

# One line Effect
0032 Loop trigger: any completed calculation with a fresh un-looped BG invokes the loop. Before: the DB write of a just-delivered SMB cancelled the NEXT reading's calculation and the replacement run was rejected by a cause filter. No more silently swallowed cycles → SMBs no longer locked to ~2min.
0033 Calculation order: dosing chain (LoadBG → IOB/COB → InvokeLoop) runs BEFORE the graph-prep workers (~27s/cycle on 1-min data). BG→loop latency ~40-45s → ~10-20s.
0034 SMB enact gates: LoopPlugin ×2 + CommandSMBBolus get the determine gate's 6s tolerance. A determine-approved SMB is no longer silently zeroed in the 54-60s window.
0035 Pump busy: an aborted loop invocation no longer consumes the BG reading — the next calculation retries it. No lost readings while the pump is enacting (matters most for pumps with long connect/enact — pods, Combo).
0036 MEDTRUM ONLY — skip on other pumps. Post-bolus sequence sleep 2000→750ms. Faster post-bolus recovery on Medtrum.
0037 Bucketing: binary search instead of linear scans in autosens bucketing (~0.8-1.6M comparisons/min on 1-min data) + progress-event throttling. Pure CPU/battery speedup, no behavior change.
0038 SMB interval gates: all four smbinterval age checks get 15s tolerance (gate 45s instead of 54s) — the bolus record lands ~10s AFTER the decision, so the next 60s cycle always saw ~50s < 54s and waited. SMBInterval=1 actually delivers every minute under sustained demand (live-verified: 58-69s spacing).
0039 Cleanup: stale comments, inactive openAPS-SMB gate aligned. No behavior change.

Minimum set for the 2-min-cadence fix: 0032 + 0038. Recommended: 0032, 0033, 0034, 0035, 0037, 0038, 0039 (+0036 on Medtrum).

Optional: automation layer (0042 + 0046 + 0047 — apply all three together)

# One line Effect
0042 Automation trigger poll 150s → 60s (150s was the 5-min-CGM half-interval). Detection latency only — the per-event 5-min repeat guard is unchanged. Automations react within ~1min instead of ~2.5min.
0046 @Synchronized-class fix: processActions() runs from two threads (handler refreshLoop + rx io subscriptions); unsynchronized passes could interleave their action sequences and stomp each other's settings. Automation passes are serialized.
0047 Follow-up to 0046: serialize on a dedicated lock, not the plugin's object monitor (which the overview UI thread also takes to render automation buttons — a multi-action pass froze the UI into an ANR). Same serialization, no UI freeze. Never apply 0046 without 0047.

How to apply

cd <your-AndroidAPS-checkout>   # full clone! (git fetch --unshallow if needed)
git am -3 00*.patch          # or cherry-pick individual files
# on conflict: git am --show-current-patch, resolve, git add -A, git am --continue

Version notes:

  • The series is generated against the CLEAN Tobias base bc0cce207e (= branch 3.4.2.1+aisf3.2.0 of https://github.com/T-o-b-i-a-s/AndroidAPS) and applies there with a plain git am (verified). On other 3.4.x+aisf3.x states use git am -3.
  • v2 note: the first upload was generated against my private fork (patches carried context from unpublished commits — 0037 failed to apply, thanks Randall for the report). This regenerated series is self-contained.
  • 0038 patches DetermineBasalAutoISF — it assumes the autoISF fork. On plain AAPS the same one-line tolerance goes into DetermineBasalSMB instead.
  • AAPS older than ~3.3 (JavaScript determine-basal era): the patches will NOT fit.

Verifying success

After flashing, watch the Treatments tab under sustained demand (insulinReq clearly positive over several minutes): SMB spacing should be ~60s instead of ~120s. It stays fully demand-driven — no demand, no SMBs.