Merge pull request #2778 from Tornado-Tim/carbs-watch-fix
Carbs Required Fixes
This commit is contained in:
commit
77142afd46
|
@ -108,6 +108,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
|||
private boolean isDisconnected;
|
||||
|
||||
private long carbsSuggestionsSuspendedUntil = 0;
|
||||
private int prevCarbsreq = 0;
|
||||
|
||||
@Nullable private LastRun lastRun = null;
|
||||
|
||||
|
@ -396,7 +397,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
|||
}
|
||||
result.percent = (int) (result.rate / profile.getBasal() * 100);
|
||||
|
||||
// check rate for constrais
|
||||
// check rate for constraints
|
||||
final APSResult resultAfterConstraints = result.newAndClone(injector);
|
||||
resultAfterConstraints.rateConstraint = new Constraint<>(resultAfterConstraints.rate);
|
||||
resultAfterConstraints.rate = constraintChecker.applyBasalConstraints(resultAfterConstraints.rateConstraint, profile).value();
|
||||
|
@ -414,6 +415,10 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
|||
resultAfterConstraints.smb = 0;
|
||||
}
|
||||
|
||||
if (lastRun != null) {
|
||||
prevCarbsreq = lastRun.getConstraintsProcessed().carbsReq;
|
||||
}
|
||||
|
||||
if (lastRun == null) lastRun = new LastRun();
|
||||
lastRun.setRequest(result);
|
||||
lastRun.setConstraintsProcessed(resultAfterConstraints);
|
||||
|
@ -494,12 +499,19 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
|||
mNotificationManager.notify(Constants.notificationID, builder.build());
|
||||
rxBus.send(new EventNewOpenLoopNotification());
|
||||
|
||||
// Send to Wear
|
||||
actionStringHandler.get().handleInitiate("changeRequest");
|
||||
//only send to wear if Native notifications are turned off
|
||||
if (!sp.getBoolean(R.string.key_raise_notifications_as_android_notifications, false)) {
|
||||
// Send to Wear
|
||||
actionStringHandler.get().handleInitiate("changeRequest");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
dismissSuggestion();
|
||||
//If carbs were required previously, but are no longer needed, dismiss notifications
|
||||
if ( prevCarbsreq > 0 ) {
|
||||
dismissSuggestion();
|
||||
rxBus.send(new EventDismissNotification(Notification.CARBS_REQUIRED));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -748,13 +748,16 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
|
||||
if (config.APS && lastRun?.constraintsProcessed != null) {
|
||||
if (lastRun.constraintsProcessed!!.carbsReq > 0) {
|
||||
overview_cob?.text = cobText + " | " + lastRun.constraintsProcessed!!.carbsReq + " " + resourceHelper.gs(R.string.required)
|
||||
//only display carbsreq when carbs havnt been entered recently
|
||||
if (treatmentsPlugin.lastCarbTime < lastRun.lastAPSRun){
|
||||
cobText = cobText + " | " + lastRun.constraintsProcessed!!.carbsReq + " " + resourceHelper.gs(R.string.required)
|
||||
}
|
||||
overview_cob?.text = cobText
|
||||
if (!carbAnimation.isRunning)
|
||||
carbAnimation.start()
|
||||
} else {
|
||||
overview_cob?.text = cobText
|
||||
if (carbAnimation.isRunning)
|
||||
carbAnimation.stop()
|
||||
carbAnimation.stop()
|
||||
carbAnimation.selectDrawable(0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue