diff --git a/lib/autotune/index.js b/lib/autotune/index.js index 5b165c919..1609ade0f 100644 --- a/lib/autotune/index.js +++ b/lib/autotune/index.js @@ -421,7 +421,7 @@ function tuneAllTheThings (inputs) { } //else { console.error("newCR",newCR,"is close enough to",pumpCarbRatio); } } // only adjust by 20% - var newCR = ( 0.8 * carbRatio ) + ( 0.2 * fullNewCR ); + var newCR = ( 0.6 * carbRatio ) + ( 0.4 * fullNewCR ); // safety cap newCR if (typeof(pumpCarbRatio) !== 'undefined') { if (newCR > maxCR) { diff --git a/lib/determine-basal/determine-basal.js b/lib/determine-basal/determine-basal.js index 034910024..368244a7b 100644 --- a/lib/determine-basal/determine-basal.js +++ b/lib/determine-basal/determine-basal.js @@ -617,11 +617,17 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ } UAMpredBG = UAMpredBGs[UAMpredBGs.length-1] + predBGI + Math.min(0, predDev) + predUCI; //console.error(predBGI, predCI, predUCI); - // truncate all BG predictions at 4 hours - if ( IOBpredBGs.length < 48) { IOBpredBGs.push(IOBpredBG); } - if ( COBpredBGs.length < 48) { COBpredBGs.push(COBpredBG); } - if ( UAMpredBGs.length < 48) { UAMpredBGs.push(UAMpredBG); } - if ( ZTpredBGs.length < 48) { ZTpredBGs.push(ZTpredBG); } + // truncate all BG predictions at lookahead_int hours in 5min segments + + if (typeof profile.lookahead_5mins === 'undefined') { + var lookahead_int = 48; } + else if (profile.lookahead_5mins) { + var lookahead_int = Math.max(profile.lookahead_5mins, 27); } + + if ( IOBpredBGs.length < lookahead_int) { IOBpredBGs.push(IOBpredBG); } + if ( COBpredBGs.length < lookahead_int) { COBpredBGs.push(COBpredBG); } + if ( UAMpredBGs.length < lookahead_int) { UAMpredBGs.push(UAMpredBG); } + if ( ZTpredBGs.length < lookahead_int) { ZTpredBGs.push(ZTpredBG); } // calculate minGuardBGs without a wait from COB, UAM, IOB predBGs if ( COBpredBG < minCOBGuardBG ) { minCOBGuardBG = round(COBpredBG); } if ( UAMpredBG < minUAMGuardBG ) { minUAMGuardBG = round(UAMpredBG); } diff --git a/lib/profile/index.js b/lib/profile/index.js index aafd80342..8aded3742 100644 --- a/lib/profile/index.js +++ b/lib/profile/index.js @@ -69,6 +69,7 @@ function defaults ( ) { // TODO: make maxRaw a preference here usable by oref0-raw in myopenaps-cgm-loop //, maxRaw: 200 // highest raw/noisy CGM value considered safe to use for looping , calc_glucose_noise: false + , lookahead_5mins: 48 // prediction truncation in hours x 12 }; } @@ -92,6 +93,7 @@ function displayedDefaults () { profile.enableUAM = allDefaults.enableUAM; profile.curve = allDefaults.curve; profile.offline_hotspot = allDefaults.offline_hotspot; + profile.lookahead_5mins = allDefaults.lookahead_5mins; console.error(profile); return profile