diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java
index 0d518c0603..c8a23ccdff 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java
@@ -242,6 +242,9 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
sb.append("");
sb.append("
");
sb.append(getString(R.string.nsprofileview_basal_label));
+ sb.append( " ( ∑");
+ sb.append(DecimalFormatter.to2Decimal(circadianPercentageProfilePlugin.percentageBasalSum()));
+ sb.append("U )");
sb.append("
" + circadianPercentageProfilePlugin.basalString());
sb.append("");
sb.append(getString(R.string.nsprofileview_ic_label));
@@ -251,7 +254,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
sb.append("
" + circadianPercentageProfilePlugin.isfString());
profileView.setText(Html.fromHtml(sb.toString()));
- baseprofileBasal.setText(Html.fromHtml("" + getString(R.string.base_profile_label) + "
" +
+ baseprofileBasal.setText(Html.fromHtml("" + getString(R.string.base_profile_label) + " ( ∑" + DecimalFormatter.to2Decimal(circadianPercentageProfilePlugin.baseBasalSum()) + "U )
" +
"" + getString(R.string.nsprofileview_basal_label) + "
" + circadianPercentageProfilePlugin.baseBasalString()));
baseprofileIC.setText(Html.fromHtml("" + getString(R.string.nsprofileview_ic_label) + "
" + circadianPercentageProfilePlugin.baseIcString()));
baseprofileISF.setText(Html.fromHtml("" + getString(R.string.nsprofileview_isf_label) + "
" + circadianPercentageProfilePlugin.baseIsfString()));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java
index 2caa7c0639..094ae157c8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java
@@ -207,11 +207,7 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
JSONObject profile = new JSONObject();
StringBuilder stringBuilder = new StringBuilder();
- double sum = 0d;
- for (int i = 0; i < 24; i++) {
- sum += basebasal[i];
- }
- stringBuilder.append(DecimalFormatter.to2Decimal(sum));
+ stringBuilder.append(DecimalFormatter.to2Decimal(sum(basebasal)));
stringBuilder.append("U@");
stringBuilder.append(percentage);
stringBuilder.append("%>");
@@ -298,6 +294,27 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
String baseBasalString() {return profileString(basebasal, 0, 100, true);}
+ public double baseBasalSum(){
+ return sum(basebasal);
+ }
+
+ public double percentageBasalSum(){
+ double result = 0;
+ for (int i = 0; i < basebasal.length; i++) {
+ result += SafeParse.stringToDouble(DecimalFormatter.to2Decimal(basebasal[i] * percentage / 100d));
+ }
+ return result;
+ }
+
+
+ public static double sum(double values[]){
+ double result = 0;
+ for (int i = 0; i < values.length; i++) {
+ result += values[i];
+ }
+ return result;
+ }
+
private static String profileString(double[] values, int timeshift, int percentage, boolean inc) {
timeshift = -(timeshift % 24) + 24;