From 8e0335b19ad84c50603de2c0c17c9e1856744b28 Mon Sep 17 00:00:00 2001 From: Scott Leibrand Date: Wed, 8 Jan 2020 21:38:21 -0800 Subject: [PATCH] first attempt at non-decaying floating_carbs behavior Conflicts: lib/determine-basal/determine-basal.js --- lib/determine-basal/determine-basal.js | 9 +++++++-- lib/profile/index.js | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/determine-basal/determine-basal.js b/lib/determine-basal/determine-basal.js index dded5e57f..034910024 100644 --- a/lib/determine-basal/determine-basal.js +++ b/lib/determine-basal/determine-basal.js @@ -545,10 +545,15 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ // avoid divide by zero cid = 0; } else { - cid = Math.min(remainingCATime*60/5/2,Math.max(0, meal_data.mealCOB * csf / ci )); + if (profile.floating_carbs === true) { + // with floating_carbs preference set, use all carbs, not just COB + cid = Math.min(remainingCATime*60/5/2,Math.max(0, meal_data.carbs * csf / ci )); + } else { + cid = Math.min(remainingCATime*60/5/2,Math.max(0, meal_data.mealCOB * csf / ci )); + } } // duration (hours) = duration (5m) * 5 / 60 * 2 (to account for linear decay) - console.error("Carb Impact:",ci,"mg/dL per 5m; CI Duration:",round(cid*5/60*2,1),"hours; remaining CI (",remainingCATime," peak):",round(remainingCIpeak,1),"mg/dL per 5m"); + console.error("Carb Impact:",ci,"mg/dL per 5m; CI Duration:",round(cid*5/60*2,1),"hours; remaining CI (",remainingCATime/2,"h peak):",round(remainingCIpeak,1),"mg/dL per 5m"); var minIOBPredBG = 999; var minCOBPredBG = 999; diff --git a/lib/profile/index.js b/lib/profile/index.js index 00ba074ca..aafd80342 100644 --- a/lib/profile/index.js +++ b/lib/profile/index.js @@ -32,6 +32,7 @@ function defaults ( ) { , unsuspend_if_no_temp: false // if true, pump will un-suspend after a zero temp finishes , bolussnooze_dia_divisor: 2 // bolus snooze decays after 1/2 of DIA , min_5m_carbimpact: 8 // mg/dL per 5m (8 mg/dL/5m corresponds to 24g/hr at a CSF of 4 mg/dL/g (x/5*60/4)) + , floating_carbs: false // if true, use all entered carbs for predBGs: don't decay them as COB , autotune_isf_adjustmentFraction: 1.0 // keep autotune ISF closer to pump ISF via a weighted average of fullNewISF and pumpISF. 1.0 allows full adjustment, 0 is no adjustment from pump ISF. , remainingCarbsFraction: 1.0 // fraction of carbs we'll assume will absorb over 4h if we don't yet see carb absorption , remainingCarbsCap: 90 // max carbs we'll assume will absorb over 4h if we don't yet see carb absorption