From 74268675af3542f91c1d842011b98c0b08182083 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 8 Jun 2017 22:14:55 +0200 Subject: [PATCH] optimize overview graph drawing --- .../IobCobCalculator/AutosensData.java | 2 +- .../plugins/Overview/OverviewFragment.java | 23 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java index 2c919c9fe8..427ca5d531 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java @@ -12,7 +12,7 @@ public class AutosensData { public double deviation = 0d; boolean calculateWithDeviation = false; double absorbed = 0d; - double carbsFromBolus = 0d; + public double carbsFromBolus = 0d; public double cob = 0; public double bgi = 0d; public double delta = 0d; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 3f40baf7c1..900c5c27ad 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -1296,17 +1296,30 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, List iobArray = new ArrayList<>(); List cobArray = new ArrayList<>(); List devArray = new ArrayList<>(); + double lastIob = -1000; + int lastCob = 0; for (long time = fromTime; time <= now; time += 5 * 60 * 1000L) { if (showIobView.isChecked()) { - IobTotal iob = IobCobCalculatorPlugin.calulateFromTreatmentsAndTemps(time); - iobArray.add(new DataPoint(time, iob.iob)); - maxIobValueFound = Math.max(maxIobValueFound, Math.abs(iob.iob)); + double iob = IobCobCalculatorPlugin.calulateFromTreatmentsAndTemps(time).iob; + if (Math.abs(lastIob - iob) > 0.02) { + if (Math.abs(lastIob - iob) > 0.2) + iobArray.add(new DataPoint(time, lastIob)); + iobArray.add(new DataPoint(time, iob)); + maxIobValueFound = Math.max(maxIobValueFound, Math.abs(iob)); + lastIob = iob; + } } if (showCobView.isChecked() || showDeviationsView.isChecked()) { AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(time); if (autosensData != null && showCobView.isChecked()) { - cobArray.add(new DataPoint(time, autosensData.cob)); - maxCobValueFound = Math.max(maxCobValueFound, autosensData.cob); + int cob = (int) autosensData.cob; + if (cob != lastCob) { + if (autosensData.carbsFromBolus > 0) + cobArray.add(new DataPoint(time, lastCob)); + cobArray.add(new DataPoint(time, cob)); + maxCobValueFound = Math.max(maxCobValueFound, cob); + lastCob = cob; + } } if (autosensData != null && showDeviationsView.isChecked()) { int color = Color.BLACK; // "="