Merge pull request #10 from MilosKozak/dev

Dev
This commit is contained in:
Roumen Georgiev 2018-03-11 08:24:16 +02:00 committed by GitHub
commit 2ac2006100
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 1341 additions and 333 deletions

Binary file not shown.

View file

@ -38,6 +38,14 @@ public class Constants {
//DanaR //DanaR
public static final double dailyLimitWarning = 0.95d; public static final double dailyLimitWarning = 0.95d;
// Temp targets
public static final int defaultActivityTTDuration = 90; // min
public static final double defaultActivityTTmgdl = 90d;
public static final double defaultActivityTTmmol = 5d;
public static final int defaultEatingSoonTTDuration = 45; // min
public static final double defaultEatingSoonTTmgdl = 140d;
public static final double defaultEatingSoonTTmmol = 8d;
//NSClientInternal //NSClientInternal
public static final int MAX_LOG_LINES = 100; public static final int MAX_LOG_LINES = 100;

View file

@ -247,6 +247,10 @@ public class MainApp extends Application {
return sResources.getString(id, args); return sResources.getString(id, args);
} }
public static int gc(int id) {
return sResources.getColor(id);
}
public static MainApp instance() { public static MainApp instance() {
return sInstance; return sInstance;
} }

View file

@ -442,6 +442,14 @@ public class Profile {
return ret; return ret;
} }
public double getTarget(){
return getTarget(secondsFromMidnight(System.currentTimeMillis()));
}
private double getTarget(Integer time) {
return (getTargetLow(time) + getTargetHigh(time))/2;
}
public Double getTargetLow() { public Double getTargetLow() {
return getTargetLow(secondsFromMidnight(System.currentTimeMillis())); return getTargetLow(secondsFromMidnight(System.currentTimeMillis()));
} }

View file

@ -41,6 +41,10 @@ public class TempTarget implements Interval {
@DatabaseField @DatabaseField
public int durationInMinutes; public int durationInMinutes;
public double target() {
return (low + high) / 2;
}
public boolean isEqual(TempTarget other) { public boolean isEqual(TempTarget other) {
if (date != other.date) { if (date != other.date) {
return false; return false;

View file

@ -325,13 +325,13 @@ public class TemporaryBasal implements Interval {
if(profile != null) { if(profile != null) {
double basal = profile.getBasal(); double basal = profile.getBasal();
if(basal != 0){ if(basal != 0){
return Math.round(rate*100d/basal) + "% "; return Math.round(rate*100d/basal) + "%";
} }
} }
} }
return DecimalFormatter.to2Decimal(rate) + "U/h "; return DecimalFormatter.to2Decimal(rate) + "U/h";
} else { // percent } else { // percent
return percentRate + "% "; return percentRate + "%";
} }
} }

View file

@ -211,7 +211,8 @@ public class DetermineBasalAdapterAMAJS {
mProfile.put("current_basal", basalrate); mProfile.put("current_basal", basalrate);
mProfile.put("temptargetSet", tempTargetSet); mProfile.put("temptargetSet", tempTargetSet);
mProfile.put("autosens_adjust_targets", SP.getBoolean("openapsama_autosens_adjusttargets", true)); mProfile.put("autosens_adjust_targets", SP.getBoolean("openapsama_autosens_adjusttargets", true));
mProfile.put("min_5m_carbimpact", SP.getInt("openapsama_min_5m_carbimpact", SMBDefaults.min_5m_carbimpact)); //TODO: align with max-absorption model in AMA sensitivity
mProfile.put("min_5m_carbimpact", SP.getDouble("openapsama_min_5m_carbimpact", SMBDefaults.min_5m_carbimpact));
if (units.equals(Constants.MMOL)) { if (units.equals(Constants.MMOL)) {
mProfile.put("out_units", "mmol/L"); mProfile.put("out_units", "mmol/L");

View file

@ -176,7 +176,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
double maxBasal = SP.getDouble("openapsma_max_basal", 1d); double maxBasal = SP.getDouble("openapsma_max_basal", 1d);
double minBg = Profile.toMgdl(profile.getTargetLow(), units); double minBg = Profile.toMgdl(profile.getTargetLow(), units);
double maxBg = Profile.toMgdl(profile.getTargetHigh(), units); double maxBg = Profile.toMgdl(profile.getTargetHigh(), units);
double targetBg = (minBg + maxBg) / 2; double targetBg = Profile.toMgdl(profile.getTarget(), units);
minBg = Round.roundTo(minBg, 0.1d); minBg = Round.roundTo(minBg, 0.1d);
maxBg = Round.roundTo(maxBg, 0.1d); maxBg = Round.roundTo(maxBg, 0.1d);
@ -202,7 +202,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
isTempTarget = true; isTempTarget = true;
minBg = HardLimits.verifyHardLimits(tempTarget.low, "minBg", HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]); minBg = HardLimits.verifyHardLimits(tempTarget.low, "minBg", HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
maxBg = HardLimits.verifyHardLimits(tempTarget.high, "maxBg", HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[1]); maxBg = HardLimits.verifyHardLimits(tempTarget.high, "maxBg", HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[1]);
targetBg = HardLimits.verifyHardLimits((tempTarget.low + tempTarget.high) / 2, "targetBg", HardLimits.VERY_HARD_LIMIT_TEMP_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_TARGET_BG[1]); targetBg = HardLimits.verifyHardLimits(tempTarget.target(), "targetBg", HardLimits.VERY_HARD_LIMIT_TEMP_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_TARGET_BG[1]);
} }

View file

@ -179,7 +179,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
double maxBasal = SafeParse.stringToDouble(SP.getString("openapsma_max_basal", "1")); double maxBasal = SafeParse.stringToDouble(SP.getString("openapsma_max_basal", "1"));
double minBg = Profile.toMgdl(profile.getTargetLow(), units); double minBg = Profile.toMgdl(profile.getTargetLow(), units);
double maxBg = Profile.toMgdl(profile.getTargetHigh(), units); double maxBg = Profile.toMgdl(profile.getTargetHigh(), units);
double targetBg = (minBg + maxBg) / 2; double targetBg = Profile.toMgdl(profile.getTarget(), units);
minBg = Round.roundTo(minBg, 0.1d); minBg = Round.roundTo(minBg, 0.1d);
maxBg = Round.roundTo(maxBg, 0.1d); maxBg = Round.roundTo(maxBg, 0.1d);
@ -205,7 +205,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
if (tempTarget != null) { if (tempTarget != null) {
minBg = verifyHardLimits(tempTarget.low, "minBg", HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]); minBg = verifyHardLimits(tempTarget.low, "minBg", HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
maxBg = verifyHardLimits(tempTarget.high, "maxBg", HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[1]); maxBg = verifyHardLimits(tempTarget.high, "maxBg", HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[1]);
targetBg = verifyHardLimits((tempTarget.low + tempTarget.high) / 2, "targetBg", HardLimits.VERY_HARD_LIMIT_TEMP_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_TARGET_BG[1]); targetBg = verifyHardLimits(tempTarget.target(), "targetBg", HardLimits.VERY_HARD_LIMIT_TEMP_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_TARGET_BG[1]);
} }
maxIob = verifyHardLimits(maxIob, "maxIob", 0, HardLimits.maxIobAMA()); maxIob = verifyHardLimits(maxIob, "maxIob", 0, HardLimits.maxIobAMA());

View file

@ -241,7 +241,8 @@ public class DetermineBasalAdapterSMBJS {
mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target); mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target);
mProfile.put("maxCOB", SMBDefaults.maxCOB); mProfile.put("maxCOB", SMBDefaults.maxCOB);
mProfile.put("skip_neutral_temps", SMBDefaults.skip_neutral_temps); mProfile.put("skip_neutral_temps", SMBDefaults.skip_neutral_temps);
mProfile.put("min_5m_carbimpact", SP.getInt("openapsama_min_5m_carbimpact", SMBDefaults.min_5m_carbimpact));; //TODO: align with max-absorption model in AMA sensitivity
mProfile.put("min_5m_carbimpact", SP.getDouble("openapsama_min_5m_carbimpact", SMBDefaults.min_5m_carbimpact));;
mProfile.put("remainingCarbsCap", SMBDefaults.remainingCarbsCap); mProfile.put("remainingCarbsCap", SMBDefaults.remainingCarbsCap);
mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false)); mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false));
mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable); mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable);

View file

@ -181,7 +181,7 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface {
double maxBasal = SP.getDouble("openapsma_max_basal", 1d); double maxBasal = SP.getDouble("openapsma_max_basal", 1d);
double minBg = Profile.toMgdl(profile.getTargetLow(), units); double minBg = Profile.toMgdl(profile.getTargetLow(), units);
double maxBg = Profile.toMgdl(profile.getTargetHigh(), units); double maxBg = Profile.toMgdl(profile.getTargetHigh(), units);
double targetBg = (minBg + maxBg) / 2; double targetBg = Profile.toMgdl(profile.getTarget(), units);
minBg = Round.roundTo(minBg, 0.1d); minBg = Round.roundTo(minBg, 0.1d);
maxBg = Round.roundTo(maxBg, 0.1d); maxBg = Round.roundTo(maxBg, 0.1d);
@ -207,7 +207,7 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface {
isTempTarget = true; isTempTarget = true;
minBg = verifyHardLimits(tempTarget.low, "minBg", HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]); minBg = verifyHardLimits(tempTarget.low, "minBg", HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
maxBg = verifyHardLimits(tempTarget.high, "maxBg", HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[1]); maxBg = verifyHardLimits(tempTarget.high, "maxBg", HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[1]);
targetBg = verifyHardLimits((tempTarget.low + tempTarget.high) / 2, "targetBg", HardLimits.VERY_HARD_LIMIT_TEMP_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_TARGET_BG[1]); targetBg = verifyHardLimits(tempTarget.target(), "targetBg", HardLimits.VERY_HARD_LIMIT_TEMP_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_TARGET_BG[1]);
} }

View file

@ -40,7 +40,7 @@ public class SMBDefaults {
public final static boolean skip_neutral_temps = true; // ***** default false in oref1 ***** if true, don't set neutral temps public final static boolean skip_neutral_temps = true; // ***** default false in oref1 ***** if true, don't set neutral temps
// unsuspend_if_no_temp:false // if true, pump will un-suspend after a zero temp finishes // 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 // bolussnooze_dia_divisor:2 // bolus snooze decays after 1/2 of DIA
public final static int 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)) public final static double min_5m_carbimpact = 8d; // mg/dL per 5m (8 mg/dL/5m corresponds to 24g/hr at a CSF of 4 mg/dL/g (x/5*60/4))
public final static int remainingCarbsCap = 90; // max carbs we'll assume will absorb over 4h if we don't yet see carb absorption public final static int remainingCarbsCap = 90; // max carbs we'll assume will absorb over 4h if we don't yet see carb absorption
// WARNING: use SMB with caution: it can and will automatically bolus up to max_iob worth of extra insulin // WARNING: use SMB with caution: it can and will automatically bolus up to max_iob worth of extra insulin
// enableUAM:true // enable detection of unannounced meal carb absorption // enableUAM:true // enable detection of unannounced meal carb absorption

View file

@ -36,15 +36,15 @@ import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.OpenAPSSMB.DetermineBasalResultSMB;
import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.Callback;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.NumberPicker; import info.nightscout.utils.NumberPicker;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse; import info.nightscout.utils.SafeParse;
@ -69,9 +69,9 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
private static final double FAV1_DEFAULT = 5; private static final double FAV1_DEFAULT = 5;
private static final double FAV2_DEFAULT = 10; private static final double FAV2_DEFAULT = 10;
private static final double FAV3_DEFAULT = 20; private static final double FAV3_DEFAULT = 20;
private CheckBox suspendLoopCheckbox; private CheckBox suspendLoopCheckbox;
private CheckBox startActivityTTCheckbox; private CheckBox startActivityTTCheckbox;
private CheckBox startEatingSoonTTCheckbox;
private Integer maxCarbs; private Integer maxCarbs;
@ -103,7 +103,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
Integer carbs = SafeParse.stringToInt(editCarbs.getText()); Integer carbs = SafeParse.stringToInt(editCarbs.getText());
if (carbs > maxCarbs) { if (carbs > maxCarbs) {
editCarbs.setValue(0d); editCarbs.setValue(0d);
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.carbsconstraintapplied)); ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.carbsconstraintapplied));
} }
} }
@ -127,6 +127,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher); editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
startActivityTTCheckbox = view.findViewById(R.id.newcarbs_activity_tt); startActivityTTCheckbox = view.findViewById(R.id.newcarbs_activity_tt);
startEatingSoonTTCheckbox = view.findViewById(R.id.carbs_eating_soon_tt);
dateButton = view.findViewById(R.id.newcarbs_eventdate); dateButton = view.findViewById(R.id.newcarbs_eventdate);
timeButton = view.findViewById(R.id.newcarb_eventtime); timeButton = view.findViewById(R.id.newcarb_eventtime);
@ -138,6 +139,10 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
dateButton.setOnClickListener(this); dateButton.setOnClickListener(this);
timeButton.setOnClickListener(this); timeButton.setOnClickListener(this);
//To be able to select only one TT at a time
startEatingSoonTTCheckbox.setOnClickListener(this);
startActivityTTCheckbox.setOnClickListener(this);
// TODO prefilling carbs, maybe // TODO prefilling carbs, maybe
// TODO maybe update suggested carbs to target TT when checked // TODO maybe update suggested carbs to target TT when checked
// APSResult lastAPSResult = ConfigBuilderPlugin.getActiveAPS().getLastAPSResult(); // APSResult lastAPSResult = ConfigBuilderPlugin.getActiveAPS().getLastAPSResult();
@ -147,13 +152,13 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
fav1Button = view.findViewById(R.id.newcarbs_plus1); fav1Button = view.findViewById(R.id.newcarbs_plus1);
fav1Button.setOnClickListener(this); fav1Button.setOnClickListener(this);
fav1Button.setText("+" + SP.getString(MainApp.gs(R.string.key_carbs_button_increment_1), String.valueOf(FAV1_DEFAULT))); fav1Button.setText("+" + SP.getString(R.string.key_carbs_button_increment_1, String.valueOf(FAV1_DEFAULT)));
fav2Button = view.findViewById(R.id.newcarbs_plus2); fav2Button = view.findViewById(R.id.newcarbs_plus2);
fav2Button.setOnClickListener(this); fav2Button.setOnClickListener(this);
fav2Button.setText("+" + SP.getString(MainApp.gs(R.string.key_carbs_button_increment_2), String.valueOf(FAV2_DEFAULT))); fav2Button.setText("+" + SP.getString(R.string.key_carbs_button_increment_2, String.valueOf(FAV2_DEFAULT)));
fav3Button = view.findViewById(R.id.newcarbs_plus3); fav3Button = view.findViewById(R.id.newcarbs_plus3);
fav3Button.setOnClickListener(this); fav3Button.setOnClickListener(this);
fav3Button.setText("+" + SP.getString(MainApp.gs(R.string.key_carbs_button_increment_3), String.valueOf(FAV3_DEFAULT))); fav3Button.setText("+" + SP.getString(R.string.key_carbs_button_increment_3, String.valueOf(FAV3_DEFAULT)));
suspendLoopCheckbox = view.findViewById(R.id.newcarbs_suspend_loop); suspendLoopCheckbox = view.findViewById(R.id.newcarbs_suspend_loop);
@ -197,19 +202,26 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
break; break;
case R.id.newcarbs_plus1: case R.id.newcarbs_plus1:
editCarbs.setValue(editCarbs.getValue() editCarbs.setValue(editCarbs.getValue()
+ SP.getDouble(MainApp.gs(R.string.key_carbs_button_increment_1), FAV1_DEFAULT)); + SP.getDouble(R.string.key_carbs_button_increment_1, FAV1_DEFAULT));
validateInputs(); validateInputs();
break; break;
case R.id.newcarbs_plus2: case R.id.newcarbs_plus2:
editCarbs.setValue(editCarbs.getValue() editCarbs.setValue(editCarbs.getValue()
+ SP.getDouble(MainApp.gs(R.string.key_carbs_button_increment_2), FAV2_DEFAULT)); + SP.getDouble(R.string.key_carbs_button_increment_2, FAV2_DEFAULT));
validateInputs(); validateInputs();
break; break;
case R.id.newcarbs_plus3: case R.id.newcarbs_plus3:
editCarbs.setValue(editCarbs.getValue() editCarbs.setValue(editCarbs.getValue()
+ SP.getDouble(MainApp.gs(R.string.key_carbs_button_increment_3), FAV3_DEFAULT)); + SP.getDouble(R.string.key_carbs_button_increment_3, FAV3_DEFAULT));
validateInputs(); validateInputs();
break; break;
case R.id.newcarbs_activity_tt:
startEatingSoonTTCheckbox.setChecked(false);
break;
case R.id.carbs_eating_soon_tt:
startActivityTTCheckbox.setChecked(false);
break;
} }
} }
@ -227,20 +239,46 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
String confirmMessage = ""; String confirmMessage = "";
if (carbs > 0) if (carbs > 0)
confirmMessage += getString(R.string.carbs) + ": " + "<font color='" + MainApp.sResources.getColor(R.color.colorCarbsButton) + "'>" + carbsAfterConstraints + "g" + "</font>"; confirmMessage += MainApp.gs(R.string.carbs) + ": " + "<font color='" + MainApp.gc(R.color.colorCarbsButton) + "'>" + carbsAfterConstraints + "g" + "</font>";
if (!carbsAfterConstraints.equals(carbs)) if (!carbsAfterConstraints.equals(carbs))
confirmMessage += "<br/><font color='" + MainApp.sResources.getColor(R.color.low) + "'>" + getString(R.string.carbsconstraintapplied) + "</font>"; confirmMessage += "<br/><font color='" + MainApp.gc(R.color.low) + "'>" + MainApp.gs(R.string.carbsconstraintapplied) + "</font>";
if (suspendLoopCheckbox.isChecked()) { if (suspendLoopCheckbox.isChecked()) {
confirmMessage += "<br/>" + "Loop: " + "<font color='" + MainApp.sResources.getColor(R.color.low) + "'>" + "Suspend for 30 min</font>"; confirmMessage += "<br/>" + MainApp.gs(R.string.loop) + ": " + "<font color='" + MainApp.gc(R.color.low) + "'>" + MainApp.gs(R.string.suspendloopfor30min) + "</font>";
} }
double prefTTDuration = SP.getDouble(R.string.key_activity_duration, 90d); final Profile currentProfile = MainApp.getConfigBuilder().getProfile();
double ttDuration = prefTTDuration > 0 ? prefTTDuration : 90d; if (currentProfile == null)
double prefTT = SP.getDouble(R.string.key_activity_target, 140d); return;
double tt = prefTT > 0 ? prefTT : 140d;
int activityTTDuration = SP.getInt(R.string.key_activity_duration, Constants.defaultActivityTTDuration);
activityTTDuration = activityTTDuration > 0 ? activityTTDuration : Constants.defaultActivityTTDuration;
double activityTT = SP.getDouble(R.string.key_activity_target, currentProfile.getUnits().equals(Constants.MMOL) ? Constants.defaultActivityTTmmol : Constants.defaultActivityTTmgdl);
activityTT = activityTT > 0 ? activityTT : currentProfile.getUnits().equals(Constants.MMOL) ? Constants.defaultActivityTTmmol : Constants.defaultActivityTTmgdl;
int eatingSoonTTDuration = SP.getInt(R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration);
eatingSoonTTDuration = eatingSoonTTDuration > 0 ? eatingSoonTTDuration : Constants.defaultEatingSoonTTDuration;
double eatingSoonTT = SP.getDouble(R.string.key_eatingsoon_target, currentProfile.getUnits().equals(Constants.MMOL) ? Constants.defaultEatingSoonTTmmol : Constants.defaultEatingSoonTTmgdl);
eatingSoonTT = eatingSoonTT > 0 ? Profile.toMgdl(eatingSoonTT, currentProfile.getUnits()) : currentProfile.getUnits().equals(Constants.MMOL) ? Constants.defaultEatingSoonTTmmol : Constants.defaultEatingSoonTTmgdl;
if (startActivityTTCheckbox.isChecked()) { if (startActivityTTCheckbox.isChecked()) {
confirmMessage += "<br/>" + "TT: " + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + ((int) tt) + "mg/dl for " + ((int) ttDuration) + " min </font>"; if (currentProfile.getUnits().equals(Constants.MMOL)) {
confirmMessage += "<br/>" + MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.high) + "'>" + DecimalFormatter.to1Decimal(activityTT) + " mmol/l (" + ((int) activityTTDuration) + " min)</font>";
} else
confirmMessage += "<br/>" + MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.high) + "'>" + DecimalFormatter.to0Decimal(activityTT) + " mg/dl (" + ((int) activityTTDuration) + " min)</font>";
} }
if (startEatingSoonTTCheckbox.isChecked() && !startActivityTTCheckbox.isChecked()) {
if (currentProfile.getUnits().equals(Constants.MMOL)) {
confirmMessage += "<br/>" + MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.high) + "'>" + DecimalFormatter.to1Decimal(eatingSoonTT) + " mmol/l (" + eatingSoonTTDuration + " min)</font>";
} else
confirmMessage += "<br/>" + MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.high) + "'>" + DecimalFormatter.to0Decimal(eatingSoonTT) + " mg/dl (" + eatingSoonTTDuration + " min)</font>";
}
final double finalActivityTT = activityTT;
final double finalEatigSoonTT = eatingSoonTT;
final int finalActivityTTDuration = activityTTDuration;
final int finalEatingSoonTTDuration = eatingSoonTTDuration;
if (StringUtils.isNoneEmpty(food)) { if (StringUtils.isNoneEmpty(food)) {
confirmMessage += "<br/>" + "Food: " + food; confirmMessage += "<br/>" + "Food: " + food;
@ -249,66 +287,80 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
if (!initialEventTime.equals(eventTime)) { if (!initialEventTime.equals(eventTime)) {
confirmMessage += "<br/> Time: " + DateUtil.dateAndTimeString(eventTime); confirmMessage += "<br/> Time: " + DateUtil.dateAndTimeString(eventTime);
} }
if (confirmMessage.length() > 0) {
final int finalCarbsAfterConstraints = carbsAfterConstraints; final int finalCarbsAfterConstraints = carbsAfterConstraints;
final Context context = getContext(); final Context context = getContext();
final AlertDialog.Builder builder = new AlertDialog.Builder(context); final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(this.getContext().getString(R.string.confirmation)); builder.setTitle(MainApp.gs(R.string.confirmation));
if (confirmMessage.startsWith("<br/>")) if (confirmMessage.startsWith("<br/>"))
confirmMessage = confirmMessage.substring("<br/>".length()); confirmMessage = confirmMessage.substring("<br/>".length());
builder.setMessage(Html.fromHtml(confirmMessage));
builder.setPositiveButton(getString(R.string.ok), (dialog, id) -> {
synchronized (builder) {
if (accepted) {
log.debug("guarding: already accepted");
return;
}
accepted = true;
if (suspendLoopCheckbox.isChecked()) { builder.setMessage(Html.fromHtml(confirmMessage));
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop(); builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
activeloop.suspendTo(System.currentTimeMillis() + 30L * 60 * 1000); synchronized (builder) {
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() { if (accepted) {
@Override log.debug("guarding: already accepted");
public void run() { return;
if (!result.success) { }
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror)); accepted = true;
if (suspendLoopCheckbox.isChecked()) {
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
activeloop.suspendTo(System.currentTimeMillis() + 30L * 60 * 1000);
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
@Override
public void run() {
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.tempbasaldeliveryerror));
}
} }
} });
}); }
}
if (startActivityTTCheckbox.isChecked()) { if (startActivityTTCheckbox.isChecked()) {
TempTarget tempTarget = new TempTarget(); TempTarget tempTarget = new TempTarget();
tempTarget.date = System.currentTimeMillis(); tempTarget.date = System.currentTimeMillis();
tempTarget.durationInMinutes = (int) ttDuration; tempTarget.durationInMinutes = finalActivityTTDuration;
tempTarget.reason = "Activity"; tempTarget.reason = MainApp.gs(R.string.activity);
tempTarget.source = Source.USER; tempTarget.source = Source.USER;
tempTarget.low = (int) tt; tempTarget.low = Profile.toMgdl(finalActivityTT, currentProfile.getUnits());
tempTarget.high = (int) tt; tempTarget.high = Profile.toMgdl(finalActivityTT, currentProfile.getUnits());
MainApp.getDbHelper().createOrUpdate(tempTarget); MainApp.getDbHelper().createOrUpdate(tempTarget);
} } else if (startEatingSoonTTCheckbox.isChecked()) {
TempTarget tempTarget = new TempTarget();
tempTarget.date = System.currentTimeMillis();
tempTarget.durationInMinutes = finalEatingSoonTTDuration;
tempTarget.reason = MainApp.gs(R.string.eatingsoon);
tempTarget.source = Source.USER;
tempTarget.low = Profile.toMgdl(finalEatigSoonTT, currentProfile.getUnits());
tempTarget.high = Profile.toMgdl(finalEatigSoonTT, currentProfile.getUnits());
MainApp.getDbHelper().createOrUpdate(tempTarget);
}
if (finalCarbsAfterConstraints > 0 || food != null) { if (finalCarbsAfterConstraints > 0 || food != null) {
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo(); DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
detailedBolusInfo.date = eventTime.getTime(); detailedBolusInfo.date = eventTime.getTime();
detailedBolusInfo.eventType = CareportalEvent.CARBCORRECTION; detailedBolusInfo.eventType = CareportalEvent.CARBCORRECTION;
detailedBolusInfo.carbs = finalCarbsAfterConstraints; detailedBolusInfo.carbs = finalCarbsAfterConstraints;
// detailedBolusInfo.food = food; // detailedBolusInfo.food = food;
detailedBolusInfo.context = context; detailedBolusInfo.context = context;
detailedBolusInfo.source = Source.USER; detailedBolusInfo.source = Source.USER;
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
}
} }
} });
}); builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.setNegativeButton(getString(R.string.cancel), null); builder.show();
builder.show(); dismiss();
dismiss(); } else
dismiss();
} catch (Exception e) { } catch (Exception e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
} }
} }
@Override @Override
@ -326,4 +378,4 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
eventTime.setSeconds(second); eventTime.setSeconds(second);
timeButton.setText(DateUtil.timeString(eventTime)); timeButton.setText(DateUtil.timeString(eventTime));
} }
} }

View file

@ -246,8 +246,19 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
double ttDuration = prefTTDuration > 0 ? prefTTDuration : 45d; double ttDuration = prefTTDuration > 0 ? prefTTDuration : 45d;
double prefTT = SP.getDouble(R.string.key_eatingsoon_target, 80d); double prefTT = SP.getDouble(R.string.key_eatingsoon_target, 80d);
double tt = prefTT > 0 ? prefTT : 80d; double tt = prefTT > 0 ? prefTT : 80d;
Profile currentProfile = MainApp.getConfigBuilder().getProfile();
if(currentProfile == null)
return;
if(currentProfile.getUnits().equals(Constants.MMOL))
tt = prefTT > 0 ? Profile.toMgdl(prefTT, Constants.MMOL) : 80d;
else
tt = prefTT > 0 ? prefTT : 80d;
final double finalTT = tt;
if (startESMCheckbox.isChecked()) { if (startESMCheckbox.isChecked()) {
confirmMessage += "<br/>" + "TT: " + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + ((int) tt) + "mg/dl for " + ((int) ttDuration) + " min </font>"; if(currentProfile.getUnits().equals("mmol")){
confirmMessage += "<br/>" + "TT: " + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + Profile.toMmol(tt, Constants.MGDL) + " mmol for " + ((int) ttDuration) + " min </font>";
} else
confirmMessage += "<br/>" + "TT: " + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + ((int) tt) + "mg/dl for " + ((int) ttDuration) + " min </font>";
} }
if (!initialEventTime.equals(eventTime)) { if (!initialEventTime.equals(eventTime)) {
@ -277,8 +288,8 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
tempTarget.durationInMinutes = (int) ttDuration; tempTarget.durationInMinutes = (int) ttDuration;
tempTarget.reason = "Eating soon"; tempTarget.reason = "Eating soon";
tempTarget.source = Source.USER; tempTarget.source = Source.USER;
tempTarget.low = (int) tt; tempTarget.low = (int) finalTT;
tempTarget.high = (int) tt; tempTarget.high = (int) finalTT;
MainApp.getDbHelper().createOrUpdate(tempTarget); MainApp.getDbHelper().createOrUpdate(tempTarget);
} }
@ -339,4 +350,4 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
eventTime.setSeconds(second); eventTime.setSeconds(second);
timeButton.setText(DateUtil.timeString(eventTime)); timeButton.setText(DateUtil.timeString(eventTime));
} }
} }

View file

@ -249,7 +249,7 @@ public class GraphData {
if (tt == null) { if (tt == null) {
value = (profile.getTargetLow(time) + profile.getTargetHigh(time)) / 2; value = (profile.getTargetLow(time) + profile.getTargetHigh(time)) / 2;
} else { } else {
value = (tt.low + tt.high) / 2; value = tt.target();
} }
if (lastTarget > 0 && lastTarget != value) { if (lastTarget > 0 && lastTarget != value) {
targetsSeriesArray.add(new DataPoint(time, lastTarget)); targetsSeriesArray.add(new DataPoint(time, lastTarget));

View file

@ -27,13 +27,15 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpInsight.connector.AbsoluteTBRTaskRunner;
import info.nightscout.androidaps.plugins.PumpInsight.connector.CancelBolusTaskRunner; import info.nightscout.androidaps.plugins.PumpInsight.connector.CancelBolusTaskRunner;
import info.nightscout.androidaps.plugins.PumpInsight.connector.Connector; import info.nightscout.androidaps.plugins.PumpInsight.connector.Connector;
import info.nightscout.androidaps.plugins.PumpInsight.connector.ReadBasalProfileTaskRunner;
import info.nightscout.androidaps.plugins.PumpInsight.connector.SetTBRTaskRunner; import info.nightscout.androidaps.plugins.PumpInsight.connector.SetTBRTaskRunner;
import info.nightscout.androidaps.plugins.PumpInsight.connector.WriteBasalProfileTaskRunner;
import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightPumpCallback; import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightPumpCallback;
import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightPumpUpdateGui; import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightPumpUpdateGui;
import info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver; import info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver;
@ -46,6 +48,7 @@ import info.nightscout.utils.SP;
import sugar.free.sightparser.applayer.descriptors.ActiveBolus; import sugar.free.sightparser.applayer.descriptors.ActiveBolus;
import sugar.free.sightparser.applayer.descriptors.ActiveBolusType; import sugar.free.sightparser.applayer.descriptors.ActiveBolusType;
import sugar.free.sightparser.applayer.descriptors.PumpStatus; import sugar.free.sightparser.applayer.descriptors.PumpStatus;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfileBlock;
import sugar.free.sightparser.applayer.messages.AppLayerMessage; import sugar.free.sightparser.applayer.messages.AppLayerMessage;
import sugar.free.sightparser.applayer.messages.remote_control.BolusMessage; import sugar.free.sightparser.applayer.messages.remote_control.BolusMessage;
import sugar.free.sightparser.applayer.messages.remote_control.CancelTBRMessage; import sugar.free.sightparser.applayer.messages.remote_control.CancelTBRMessage;
@ -56,7 +59,6 @@ import sugar.free.sightparser.handling.TaskRunner;
import sugar.free.sightparser.handling.taskrunners.StatusTaskRunner; import sugar.free.sightparser.handling.taskrunners.StatusTaskRunner;
import static info.nightscout.androidaps.plugins.PumpInsight.history.PumpIdCache.getRecordUniqueID; import static info.nightscout.androidaps.plugins.PumpInsight.history.PumpIdCache.getRecordUniqueID;
import static info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers.roundDouble;
/** /**
@ -93,6 +95,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
private double basalRate = 0; private double basalRate = 0;
private Connector connector; private Connector connector;
private volatile boolean connector_enabled = false; private volatile boolean connector_enabled = false;
private List<BRProfileBlock.ProfileBlock> profileBlocks;
private final TaskRunner.ResultCallback statusResultHandler = new TaskRunner.ResultCallback() { private final TaskRunner.ResultCallback statusResultHandler = new TaskRunner.ResultCallback() {
@Override @Override
@ -110,13 +113,17 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
@Override @Override
public synchronized void onResult(Object result) { public synchronized void onResult(Object result) {
log("GOT STATUS RESULT!!!"); if (result instanceof StatusTaskRunner.StatusResult) {
statusResult = (StatusTaskRunner.StatusResult) result; log("GOT STATUS RESULT!!!");
statusResultTime = Helpers.tsl(); statusResult = (StatusTaskRunner.StatusResult) result;
processStatusResult(); statusResultTime = Helpers.tsl();
updateGui(); processStatusResult();
connector.requestHistoryReSync(); updateGui();
connector.requestHistorySync(); connector.requestHistoryReSync();
connector.requestHistorySync();
} else if (result instanceof List) {
profileBlocks = (List<BRProfileBlock.ProfileBlock>) result;
}
} }
}; };
@ -142,7 +149,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
pumpDescription.tempDurationStep30mAllowed = true; pumpDescription.tempDurationStep30mAllowed = true;
pumpDescription.tempMaxDuration = 24 * 60; pumpDescription.tempMaxDuration = 24 * 60;
pumpDescription.isSetBasalProfileCapable = false; // leave this for now pumpDescription.isSetBasalProfileCapable = true; // leave this for now
pumpDescription.basalStep = 0.01d; pumpDescription.basalStep = 0.01d;
pumpDescription.basalMinimumRate = 0.02d; pumpDescription.basalMinimumRate = 0.02d;
@ -378,6 +385,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
public void run() { public void run() {
taskRunner = new StatusTaskRunner(connector.getServiceConnector()); taskRunner = new StatusTaskRunner(connector.getServiceConnector());
taskRunner.fetch(statusResultHandler); taskRunner.fetch(statusResultHandler);
new ReadBasalProfileTaskRunner(connector.getServiceConnector()).fetch(statusResultHandler);
} }
} }
, 1000); , 1000);
@ -386,21 +394,59 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
} }
} }
// TODO implement
@Override @Override
public PumpEnactResult setNewBasalProfile(Profile profile) { public PumpEnactResult setNewBasalProfile(Profile profile) {
lastDataTime = new Date();
// Do nothing here. we are using MainApp.getConfigBuilder().getActiveProfile().getProfile();
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
result.enacted = false; if (!isInitialized()) {
result.success = false; log.error("setNewBasalProfile not initialized");
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60); Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
result.comment = MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet);
return result;
} else {
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
}
List<BRProfileBlock.ProfileBlock> profileBlocks = new ArrayList<>();
for (int i = 0; i < profile.getBasalValues().length; i++) {
Profile.BasalValue basalValue = profile.getBasalValues()[i];
Profile.BasalValue nextValue = null;
if (profile.getBasalValues().length > i + 1) nextValue = profile.getBasalValues()[i + 1];
profileBlocks.add(new BRProfileBlock.ProfileBlock((((nextValue != null ? nextValue.timeAsSeconds : 24 * 60 * 60) - basalValue.timeAsSeconds) / 60), basalValue.value));
}
final UUID uuid = aSyncTaskRunner(new WriteBasalProfileTaskRunner(connector.getServiceConnector(), profileBlocks), "Write basal profile");
final Mstatus ms = async.busyWaitForCommandResult(uuid, BUSY_WAIT_TIME);
if (ms.success()) {
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(notification));
result.success = true;
result.enacted = true;
result.comment = "OK";
} else {
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
result.comment = MainApp.sResources.getString(R.string.failedupdatebasalprofile);
}
return result; return result;
} }
@Override @Override
public boolean isThisProfileSet(Profile profile) { public boolean isThisProfileSet(Profile profile) {
if (!isInitialized() || profileBlocks == null) return true;
if (profile.getBasalValues().length != profileBlocks.size()) return false;
for (int i = 0; i < profileBlocks.size(); i++) {
BRProfileBlock.ProfileBlock profileBlock = profileBlocks.get(i);
Profile.BasalValue basalValue = profile.getBasalValues()[i];
Profile.BasalValue nextValue = null;
if (profile.getBasalValues().length > i + 1) nextValue = profile.getBasalValues()[i + 1];
if (profileBlock == null || basalValue == null) return false;
if (profileBlock.getDuration() * 60 != (nextValue != null ? nextValue.timeAsSeconds : 24 * 60 * 60) - basalValue.timeAsSeconds) return false;
//Allow a little imprecision due to rounding errors
if (Math.abs(profileBlock.getAmount() - basalValue.value) > 0.2D) return false;
}
return true; return true;
} }
@ -431,7 +477,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
// is there an insulin component to the treatment? // is there an insulin component to the treatment?
if (detailedBolusInfo.insulin > 0) { if (detailedBolusInfo.insulin > 0) {
final UUID cmd = deliverBolus((float) detailedBolusInfo.insulin); // actually request delivery final UUID cmd = deliverBolus(detailedBolusInfo.insulin); // actually request delivery
if (cmd == null) { if (cmd == null) {
return pumpEnactFailure(); return pumpEnactFailure();
} }
@ -545,51 +591,6 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
return pumpEnactResult; return pumpEnactResult;
} }
//@Override
public PumpEnactResult setTempBasalAbsoluteOld(Double absoluteRate, Integer durationInMinutes, boolean enforceNew) {
absoluteRate = Helpers.roundDouble(absoluteRate, 3);
log("Set TBR absolute: " + absoluteRate);
final AbsoluteTBRTaskRunner task = new AbsoluteTBRTaskRunner(connector.getServiceConnector(), absoluteRate, durationInMinutes);
final UUID cmd = aSyncTaskRunner(task, "Set TBR abs: " + absoluteRate + " " + durationInMinutes + "m");
if (cmd == null) {
return pumpEnactFailure();
}
Mstatus ms = async.busyWaitForCommandResult(cmd, BUSY_WAIT_TIME);
log("Got command status: " + ms);
PumpEnactResult pumpEnactResult = new PumpEnactResult().enacted(true).isPercent(false).duration(durationInMinutes);
pumpEnactResult.absolute = absoluteRate; // TODO get converted value?
pumpEnactResult.success = ms.success();
pumpEnactResult.isTempCancel = false; // do we test this here?
pumpEnactResult.comment = ms.getCommandComment();
if (pumpEnactResult.success) {
// create log entry
final TemporaryBasal tempBasal = new TemporaryBasal();
tempBasal.date = System.currentTimeMillis();
tempBasal.isAbsolute = true;
tempBasal.absoluteRate = task.getCalculatedAbsolute(); // is this the correct figure to use?
tempBasal.durationInMinutes = durationInMinutes;
tempBasal.source = Source.USER;
MainApp.getConfigBuilder().addToHistoryTempBasal(tempBasal);
}
if (Config.logPumpComm)
log.debug("Setting temp basal absolute: " + pumpEnactResult.success);
lastDataTime = new Date();
updateGui();
connector.requestHistorySync(5000);
connector.tryToGetPumpStatusAgain();
return pumpEnactResult;
}
@Override @Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) { public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
@ -686,8 +687,8 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) { public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
log("Set Extended bolus " + insulin + " " + durationInMinutes); log("Set Extended bolus " + insulin + " " + durationInMinutes);
ExtendedBolusMessage extendedBolusMessage = new ExtendedBolusMessage(); ExtendedBolusMessage extendedBolusMessage = new ExtendedBolusMessage();
extendedBolusMessage.setAmount((float) ((double) insulin)); extendedBolusMessage.setAmount(insulin);
extendedBolusMessage.setDuration((short) ((int) durationInMinutes)); extendedBolusMessage.setDuration(durationInMinutes);
final UUID cmd = aSyncSingleCommand(extendedBolusMessage, "Extended bolus U" + insulin + " mins:" + durationInMinutes); final UUID cmd = aSyncSingleCommand(extendedBolusMessage, "Extended bolus U" + insulin + " mins:" + durationInMinutes);
if (cmd == null) { if (cmd == null) {
return pumpEnactFailure(); return pumpEnactFailure();
@ -755,7 +756,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
} }
private synchronized UUID deliverBolus(float bolusValue) { private synchronized UUID deliverBolus(double bolusValue) {
log("DeliverBolus: " + bolusValue); log("DeliverBolus: " + bolusValue);
if (bolusValue == 0) return null; if (bolusValue == 0) return null;
@ -838,7 +839,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
if (statusResult != null) { if (statusResult != null) {
batteryPercent = statusResult.getBatteryAmountMessage().getBatteryAmount(); batteryPercent = statusResult.getBatteryAmountMessage().getBatteryAmount();
reservoirInUnits = (int) statusResult.getCartridgeAmountMessage().getCartridgeAmount(); reservoirInUnits = (int) statusResult.getCartridgeAmountMessage().getCartridgeAmount();
basalRate = roundDouble(statusResult.getCurrentBasalMessage().getCurrentBasalAmount(), 2); basalRate = statusResult.getCurrentBasalMessage().getCurrentBasalAmount();
initialized = true; // basic communication test initialized = true; // basic communication test
} }
} }

View file

@ -1,60 +0,0 @@
package info.nightscout.androidaps.plugins.PumpInsight.connector;
import info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers;
import sugar.free.sightparser.applayer.messages.AppLayerMessage;
import sugar.free.sightparser.applayer.messages.remote_control.ChangeTBRMessage;
import sugar.free.sightparser.applayer.messages.remote_control.SetTBRMessage;
import sugar.free.sightparser.applayer.messages.status.CurrentBasalMessage;
import sugar.free.sightparser.applayer.messages.status.CurrentTBRMessage;
import sugar.free.sightparser.handling.SightServiceConnector;
import sugar.free.sightparser.handling.TaskRunner;
// by Tebbe Ubben
public class AbsoluteTBRTaskRunner extends TaskRunner {
private double absolute;
private int amount;
private int duration;
private int calculated_percentage;
private double calculated_absolute;
public AbsoluteTBRTaskRunner(SightServiceConnector serviceConnector, double absolute, int duration) {
super(serviceConnector);
if (absolute < 0) absolute = 0;
this.absolute = absolute;
this.duration = duration;
}
public int getCalculatedPercentage() {
return calculated_percentage;
}
public double getCalculatedAbsolute() {
return calculated_absolute;
}
@Override
protected AppLayerMessage run(AppLayerMessage message) throws Exception {
if (message == null) return new CurrentBasalMessage();
else if (message instanceof CurrentBasalMessage) {
float currentBasal = ((CurrentBasalMessage) message).getCurrentBasalAmount();
amount = (int) (100d / currentBasal * absolute);
amount = ((int) amount / 10) * 10;
if (amount > 250) amount = 250;
calculated_percentage = amount;
calculated_absolute = Helpers.roundDouble(calculated_percentage * (double) currentBasal / 100d, 3);
Connector.log("Asked: " + absolute + " current: " + currentBasal + " calculated as: " + amount + "%" + " = " + calculated_absolute);
return new CurrentTBRMessage();
} else if (message instanceof CurrentTBRMessage) {
SetTBRMessage setTBRMessage;
if (((CurrentTBRMessage) message).getPercentage() == 100)
setTBRMessage = new SetTBRMessage();
else setTBRMessage = new ChangeTBRMessage();
setTBRMessage.setAmount((short) amount);
setTBRMessage.setDuration((short) duration);
return setTBRMessage;
} else if (message instanceof SetTBRMessage) finish(amount);
return null;
}
}

View file

@ -0,0 +1,65 @@
package info.nightscout.androidaps.plugins.PumpInsight.connector;
import android.util.Log;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.ActiveProfileBlock;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile1Block;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile2Block;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile3Block;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile4Block;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile5Block;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfileBlock;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.ConfigurationBlock;
import sugar.free.sightparser.applayer.messages.AppLayerMessage;
import sugar.free.sightparser.applayer.messages.configuration.ReadConfigurationBlockMessage;
import sugar.free.sightparser.handling.SightServiceConnector;
import sugar.free.sightparser.handling.TaskRunner;
/**
* Created by Tebbe Ubben on 10.03.2018.
*/
public class ReadBasalProfileTaskRunner extends TaskRunner {
public ReadBasalProfileTaskRunner(SightServiceConnector serviceConnector) {
super(serviceConnector);
}
@Override
protected AppLayerMessage run(AppLayerMessage message) throws Exception {
if (message == null) {
ReadConfigurationBlockMessage readMessage = new ReadConfigurationBlockMessage();
readMessage.setConfigurationBlockID(ActiveProfileBlock.ID);
return readMessage;
} else if (message instanceof ReadConfigurationBlockMessage) {
ConfigurationBlock configurationBlock = ((ReadConfigurationBlockMessage) message).getConfigurationBlock();
if (configurationBlock instanceof ActiveProfileBlock) {
ActiveProfileBlock activeProfileBlock = (ActiveProfileBlock) configurationBlock;
ReadConfigurationBlockMessage readMessage = new ReadConfigurationBlockMessage();
switch (activeProfileBlock.getActiveProfile()) {
case BR_PROFILE_1:
readMessage.setConfigurationBlockID(BRProfile1Block.ID);
break;
case BR_PROFILE_2:
readMessage.setConfigurationBlockID(BRProfile2Block.ID);
break;
case BR_PROFILE_3:
readMessage.setConfigurationBlockID(BRProfile3Block.ID);
break;
case BR_PROFILE_4:
readMessage.setConfigurationBlockID(BRProfile4Block.ID);
break;
case BR_PROFILE_5:
readMessage.setConfigurationBlockID(BRProfile5Block.ID);
break;
}
ReadConfigurationBlockMessage test = new ReadConfigurationBlockMessage();
test.setConfigurationBlockID(BRProfile1Block.ID);
return test;
} else if (configurationBlock instanceof BRProfileBlock) {
finish(((BRProfileBlock) configurationBlock).getProfileBlocks());
}
}
return null;
}
}

View file

@ -28,20 +28,20 @@ public class SetTBRTaskRunner extends TaskRunner {
if (amount == 100) finish(amount); if (amount == 100) finish(amount);
else { else {
SetTBRMessage setTBRMessage = new SetTBRMessage(); SetTBRMessage setTBRMessage = new SetTBRMessage();
setTBRMessage.setDuration((short) duration); setTBRMessage.setDuration(duration);
setTBRMessage.setAmount((short) amount); setTBRMessage.setAmount(amount);
return setTBRMessage; return setTBRMessage;
} }
} else { } else {
if (amount == 100) { if (amount == 100) {
ChangeTBRMessage changeTBRMessage = new ChangeTBRMessage(); ChangeTBRMessage changeTBRMessage = new ChangeTBRMessage();
changeTBRMessage.setDuration((short) 1); changeTBRMessage.setDuration(1);
changeTBRMessage.setAmount((short) 90); changeTBRMessage.setAmount(90);
return changeTBRMessage; return changeTBRMessage;
} else { } else {
ChangeTBRMessage changeTBRMessage = new ChangeTBRMessage(); ChangeTBRMessage changeTBRMessage = new ChangeTBRMessage();
changeTBRMessage.setDuration((short) duration); changeTBRMessage.setDuration(duration);
changeTBRMessage.setAmount((short) amount); changeTBRMessage.setAmount(amount);
return changeTBRMessage; return changeTBRMessage;
} }
} }

View file

@ -0,0 +1,72 @@
package info.nightscout.androidaps.plugins.PumpInsight.connector;
import java.util.List;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.ActiveProfileBlock;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile1Block;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile2Block;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile3Block;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile4Block;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile5Block;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfileBlock;
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.ConfigurationBlock;
import sugar.free.sightparser.applayer.messages.AppLayerMessage;
import sugar.free.sightparser.applayer.messages.configuration.CloseWriteSessionMessage;
import sugar.free.sightparser.applayer.messages.configuration.OpenWriteSessionMessage;
import sugar.free.sightparser.applayer.messages.configuration.ReadConfigurationBlockMessage;
import sugar.free.sightparser.applayer.messages.configuration.WriteConfigurationBlockMessage;
import sugar.free.sightparser.handling.SightServiceConnector;
import sugar.free.sightparser.handling.TaskRunner;
/**
* Created by Tebbe Ubben on 10.03.2018.
*/
public class WriteBasalProfileTaskRunner extends TaskRunner {
private List<BRProfileBlock.ProfileBlock> profileBlocks;
private BRProfileBlock profileBlock;
public WriteBasalProfileTaskRunner(SightServiceConnector serviceConnector, List<BRProfileBlock.ProfileBlock> profileBlocks) {
super(serviceConnector);
this.profileBlocks = profileBlocks;
}
@Override
protected AppLayerMessage run(AppLayerMessage message) throws Exception {
if (message == null) {
ReadConfigurationBlockMessage readMessage = new ReadConfigurationBlockMessage();
readMessage.setConfigurationBlockID(ActiveProfileBlock.ID);
return readMessage;
} else if (message instanceof ReadConfigurationBlockMessage) {
ConfigurationBlock configurationBlock = ((ReadConfigurationBlockMessage) message).getConfigurationBlock();
ActiveProfileBlock activeProfileBlock = (ActiveProfileBlock) configurationBlock;
switch (activeProfileBlock.getActiveProfile()) {
case BR_PROFILE_1:
profileBlock = new BRProfile1Block();
break;
case BR_PROFILE_2:
profileBlock = new BRProfile2Block();
break;
case BR_PROFILE_3:
profileBlock = new BRProfile3Block();
break;
case BR_PROFILE_4:
profileBlock = new BRProfile4Block();
break;
case BR_PROFILE_5:
profileBlock = new BRProfile5Block();
break;
}
profileBlock.setProfileBlocks(profileBlocks);
return new OpenWriteSessionMessage();
} else if (message instanceof OpenWriteSessionMessage) {
WriteConfigurationBlockMessage writeMessage = new WriteConfigurationBlockMessage();
writeMessage.setConfigurationBlock(profileBlock);
return writeMessage;
} else if (message instanceof WriteConfigurationBlockMessage) {
return new CloseWriteSessionMessage();
} else if (message instanceof CloseWriteSessionMessage) finish(null);
return null;
}
}

View file

@ -71,8 +71,8 @@ class HistoryIntentAdapter {
final long pump_serial_number = Long.parseLong(intent.getStringExtra(HistoryBroadcast.EXTRA_PUMP_SERIAL_NUMBER)); final long pump_serial_number = Long.parseLong(intent.getStringExtra(HistoryBroadcast.EXTRA_PUMP_SERIAL_NUMBER));
final Date event_time = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME); final Date event_time = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME);
final Date start_time = getDateExtra(intent, HistoryBroadcast.EXTRA_START_TIME); final Date start_time = getDateExtra(intent, HistoryBroadcast.EXTRA_START_TIME);
final float immediate_amount = intent.getFloatExtra(HistoryBroadcast.EXTRA_IMMEDIATE_AMOUNT, -1); final double immediate_amount = intent.getDoubleExtra(HistoryBroadcast.EXTRA_IMMEDIATE_AMOUNT, -1);
final float extended_insulin = intent.getFloatExtra(HistoryBroadcast.EXTRA_EXTENDED_AMOUNT, -1); final double extended_insulin = intent.getDoubleExtra(HistoryBroadcast.EXTRA_EXTENDED_AMOUNT, -1);
final int extended_minutes = intent.getIntExtra(HistoryBroadcast.EXTRA_DURATION, -1); final int extended_minutes = intent.getIntExtra(HistoryBroadcast.EXTRA_DURATION, -1);
final long record_unique_id = getRecordUniqueID(pump_serial_number, bolus_id > -1 ? bolus_id : pump_record_id); final long record_unique_id = getRecordUniqueID(pump_serial_number, bolus_id > -1 ? bolus_id : pump_record_id);

View file

@ -481,7 +481,7 @@ public class ActionStringHandler {
ret += "DEFAULT RANGE: "; ret += "DEFAULT RANGE: ";
ret += profile.getTargetLow() + " - " + profile.getTargetHigh(); ret += profile.getTargetLow() + " - " + profile.getTargetHigh();
ret += " target: " + (profile.getTargetLow() + profile.getTargetHigh()) / 2; ret += " target: " + profile.getTarget();
return ret; return ret;
} }

View file

@ -10,6 +10,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventBolusRequested; import info.nightscout.androidaps.events.EventBolusRequested;
import info.nightscout.androidaps.events.EventExtendedBolusChange; import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventLoop;
import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventNewBasalProfile; import info.nightscout.androidaps.events.EventNewBasalProfile;
import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPreferenceChange;
@ -18,6 +19,7 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTreatmentChange; import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning; import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.Wear.wearintegration.WatchUpdaterService; import info.nightscout.androidaps.plugins.Wear.wearintegration.WatchUpdaterService;
@ -168,6 +170,11 @@ public class WearPlugin implements PluginBase {
sendDataToWatch(true, true, false); sendDataToWatch(true, true, false);
} }
@Subscribe
public void onStatusEvent(final EventOpenAPSUpdateGui ev){
sendDataToWatch(true, true, false);
}
@Subscribe @Subscribe
public void onStatusEvent(final EventExtendedBolusChange ev) { public void onStatusEvent(final EventExtendedBolusChange ev) {
sendDataToWatch(true, true, false); sendDataToWatch(true, true, false);
@ -197,7 +204,7 @@ public class WearPlugin implements PluginBase {
@Subscribe @Subscribe
public void onStatusEvent(final EventOverviewBolusProgress ev) { public void onStatusEvent(final EventOverviewBolusProgress ev) {
if(!ev.isSMB()||SP.getBoolean("wear_notifySMB", false)) { if(!ev.isSMB()||SP.getBoolean("wear_notifySMB", true)) {
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS); Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS);
intent.putExtra("progresspercent", ev.percent); intent.putExtra("progresspercent", ev.percent);
intent.putExtra("progressstatus", ev.status); intent.putExtra("progressstatus", ev.status);
@ -251,11 +258,4 @@ public class WearPlugin implements PluginBase {
public static void unRegisterWatchUpdaterService() { public static void unRegisterWatchUpdaterService() {
watchUS = null; watchUS = null;
} }
public void overviewNotification(int id, String message) {
if(SP.getBoolean("wear_overview_notification", false)){
ActionStringHandler.expectNotificationAction(message, id);
}
}
} }

View file

@ -6,6 +6,8 @@ import android.content.IntentFilter;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.BatteryManager; import android.os.BatteryManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.util.Log; import android.util.Log;
@ -19,11 +21,15 @@ import com.google.android.gms.wearable.PutDataRequest;
import com.google.android.gms.wearable.Wearable; import com.google.android.gms.wearable.Wearable;
import com.google.android.gms.wearable.WearableListenerService; import com.google.android.gms.wearable.WearableListenerService;
import org.mozilla.javascript.tools.jsc.Main;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
@ -35,6 +41,7 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
@ -82,6 +89,7 @@ public class WatchUpdaterService extends WearableListenerService implements
private static Logger log = LoggerFactory.getLogger(WatchUpdaterService.class); private static Logger log = LoggerFactory.getLogger(WatchUpdaterService.class);
private Handler handler;
@Override @Override
public void onCreate() { public void onCreate() {
@ -91,6 +99,11 @@ public class WatchUpdaterService extends WearableListenerService implements
if (wear_integration) { if (wear_integration) {
googleApiConnect(); googleApiConnect();
} }
if (handler == null) {
HandlerThread handlerThread = new HandlerThread(this.getClass().getSimpleName() + "Handler");
handlerThread.start();
handler = new Handler(handlerThread.getLooper());
}
} }
public void listenForChangeInSettings() { public void listenForChangeInSettings() {
@ -123,34 +136,33 @@ public class WatchUpdaterService extends WearableListenerService implements
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
String action = null; String action = intent != null ? intent.getAction() : null;
if (intent != null) {
action = intent.getAction();
}
if (wear_integration) { if (wear_integration) {
if (googleApiClient.isConnected()) { handler.post(() -> {
if (ACTION_RESEND.equals(action)) { if (googleApiClient.isConnected()) {
resendData(); if (ACTION_RESEND.equals(action)) {
} else if (ACTION_OPEN_SETTINGS.equals(action)) { resendData();
sendNotification(); } else if (ACTION_OPEN_SETTINGS.equals(action)) {
} else if (ACTION_SEND_STATUS.equals(action)) { sendNotification();
sendStatus(); } else if (ACTION_SEND_STATUS.equals(action)) {
} else if (ACTION_SEND_BASALS.equals(action)) { sendStatus();
sendBasals(); } else if (ACTION_SEND_BASALS.equals(action)) {
} else if (ACTION_SEND_BOLUSPROGRESS.equals(action)) { sendBasals();
sendBolusProgress(intent.getIntExtra("progresspercent", 0), intent.hasExtra("progressstatus") ? intent.getStringExtra("progressstatus") : ""); } else if (ACTION_SEND_BOLUSPROGRESS.equals(action)) {
} else if (ACTION_SEND_ACTIONCONFIRMATIONREQUEST.equals(action)) { sendBolusProgress(intent.getIntExtra("progresspercent", 0), intent.hasExtra("progressstatus") ? intent.getStringExtra("progressstatus") : "");
String title = intent.getStringExtra("title"); } else if (ACTION_SEND_ACTIONCONFIRMATIONREQUEST.equals(action)) {
String message = intent.getStringExtra("message"); String title = intent.getStringExtra("title");
String actionstring = intent.getStringExtra("actionstring"); String message = intent.getStringExtra("message");
sendActionConfirmationRequest(title, message, actionstring); String actionstring = intent.getStringExtra("actionstring");
sendActionConfirmationRequest(title, message, actionstring);
} else {
sendData();
}
} else { } else {
sendData(); googleApiClient.connect();
} }
} else { });
googleApiClient.connect();
}
} }
return START_STICKY; return START_STICKY;
@ -345,11 +357,15 @@ public class WatchUpdaterService extends WearableListenerService implements
} }
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
long startTimeWindow = now - (long) (60000 * 60 * 5.5); final long startTimeWindow = now - (long) (60000 * 60 * 5.5);
ArrayList<DataMap> basals = new ArrayList<>(); ArrayList<DataMap> basals = new ArrayList<>();
ArrayList<DataMap> temps = new ArrayList<>(); ArrayList<DataMap> temps = new ArrayList<>();
ArrayList<DataMap> boluses = new ArrayList<>();
ArrayList<DataMap> predictions = new ArrayList<>();
Profile profile = MainApp.getConfigBuilder().getProfile(); Profile profile = MainApp.getConfigBuilder().getProfile();
@ -447,9 +463,31 @@ public class WatchUpdaterService extends WearableListenerService implements
} }
} }
List<Treatment> treatments = MainApp.getConfigBuilder().getTreatmentsFromHistory();
for (Treatment treatment:treatments) {
if(treatment.date > startTimeWindow){
boluses.add(treatmentMap(treatment.date, treatment.insulin, treatment.carbs, treatment.isSMB, treatment.isValid));
}
}
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
if(SP.getBoolean("wear_predictions", true) && finalLastRun != null && finalLastRun.request.hasPredictions && finalLastRun.constraintsProcessed != null){
List<BgReading> predArray = finalLastRun.constraintsProcessed.getPredictions();
if (!predArray.isEmpty()) {
for (BgReading bg : predArray) {
predictions.add(predictionMap(bg.date, bg.value));
}
}
}
DataMap dm = new DataMap(); DataMap dm = new DataMap();
dm.putDataMapArrayList("basals", basals); dm.putDataMapArrayList("basals", basals);
dm.putDataMapArrayList("temps", temps); dm.putDataMapArrayList("temps", temps);
dm.putDataMapArrayList("boluses", boluses);
dm.putDataMapArrayList("predictions", predictions);
new SendToDataLayerThread(BASAL_DATA_PATH, googleApiClient).execute(dm); new SendToDataLayerThread(BASAL_DATA_PATH, googleApiClient).execute(dm);
} }
@ -472,6 +510,23 @@ public class WatchUpdaterService extends WearableListenerService implements
return dm; return dm;
} }
private DataMap treatmentMap(long date, double bolus, double carbs, boolean isSMB, boolean isValid) {
DataMap dm = new DataMap();
dm.putLong("date", date);
dm.putDouble("bolus", bolus);
dm.putDouble("carbs", carbs);
dm.putBoolean("isSMB", isSMB);
dm.putBoolean("isValid", isValid);
return dm;
}
private DataMap predictionMap(long timestamp, double sgv) {
DataMap dm = new DataMap();
dm.putLong("timestamp", timestamp);
dm.putDouble("sgv", sgv);
return dm;
}
private void sendNotification() { private void sendNotification() {
if (googleApiClient.isConnected()) { if (googleApiClient.isConnected()) {

View file

@ -184,7 +184,7 @@ public class StatuslinePlugin implements PluginBase {
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis()); TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis());
if (activeTemp != null) { if (activeTemp != null) {
status += activeTemp.toStringShort(); status += activeTemp.toStringShort() + " ";
} }
//IOB //IOB

View file

@ -394,7 +394,9 @@
android:paddingRight="0dp" android:paddingRight="0dp"
android:text="@string/overview_treatment_label" android:text="@string/overview_treatment_label"
android:textColor="@color/colorTreatmentButton" android:textColor="@color/colorTreatmentButton"
android:textSize="10sp" /> android:textSize="10sp"
android:visibility="gone"/>
<info.nightscout.utils.SingleClickButton <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_insulinbutton" android:id="@+id/overview_insulinbutton"
@ -423,7 +425,8 @@
android:paddingRight="0dp" android:paddingRight="0dp"
android:text="@string/overview_carbs_label" android:text="@string/overview_carbs_label"
android:textColor="@color/colorCarbsButton" android:textColor="@color/colorCarbsButton"
android:textSize="10sp" /> android:textSize="10sp"
android:visibility="gone"/>
<info.nightscout.utils.SingleClickButton <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_wizardbutton" android:id="@+id/overview_wizardbutton"
@ -467,7 +470,8 @@
android:paddingRight="0dp" android:paddingRight="0dp"
android:text="@string/overview_cgm" android:text="@string/overview_cgm"
android:textColor="@color/colorCalibrationButton" android:textColor="@color/colorCalibrationButton"
android:textSize="10sp"/> android:textSize="10sp"
android:visibility="gone"/>
<info.nightscout.utils.SingleClickButton <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_quickwizardbutton" android:id="@+id/overview_quickwizardbutton"

View file

@ -34,23 +34,30 @@
<CheckBox <CheckBox
android:id="@+id/newcarbs_activity_tt" android:id="@+id/newcarbs_activity_tt"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:text="@string/start_activity_tt" />
<CheckBox
android:id="@+id/carbs_eating_soon_tt"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:text="Start activity TT"/> android:text="@string/start_eating_soon_tt" />
<CheckBox <CheckBox
android:id="@+id/newcarbs_suspend_loop" android:id="@+id/newcarbs_suspend_loop"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:text="Suspend loop for 30 min"/> android:text="@string/suspendloopfor30min" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="5dp" android:layout_gravity="center_horizontal"
android:layout_gravity="center_horizontal"> android:padding="5dp">
<TextView <TextView
android:id="@+id/newcarbs_eventdate" android:id="@+id/newcarbs_eventdate"
@ -76,7 +83,7 @@
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:width="180dp" android:width="180dp"
android:inputType="text|textCapWords" android:inputType="text|textCapWords"
android:visibility="gone"/> android:visibility="gone" />
<info.nightscout.utils.NumberPicker <info.nightscout.utils.NumberPicker
android:id="@+id/newcarb_carbsamount" android:id="@+id/newcarb_carbsamount"
@ -91,8 +98,8 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:layout_marginBottom="5dp"
android:layout_marginBottom="5dp"> android:orientation="horizontal">
<Button <Button
android:id="@+id/newcarbs_plus1" android:id="@+id/newcarbs_plus1"
@ -122,4 +129,4 @@
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</FrameLayout> </FrameLayout>

View file

@ -34,16 +34,16 @@
<CheckBox <CheckBox
android:id="@+id/newinsulin_start_eating_soon_tt" android:id="@+id/newinsulin_start_eating_soon_tt"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:text="Start eating soon TT" /> android:text="@string/start_eating_soon_tt" />
<CheckBox <CheckBox
android:id="@+id/newinsulin_record_only" android:id="@+id/newinsulin_record_only"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="Don't bolus, record only" /> android:text="@string/don_t_bolus_record_only" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -115,4 +115,4 @@
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</FrameLayout> </FrameLayout>

View file

@ -777,4 +777,96 @@
<string name="combo_read_full_history_confirmation">Opravdu chcete přečíst historii z pumpy a nést důsledky z toho vyplývající?</string> <string name="combo_read_full_history_confirmation">Opravdu chcete přečíst historii z pumpy a nést důsledky z toho vyplývající?</string>
<string name="combo_reservoir_level_insufficient_for_bolus">Nedostatek inzulínu pro takovýto bolus</string> <string name="combo_reservoir_level_insufficient_for_bolus">Nedostatek inzulínu pro takovýto bolus</string>
<string name="extendedbolusdeliveryerror">Chyba spuštění extended bolusu</string> <string name="extendedbolusdeliveryerror">Chyba spuštění extended bolusu</string>
<string name="smb_shortname">SMB</string>
<string name="openapssmb">OpenAPS SMB</string>
<string name="enableuam">Povolit UAM</string>
<string name="enablesmb">Povolit SMB</string>
<string name="enablesmb_summary">Použít super mikro bolusy místo dočasných bazálů pro zrychlení účinku</string>
<string name="enableuam_summary">Detekce neoznámených jídel</string>
<string name="insightpump_shortname">Insight</string>
<string name="insightpump">Pumpa Insight</string>
<string name="status_no_colon">Stav</string>
<string name="changed">Změněno</string>
<string name="pump_stopped_uppercase">PUMPA ZASTAVENA</string>
<string name="status_updated">Stav aktualizován</string>
<string name="ago">zpět</string>
<string name="with">s</string>
<string name="insight_active_tbr">Aktivní dočasný bazál</string>
<string name="insight_min_left">min zbývá</string>
<string name="log_book">Historie</string>
<string name="insight_last_completed_action">Poslední vykonaný příkaz</string>
<string name="insight_needs">potřebuje</string>
<string name="insight_startup_uppercase">SPOUŠTĚNÍ</string>
<string name="insight_history_synced">SYNCHRONIZOVÁNO</string>
<string name="insight_history_busy">ZANEPRÁZDNĚN</string>
<string name="insight_history_syncing">SYNCHRONIZUJI</string>
<string name="insight_history_idle">NEČINNÝ</string>
<string name="insight_actually_cancel_tbr_summary">Momentálně zruší dočasný bazál (spouští alarm na pumpě) místo nastavení 90% na 1 min</string>
<string name="insight_use_real_tbr_cancels">Použít skutečné ukončení dočasného bazálu</string>
<string name="insight_stay_always_connected">Zůstat stále připojený</string>
<string name="insight_not_connected_to_companion_app">Nepřipojen k podpůrné aplikaci!</string>
<string name="insight_companion_app_not_installed">Podpůrná aplikace patrně není nainstalovaná!</string>
<string name="insight_incompatible_compantion_app_we_need_version">Nekompatibilní podpůrná aplikace, je požadována verze</string>
<string name="insight_unknown">Neznámý</string>
<string name="insight_waiting_for_code">Čekám na potrvzení kódu</string>
<string name="insight_code_rejected">Kód odmítnut</string>
<string name="insight_app_binding">Připojování aplikace</string>
<string name="insight_not_authorized">Neautorizován</string>
<string name="insight_incompatible">Nekompatibilní</string>
<string name="second">sekund</string>
<string name="minute">minut</string>
<string name="hour">hodin</string>
<string name="day">dní</string>
<string name="week">týdnů</string>
<string name="time_plural">" "</string>
<string name="enablesmbalways">Vždy povolit SMB</string>
<string name="enablesmbwithcob">Povolit SMB se sacharidy</string>
<string name="enablesmbwithcob_summary">Povolit SMB, pokud zbývají aktivní sacharidy</string>
<string name="enablesmbwithtemptarget">Povolit SMB s dočasnými cíly</string>
<string name="enablesmbwithtemptarget_summary">Povolit SMB, pokud je aktivní dočasný cíl (aktivita, blížící se jídlo)</string>
<string name="enablesmbwithhightemptarget">Povolit SMB s vysokými dočasnými cíly</string>
<string name="enablesmbwithhightemptarget_summary">Povolit SMB, pokud je aktivní vysoký dočasný cíl (aktivita)</string>
<string name="enablesmbaftercarbs">Povolit SMB po jídle</string>
<string name="enablesmbalways_summary">Povolit SMB nezávisle na bolusech. Možno pouze se zdroji glykémií s dobrým filtrováním dat, jako např. G5</string>
<string name="enablesmbaftercarbs_summary">Povolit SMB 6 hodin po bolusu i při nulovém COB. Možno pouze se zdroji glykémií s dobrým filtrováním dat, jako např. G5</string>
<string name="fr_lang">Francouzština</string>
<string name="ro_lang">Rumunština</string>
<string name="zh_lang">Čínština</string>
<string name="resistantadult">Dospělý s nízkou citlivostí</string>
<string name="combopump">Accu-Chek Combo</string>
<string name="combopump_shortname">COMBO</string>
<string name="insight_keepalive_format_string">%d vyprší %s</string>
<string name="insight_keep_alive_status">Stav keep-alive</string>
<string name="statistics">Statistika</string>
<string name="connect_preemptively">Připojování dopředu</string>
<string name="automatically_connect_when">Automaticky připojit při otevření obrazovky AndroidAPS, dříve než dojde k poslání příkazu, aby se omezila doba připojování</string>
<string name="not_recommended_due_to_battery_drain">Nedoporučeno kvůli vybíjení baterie</string>
<string name="let_temp_basal_run">Nechat běžet aktuální dočasný bazál</string>
<string name="mute">Ztlumit</string>
<string name="overview_insulin_label">Inzulín</string>
<string name="overview_carbs_label">Sacharidy</string>
<string name="overview_buttons_selection">Tlačítka</string>
<string name="show_calibration_button_summary">Odeslání kalibrace do xDripu+, nebo otevření kalibračního dialogu na G5</string>
<string name="show_cgm_button_summary">Otevře xDrip+, tlačítko zpět vrátí do AndroidAPS</string>
<string name="carb_increment_button_message">Množství sacharidů přidané po stisknutí tlačítka</string>
<string name="insulin_increment_button_message">Množství inzulínu přidané po stisknutí tlačítka</string>
<string name="error_starting_cgm">Nelze spustit aplikace CGM. Ujistěte se, že je nainstalovaná</string>
<string name="overview_cgm">CGM</string>
<string name="nav_historybrowser">Prohlížeč historie</string>
<string name="wear_notifysmb_title">Oznámení při SMB</string>
<string name="wear_notifysmb_summary">Ukazovat SMB na hodinkách jako normální bolus</string>
<string name="ns_create_announcements_from_errors_title">Vytvořit oznámení pro chyby</string>
<string name="ns_create_announcements_from_errors_summary">Vytvořit oznámení v NS pro chyby a místní výstrahy (zobrazitelné v Péči pod Ošetřením)</string>
<string name="wear_predictions_summary">Zobrazovat predikce na hodinkách</string>
<string name="wear_predictions_title">Predikce</string>
<string name="data_choices">Možnosti dat</string>
<string name="fabric_upload">Odesílání do Fabric</string>
<string name="allow_automated_crash_reporting">Automatické odesílání chyb aplikace a statistiky používání vývojářům pomocí služby fabric.io</string>
<string name="g5appnotdetected">Prosím aktualizujte G5 aplikaci na podporovanou verzi</string>
<string name="suspendloopfor30min">Pozastavit na 30 min</string>
<string name="start_activity_tt">Spustit Dočasný cíl Aktivita</string>
<string name="start_eating_soon_tt">Spustit Dočasný cíl Blížící se jídlo</string>
<string name="temptargetshort">DoCíl</string>
<string name="insight_min">min</string>
<string name="don_t_bolus_record_only">Nepouštět bolus, jen zaznamenat</string>
</resources> </resources>

View file

@ -375,7 +375,7 @@
<string name="tempbasaldeliveryerror">TBR Abgabe-Fehler</string> <string name="tempbasaldeliveryerror">TBR Abgabe-Fehler</string>
<string name="temptarget">Temporäres Ziel</string> <string name="temptarget">Temporäres Ziel</string>
<string name="timeshift_hint">Zeit in Stunden, um die das Profil verschoben wird.</string> <string name="timeshift_hint">Zeit in Stunden, um die das Profil verschoben wird.</string>
<string name="treatments_wizard_bgtrend_label">15-Min.-Trend</string> <string name="treatments_wizard_bgtrend_label">15\'-Trend</string>
<string name="treatments_wizard_cob_label">COB</string> <string name="treatments_wizard_cob_label">COB</string>
<string name="unsupportednsversion">Nicht unterstütze Nightscout-Version</string> <string name="unsupportednsversion">Nicht unterstütze Nightscout-Version</string>
<string name="uploader">Uploader</string> <string name="uploader">Uploader</string>

View file

@ -389,7 +389,6 @@
<string name="smscommunicator_calibrationreplywithcode" formatted="false">Para enviar calibracion %.2f responder con código %s</string> <string name="smscommunicator_calibrationreplywithcode" formatted="false">Para enviar calibracion %.2f responder con código %s</string>
<string name="bolusrequested" formatted="false">Entregaré %.2fU</string> <string name="bolusrequested" formatted="false">Entregaré %.2fU</string>
<string name="danarprofile_dia_summary">Duración de acitividad de insulina</string> <string name="danarprofile_dia_summary">Duración de acitividad de insulina</string>
<string name="pump_errors_history">Errores</string>
<string name="objectives_7_objective">habilitar funciones adicionales para uso durante el día como SMB</string> <string name="objectives_7_objective">habilitar funciones adicionales para uso durante el día como SMB</string>
<string name="valuelimitedto" formatted="false">%.2f limitado a %.2f</string> <string name="valuelimitedto" formatted="false">%.2f limitado a %.2f</string>
<string name="smscommunicator_remotecommandnotallowed">no permitido el mando remoto</string> <string name="smscommunicator_remotecommandnotallowed">no permitido el mando remoto</string>

View file

@ -50,11 +50,7 @@
<string name="treatments_wizard_total_label">TOTAL</string> <string name="treatments_wizard_total_label">TOTAL</string>
<string name="openapsma_run">Fă acum</string> <string name="openapsma_run">Fă acum</string>
<string name="vitualpump_label">POMPĂ VIRTUALĂ</string> <string name="vitualpump_label">POMPĂ VIRTUALĂ</string>
<string name="virtualpump_basebasalrate_label">Rata bazală normală</string>
<string name="virtualpump_tempbasal_label">Bazală temporară</string>
<string name="virtualpump_extendedbolus_label">Bolus extins</string> <string name="virtualpump_extendedbolus_label">Bolus extins</string>
<string name="virtualpump_battery_label">Baterie</string>
<string name="virtualpump_reservoir_label">Rezervor</string>
<string name="virtualpump_resultok">OK</string> <string name="virtualpump_resultok">OK</string>
<string name="virtualpump_sqlerror">Eroare SQL</string> <string name="virtualpump_sqlerror">Eroare SQL</string>
<string name="openapsma_lastrun_label">Ultima acțiune</string> <string name="openapsma_lastrun_label">Ultima acțiune</string>
@ -64,13 +60,11 @@
<string name="openapsma_iobdata_label">Date IOB</string> <string name="openapsma_iobdata_label">Date IOB</string>
<string name="openapsma_profile_label">Profil</string> <string name="openapsma_profile_label">Profil</string>
<string name="openapsma_mealdata_label">Date despre masă</string> <string name="openapsma_mealdata_label">Date despre masă</string>
<string name="openapsma_result_label">Rezultat</string>
<string name="openapsma_noglucosedata">Nu există date despre glicemie</string> <string name="openapsma_noglucosedata">Nu există date despre glicemie</string>
<string name="openapsma_noprofile">Niciun profil disponibil</string> <string name="openapsma_noprofile">Niciun profil disponibil</string>
<string name="openapsma_nopump">Nicio pompă disponibilă</string> <string name="openapsma_nopump">Nicio pompă disponibilă</string>
<string name="nochangerequested">Nu este solicitată nicio schimbare</string> <string name="nochangerequested">Nu este solicitată nicio schimbare</string>
<string name="openapsma_request_label">Solicită</string> <string name="openapsma_request_label">Solicită</string>
<string name="openapsma_minbg_label">Ținta de jos</string>
<string name="rate">Rată</string> <string name="rate">Rată</string>
<string name="duration">Durată</string> <string name="duration">Durată</string>
<string name="reason">Motiv</string> <string name="reason">Motiv</string>
@ -85,7 +79,6 @@
<string name="overview">Privire ansamblu</string> <string name="overview">Privire ansamblu</string>
<string name="profileviewer">Profil NS</string> <string name="profileviewer">Profil NS</string>
<string name="simpleprofile">Profil simplu</string> <string name="simpleprofile">Profil simplu</string>
<string name="tempbasals">Bazale temporare</string>
<string name="treatments">Tratamente</string> <string name="treatments">Tratamente</string>
<string name="virtualpump">Pompă virtuală</string> <string name="virtualpump">Pompă virtuală</string>
<string name="careportal">Careportal</string> <string name="careportal">Careportal</string>
@ -369,7 +362,6 @@
<string name="percentagefactor_hint">Procentul factorului cu care profilul bazal va fi mărit.</string> <string name="percentagefactor_hint">Procentul factorului cu care profilul bazal va fi mărit.</string>
Time in hours by which the profile will be shifted round robin.</string> Time in hours by which the profile will be shifted round robin.</string>
<string name="timeshift_hint">Timpul în ore în care profilul va fi rotunjit prin metoda round-robin</string> <string name="timeshift_hint">Timpul în ore în care profilul va fi rotunjit prin metoda round-robin</string>
<string name="send_to_pump">TRIMITE CĂTRE POMPĂ</string>
<string name="units">Unități:</string> <string name="units">Unități:</string>
<string name="mgdl">mg/dl</string> <string name="mgdl">mg/dl</string>
<string name="mmol">mmol/l</string> <string name="mmol">mmol/l</string>
@ -379,8 +371,6 @@
<string name="edit_base_isf">Editează ISF normal:</string> <string name="edit_base_isf">Editează ISF normal:</string>
<string name="edit_base_ic">Editează IC normal:</string> <string name="edit_base_ic">Editează IC normal:</string>
<string name="base_profile_label">Profilul de bază:</string> <string name="base_profile_label">Profilul de bază:</string>
<string name="androidaps_tempbasalendnote">Sfârșit bazală temporară</string>
<string name="androidaps_tempbasalstartnote">Început bazală temporară</string>
<string name="prefs_range_title">Intervalul pentru vizualizare</string> <string name="prefs_range_title">Intervalul pentru vizualizare</string>
<string name="prefs_range_summary">Valoarea maximă și minimă pentru graficele din vizualizare și pentru smartwatch</string> <string name="prefs_range_summary">Valoarea maximă și minimă pentru graficele din vizualizare și pentru smartwatch</string>
<string name="low_mark">Pragul HIPO</string> <string name="low_mark">Pragul HIPO</string>
@ -393,7 +383,6 @@
<string name="pumpshutdown">Pompa se oprește</string> <string name="pumpshutdown">Pompa se oprește</string>
<string name="batterydischarged">Bateria pompei este descărcată</string> <string name="batterydischarged">Bateria pompei este descărcată</string>
<string name="danarkoreanpump">DanaR Korean</string> <string name="danarkoreanpump">DanaR Korean</string>
<string name="wrongpumpdriverselected">Driver de pompă selectat greșit</string>
<string name="basal_rate">Rată bazală:</string> <string name="basal_rate">Rată bazală:</string>
<string name="profile_set_failed">Setarea profilului bazalei a eșuat</string> <string name="profile_set_failed">Setarea profilului bazalei a eșuat</string>
<string name="profile_set_ok">Profilul bazalei a fost modificat în pompă</string> <string name="profile_set_ok">Profilul bazalei a fost modificat în pompă</string>
@ -417,8 +406,6 @@
<string name="openapsma_autosensdata_label">Date Autosens</string> <string name="openapsma_autosensdata_label">Date Autosens</string>
<string name="openapsma_scriptdebugdata_label">Script debug</string> <string name="openapsma_scriptdebugdata_label">Script debug</string>
<string name="openapsama_useautosens">Folosește opțiunea autosens AMA</string> <string name="openapsama_useautosens">Folosește opțiunea autosens AMA</string>
<string name="temptargetrange">Țintă temporară</string>
<string name="temptargetrange_refreshfromnightscout">Reîncarcă țintele temporare din NS</string>
<string name="eatingsoon">Masă în curând</string> <string name="eatingsoon">Masă în curând</string>
<string name="activity">Activitate</string> <string name="activity">Activitate</string>
<string name="removerecord">Șterge înregistrarea:</string> <string name="removerecord">Șterge înregistrarea:</string>
@ -573,7 +560,6 @@
<string name="predictionshortlabel">PRE</string> <string name="predictionshortlabel">PRE</string>
<string name="basalshortlabel">BAS</string> <string name="basalshortlabel">BAS</string>
<string name="virtualpump_firmware_label">Firmware</string> <string name="virtualpump_firmware_label">Firmware</string>
<string name="virtualpump_lastconnection_label">Ultima conectare</string>
<string name="danar_bluetooth_status">Status bluetooth</string> <string name="danar_bluetooth_status">Status bluetooth</string>
<string name="nav_about">Despre</string> <string name="nav_about">Despre</string>
<string name="smscommunicator_missingsmspermission">Lipsesc permisiunile de SMS</string> <string name="smscommunicator_missingsmspermission">Lipsesc permisiunile de SMS</string>

View file

@ -965,9 +965,16 @@
<string name="ns_create_announcements_from_errors_title">Create announcements from errors</string> <string name="ns_create_announcements_from_errors_title">Create announcements from errors</string>
<string name="ns_create_announcements_from_errors_summary">Create Nightscout announcement for error dialogs and local alerts (also viewable in Careportal under Treatments)</string> <string name="ns_create_announcements_from_errors_summary">Create Nightscout announcement for error dialogs and local alerts (also viewable in Careportal under Treatments)</string>
<string name="dexcomG5_shortname" translatable="false">G5</string> <string name="dexcomG5_shortname" translatable="false">G5</string>
<string name="wear_predictions_summary">Show the predictions on the watchface.</string>
<string name="wear_predictions_title">Predictions</string>
<string name="data_choices">Data Choices</string> <string name="data_choices">Data Choices</string>
<string name="fabric_upload">Fabric Upload</string> <string name="fabric_upload">Fabric Upload</string>
<string name="allow_automated_crash_reporting">Allow automated crash reporting and feature usage data to be sent to the developers via the fabric.io service.</string> <string name="allow_automated_crash_reporting">Allow automated crash reporting and feature usage data to be sent to the developers via the fabric.io service.</string>
<string name="g5appnotdetected">Please update your G5 app to supported version</string> <string name="g5appnotdetected">Please update your G5 app to supported version</string>
<string name="suspendloopfor30min">Suspend for 30 min</string>
<string name="start_activity_tt">Start Activity TT</string>
<string name="start_eating_soon_tt">Start Eating soon TT</string>
<string name="temptargetshort">TT</string>
<string name="don_t_bolus_record_only">Don\'t bolus, record only</string>
</resources> </resources>

View file

@ -7,7 +7,7 @@
<com.andreabaccega.widget.ValidatingEditTextPreference <com.andreabaccega.widget.ValidatingEditTextPreference
validate:testType="floatNumericRange" validate:testType="floatNumericRange"
validate:floatminNumber="0.1" validate:floatminNumber="0.1"
validate:floatmaxNumber="5.0" validate:floatmaxNumber="12.0"
android:defaultValue="3.0" android:defaultValue="3.0"
android:selectAllOnFocus="true" android:selectAllOnFocus="true"
android:singleLine="true" android:singleLine="true"

View file

@ -32,10 +32,16 @@
android:title="@string/wear_showbgi_title" /> android:title="@string/wear_showbgi_title" />
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="true"
android:key="wear_notifySMB" android:key="wear_notifySMB"
android:summary="@string/wear_notifysmb_summary" android:summary="@string/wear_notifysmb_summary"
android:title="@string/wear_notifysmb_title" /> android:title="@string/wear_notifysmb_title" />
<SwitchPreference
android:defaultValue="true"
android:key="wear_predictions"
android:summary="@string/wear_predictions_summary"
android:title="@string/wear_predictions_title" />
</PreferenceScreen> </PreferenceScreen>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View file

@ -16,6 +16,10 @@ public class BgWatchData implements Comparable<BgWatchData>{
this.timestamp = aTimestamp; this.timestamp = aTimestamp;
} }
public BgWatchData(){
}
@Override @Override
public boolean equals(Object that){ public boolean equals(Object that){
if(! (that instanceof BgWatchData)){ if(! (that instanceof BgWatchData)){

View file

@ -0,0 +1,13 @@
package info.nightscout.androidaps.data;
/**
* Created by adrian on 17/11/16.
*/
public class BolusWatchData {
public long date;
public double bolus;
public double carbs;
public boolean isSMB;
public boolean isValid;
}

View file

@ -22,6 +22,7 @@ import android.support.v4.content.LocalBroadcastManager;
import android.support.wearable.view.WatchViewStub; import android.support.wearable.view.WatchViewStub;
import android.support.wearable.watchface.WatchFaceStyle; import android.support.wearable.watchface.WatchFaceStyle;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.view.Display; import android.view.Display;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -32,18 +33,18 @@ import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import com.google.android.gms.wearable.DataMap; import com.google.android.gms.wearable.DataMap;
import com.ustwo.clockwise.wearable.WatchFace;
import com.ustwo.clockwise.common.WatchFaceTime; import com.ustwo.clockwise.common.WatchFaceTime;
import com.ustwo.clockwise.common.WatchMode; import com.ustwo.clockwise.common.WatchMode;
import com.ustwo.clockwise.common.WatchShape; import com.ustwo.clockwise.common.WatchShape;
import com.ustwo.clockwise.wearable.WatchFace;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.BasalWatchData; import info.nightscout.androidaps.data.BasalWatchData;
import info.nightscout.androidaps.data.BgWatchData; import info.nightscout.androidaps.data.BgWatchData;
import info.nightscout.androidaps.data.BolusWatchData;
import info.nightscout.androidaps.data.ListenerService; import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.TempWatchData; import info.nightscout.androidaps.data.TempWatchData;
import info.nightscout.androidaps.interaction.menus.MainMenuActivity; import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
import lecho.lib.hellocharts.view.LineChartView; import lecho.lib.hellocharts.view.LineChartView;
@ -53,6 +54,7 @@ import lecho.lib.hellocharts.view.LineChartView;
*/ */
public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener { public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {
public final static IntentFilter INTENT_FILTER; public final static IntentFilter INTENT_FILTER;
public static final int SCREENSIZE_SMALL = 280;
public TextView mTime, mSgv, mTimestamp, mDelta, mAvgDelta; public TextView mTime, mSgv, mTimestamp, mDelta, mAvgDelta;
public RelativeLayout mRelativeLayout; public RelativeLayout mRelativeLayout;
public long sgvLevel = 0; public long sgvLevel = 0;
@ -64,6 +66,8 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
public int gridColour = Color.WHITE; public int gridColour = Color.WHITE;
public int basalBackgroundColor = Color.BLUE; public int basalBackgroundColor = Color.BLUE;
public int basalCenterColor = Color.BLUE; public int basalCenterColor = Color.BLUE;
public int bolusColor = Color.MAGENTA;
public int carbsColor = Color.GREEN;
public int pointSize = 2; public int pointSize = 2;
public boolean lowResMode = false; public boolean lowResMode = false;
public boolean layoutSet = false; public boolean layoutSet = false;
@ -73,6 +77,9 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
public ArrayList<BgWatchData> bgDataList = new ArrayList<>(); public ArrayList<BgWatchData> bgDataList = new ArrayList<>();
public ArrayList<TempWatchData> tempWatchDataList = new ArrayList<>(); public ArrayList<TempWatchData> tempWatchDataList = new ArrayList<>();
public ArrayList<BasalWatchData> basalWatchDataList = new ArrayList<>(); public ArrayList<BasalWatchData> basalWatchDataList = new ArrayList<>();
public ArrayList<BolusWatchData> bolusWatchDataList = new ArrayList<>();
public ArrayList<BgWatchData> predictionList = new ArrayList<>();
public PowerManager.WakeLock wakeLock; public PowerManager.WakeLock wakeLock;
public View layoutView; public View layoutView;
private final Point displaySize = new Point(); private final Point displaySize = new Point();
@ -88,6 +95,8 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
private String batteryString = "--"; private String batteryString = "--";
private String sgvString = "--"; private String sgvString = "--";
private String externalStatusString = "no status"; private String externalStatusString = "no status";
private String cobString = "";
private TextView statusView; private TextView statusView;
private long chartTapTime = 0l; private long chartTapTime = 0l;
private long sgvTapTime = 0l; private long sgvTapTime = 0l;
@ -108,7 +117,12 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
.getDefaultSharedPreferences(this); .getDefaultSharedPreferences(this);
sharedPrefs.registerOnSharedPreferenceChangeListener(this); sharedPrefs.registerOnSharedPreferenceChangeListener(this);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layoutView = inflater.inflate(R.layout.activity_bigchart, null); DisplayMetrics metrics = getResources().getDisplayMetrics();
if(metrics.widthPixels < SCREENSIZE_SMALL || metrics.heightPixels < SCREENSIZE_SMALL){
layoutView = inflater.inflate(R.layout.activity_bigchart_small, null);
} else {
layoutView = inflater.inflate(R.layout.activity_bigchart, null);
}
performViewSetup(); performViewSetup();
} }
@ -341,6 +355,8 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
DataMap dataMap = DataMap.fromBundle(bundle); DataMap dataMap = DataMap.fromBundle(bundle);
wakeLock.acquire(50); wakeLock.acquire(50);
externalStatusString = dataMap.getString("externalStatusString"); externalStatusString = dataMap.getString("externalStatusString");
cobString = dataMap.getString("cob");
showAgeAndStatus(); showAgeAndStatus();
@ -392,6 +408,29 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
basalWatchDataList.add(bwd); basalWatchDataList.add(bwd);
} }
} }
ArrayList<DataMap> boluses = dataMap.getDataMapArrayList("boluses");
if (boluses != null) {
bolusWatchDataList = new ArrayList<>();
for (DataMap bolus : boluses) {
BolusWatchData bwd = new BolusWatchData();
bwd.date = bolus.getLong("date");
bwd.bolus = bolus.getDouble("bolus");
bwd.carbs = bolus.getDouble("carbs");
bwd.isSMB = bolus.getBoolean("isSMB");
bwd.isValid = bolus.getBoolean("isValid");
bolusWatchDataList.add(bwd);
}
}
ArrayList<DataMap> predictions = dataMap.getDataMapArrayList("predictions");
if (boluses != null) {
predictionList = new ArrayList<>();
for (DataMap prediction : predictions) {
BgWatchData bwd = new BgWatchData();
bwd.timestamp = prediction.getLong("timestamp");
bwd.sgv = prediction.getDouble("sgv");
predictionList.add(bwd);
}
}
} }
private void showAgeAndStatus() { private void showAgeAndStatus() {
@ -410,7 +449,12 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
} }
if(showStatus){ if(showStatus){
statusView.setText(externalStatusString); String status = externalStatusString;
if (sharedPrefs.getBoolean("show_cob", true)) {
status = externalStatusString + " " + cobString;
}
statusView.setText(status);
statusView.setVisibility(View.VISIBLE); statusView.setVisibility(View.VISIBLE);
} else { } else {
statusView.setVisibility(View.GONE); statusView.setVisibility(View.GONE);
@ -634,9 +678,9 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3")); int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
if (lowResMode) { if (lowResMode) {
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, gridColour, basalBackgroundColor, basalCenterColor, timeframe); bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, predictionList, tempWatchDataList, basalWatchDataList, bolusWatchDataList, pointSize, midColor, gridColour, basalBackgroundColor, basalCenterColor, bolusColor, carbsColor, timeframe);
} else { } else {
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, gridColour, basalBackgroundColor, basalCenterColor, timeframe); bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, predictionList, tempWatchDataList, basalWatchDataList, bolusWatchDataList, pointSize, highColor, lowColor, midColor, gridColour, basalBackgroundColor, basalCenterColor, bolusColor, carbsColor, timeframe);
} }
chart.setLineChartData(bgGraphBuilder.lineData()); chart.setLineChartData(bgGraphBuilder.lineData());
@ -646,4 +690,4 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
ListenerService.requestData(this); ListenerService.requestData(this);
} }
} }
} }

View file

@ -66,6 +66,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
public int gridColor = Color.WHITE; public int gridColor = Color.WHITE;
public int basalBackgroundColor = Color.BLUE; public int basalBackgroundColor = Color.BLUE;
public int basalCenterColor = Color.BLUE; public int basalCenterColor = Color.BLUE;
public int bolusColor = Color.MAGENTA;
public boolean lowResMode = false; public boolean lowResMode = false;
public boolean layoutSet = false; public boolean layoutSet = false;
public boolean bIsRound = false; public boolean bIsRound = false;
@ -75,6 +76,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
public ArrayList<BgWatchData> bgDataList = new ArrayList<>(); public ArrayList<BgWatchData> bgDataList = new ArrayList<>();
public ArrayList<TempWatchData> tempWatchDataList = new ArrayList<>(); public ArrayList<TempWatchData> tempWatchDataList = new ArrayList<>();
public ArrayList<BasalWatchData> basalWatchDataList = new ArrayList<>(); public ArrayList<BasalWatchData> basalWatchDataList = new ArrayList<>();
public ArrayList<BgWatchData> predictionList = new ArrayList<>();
public PowerManager.WakeLock wakeLock; public PowerManager.WakeLock wakeLock;
// related endTime manual layout // related endTime manual layout
public View layoutView; public View layoutView;
@ -628,9 +630,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3")); int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
if (lowResMode) { if (lowResMode) {
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, gridColor, basalBackgroundColor, basalCenterColor, timeframe); bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, predictionList, tempWatchDataList, basalWatchDataList, null, pointSize, midColor, gridColor, basalBackgroundColor, basalCenterColor, bolusColor, Color.GREEN, timeframe);
} else { } else {
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, gridColor, basalBackgroundColor, basalCenterColor, timeframe); bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList,predictionList, tempWatchDataList, basalWatchDataList, null, pointSize, highColor, lowColor, midColor, gridColor, basalBackgroundColor, basalCenterColor, bolusColor, Color.GREEN, timeframe);
} }
chart.setLineChartData(bgGraphBuilder.lineData()); chart.setLineChartData(bgGraphBuilder.lineData());

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.watchfaces; package info.nightscout.androidaps.watchfaces;
import android.content.Context; import android.content.Context;
import android.graphics.Color;
import android.graphics.DashPathEffect; import android.graphics.DashPathEffect;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.format.DateFormat; import android.text.format.DateFormat;
@ -8,13 +9,13 @@ import android.text.format.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import info.nightscout.androidaps.data.BasalWatchData; import info.nightscout.androidaps.data.BasalWatchData;
import info.nightscout.androidaps.data.BgWatchData; import info.nightscout.androidaps.data.BgWatchData;
import info.nightscout.androidaps.data.BolusWatchData;
import info.nightscout.androidaps.data.TempWatchData; import info.nightscout.androidaps.data.TempWatchData;
import lecho.lib.hellocharts.model.Axis; import lecho.lib.hellocharts.model.Axis;
import lecho.lib.hellocharts.model.AxisValue; import lecho.lib.hellocharts.model.AxisValue;
@ -27,6 +28,10 @@ import lecho.lib.hellocharts.model.Viewport;
* Created by emmablack on 11/15/14. * Created by emmablack on 11/15/14.
*/ */
public class BgGraphBuilder { public class BgGraphBuilder {
public static final double MAX_PREDICTION__TIME_RATIO = (3d / 5);
private long predictionEndTime;
private List<BgWatchData> predictionsList;
private ArrayList<BolusWatchData> bolusWatchDataList;
private ArrayList<BasalWatchData> basalWatchDataList; private ArrayList<BasalWatchData> basalWatchDataList;
public List<TempWatchData> tempWatchDataList; public List<TempWatchData> tempWatchDataList;
private int timespan; private int timespan;
@ -45,9 +50,11 @@ public class BgGraphBuilder {
public int gridColour; public int gridColour;
public int basalCenterColor; public int basalCenterColor;
public int basalBackgroundColor; public int basalBackgroundColor;
private int bolusInvalidColor;
private int carbsColor;
public boolean singleLine = false; public boolean singleLine = false;
private long endHour;
private List<PointValue> inRangeValues = new ArrayList<PointValue>(); private List<PointValue> inRangeValues = new ArrayList<PointValue>();
private List<PointValue> highValues = new ArrayList<PointValue>(); private List<PointValue> highValues = new ArrayList<PointValue>();
private List<PointValue> lowValues = new ArrayList<PointValue>(); private List<PointValue> lowValues = new ArrayList<PointValue>();
@ -55,10 +62,10 @@ public class BgGraphBuilder {
//used for low resolution screen. //used for low resolution screen.
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) { public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<BgWatchData> predictionsList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> bolusWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusInvalidColor, int carbsColor, int timespan) {
end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.) this.start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago
start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago
this.bgDataList = aBgList; this.bgDataList = aBgList;
this.predictionsList = predictionsList;
this.context = context; this.context = context;
this.highMark = aBgList.get(aBgList.size() - 1).high; this.highMark = aBgList.get(aBgList.size() - 1).high;
this.lowMark = aBgList.get(aBgList.size() - 1).low; this.lowMark = aBgList.get(aBgList.size() - 1).low;
@ -70,15 +77,21 @@ public class BgGraphBuilder {
this.timespan = timespan; this.timespan = timespan;
this.tempWatchDataList = tempWatchDataList; this.tempWatchDataList = tempWatchDataList;
this.basalWatchDataList = basalWatchDataList; this.basalWatchDataList = basalWatchDataList;
this.bolusWatchDataList = (bolusWatchDataList!=null)?bolusWatchDataList:new ArrayList<BolusWatchData>();
this.gridColour = gridColour; this.gridColour = gridColour;
this.basalCenterColor = basalCenterColor; this.basalCenterColor = basalCenterColor;
this.basalBackgroundColor = basalBackgroundColor; this.basalBackgroundColor = basalBackgroundColor;
this.bolusInvalidColor = bolusInvalidColor;
this.carbsColor = carbsColor;
this.end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.)
this.predictionEndTime = getPredictionEndTime();
this.end_time = (predictionEndTime>end_time)?predictionEndTime:end_time;
} }
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) { public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<BgWatchData> predictionsList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> bolusWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusInvalidColor, int carbsColor, int timespan) {
end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.) this.start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago
start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago
this.bgDataList = aBgList; this.bgDataList = aBgList;
this.predictionsList = predictionsList;
this.context = context; this.context = context;
this.highMark = aBgList.get(aBgList.size() - 1).high; this.highMark = aBgList.get(aBgList.size() - 1).high;
this.lowMark = aBgList.get(aBgList.size() - 1).low; this.lowMark = aBgList.get(aBgList.size() - 1).low;
@ -89,9 +102,15 @@ public class BgGraphBuilder {
this.timespan = timespan; this.timespan = timespan;
this.tempWatchDataList = tempWatchDataList; this.tempWatchDataList = tempWatchDataList;
this.basalWatchDataList = basalWatchDataList; this.basalWatchDataList = basalWatchDataList;
this.bolusWatchDataList = (bolusWatchDataList!=null)?bolusWatchDataList:new ArrayList<BolusWatchData>();
this.gridColour = gridColour; this.gridColour = gridColour;
this.basalCenterColor = basalCenterColor; this.basalCenterColor = basalCenterColor;
this.basalBackgroundColor = basalBackgroundColor; this.basalBackgroundColor = basalBackgroundColor;
this.bolusInvalidColor = bolusInvalidColor;
this.carbsColor = carbsColor;
this.end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.)
this.predictionEndTime = getPredictionEndTime();
this.end_time = (predictionEndTime>end_time)?predictionEndTime:end_time;
} }
public LineChartData lineData() { public LineChartData lineData() {
@ -102,6 +121,7 @@ public class BgGraphBuilder {
} }
public List<Line> defaultLines() { public List<Line> defaultLines() {
addBgReadingValues(); addBgReadingValues();
List<Line> lines = new ArrayList<Line>(); List<Line> lines = new ArrayList<Line>();
lines.add(highLine()); lines.add(highLine());
@ -154,6 +174,12 @@ public class BgGraphBuilder {
} }
lines.add(basalLine((float) minChart, factor, highlight)); lines.add(basalLine((float) minChart, factor, highlight));
lines.add(bolusLine((float) minChart));
lines.add(bolusInvalidLine((float) minChart));
lines.add(carbsLine((float) minChart));
lines.add(smbLine((float) minChart));
lines.add(predictionLine());
return lines; return lines;
} }
@ -180,6 +206,98 @@ public class BgGraphBuilder {
} }
private Line bolusLine(float offset) {
List<PointValue> pointValues = new ArrayList<PointValue>();
for (BolusWatchData bwd: bolusWatchDataList) {
if(bwd.date > start_time && bwd.date <= end_time && !bwd.isSMB && bwd.isValid && bwd.bolus > 0) {
pointValues.add(new PointValue(fuzz(bwd.date), (float) offset-2));
}
}
Line line = new Line(pointValues);
line.setColor(basalCenterColor);
line.setHasLines(false);
line.setPointRadius(pointSize*2);
line.setHasPoints(true);
return line;
}
private Line smbLine(float offset) {
List<PointValue> pointValues = new ArrayList<PointValue>();
for (BolusWatchData bwd: bolusWatchDataList) {
if(bwd.date > start_time && bwd.date <= end_time && bwd.isSMB && bwd.isValid && bwd.bolus > 0) {
pointValues.add(new PointValue(fuzz(bwd.date), (float) offset-2));
}
}
Line line = new Line(pointValues);
line.setColor(basalCenterColor);
line.setHasLines(false);
line.setPointRadius(pointSize);
line.setHasPoints(true);
return line;
}
private Line bolusInvalidLine(float offset) {
List<PointValue> pointValues = new ArrayList<PointValue>();
for (BolusWatchData bwd: bolusWatchDataList) {
if(bwd.date > start_time && bwd.date <= end_time && !(bwd.isValid && (bwd.bolus > 0 || bwd.carbs > 0))) {
pointValues.add(new PointValue(fuzz(bwd.date), (float) offset-2));
}
}
Line line = new Line(pointValues);
line.setColor(bolusInvalidColor);
line.setHasLines(false);
line.setPointRadius(pointSize);
line.setHasPoints(true);
return line;
}
private Line carbsLine(float offset) {
List<PointValue> pointValues = new ArrayList<PointValue>();
for (BolusWatchData bwd: bolusWatchDataList) {
if(bwd.date > start_time && bwd.date <= end_time && !bwd.isSMB && bwd.isValid && bwd.carbs > 0) {
pointValues.add(new PointValue(fuzz(bwd.date), (float) offset+2));
}
}
Line line = new Line(pointValues);
line.setColor(carbsColor);
line.setHasLines(false);
line.setPointRadius(pointSize*2);
line.setHasPoints(true);
return line;
}
private Line predictionLine() {
List<PointValue> pointValues = new ArrayList<PointValue>();
long endTime = getPredictionEndTime();
for (BgWatchData bwd: predictionsList) {
if(bwd.timestamp <= endTime) {
pointValues.add(new PointValue(fuzz(bwd.timestamp), (float) bwd.sgv));
}
}
Line line = new Line(pointValues);
line.setColor(Color.MAGENTA);
line.setHasLines(false);
int size = pointSize/2;
size = (size>0)?size:1;
line.setPointRadius(size);
line.setHasPoints(true);
return line;
}
public Line highValuesLine() { public Line highValuesLine() {
Line highValuesLine = new Line(highValues); Line highValuesLine = new Line(highValues);
highValuesLine.setColor(highColor); highValuesLine.setColor(highColor);
@ -309,38 +427,42 @@ public class BgGraphBuilder {
public Axis xAxis() { public Axis xAxis() {
final boolean is24 = DateFormat.is24HourFormat(context); final boolean is24 = DateFormat.is24HourFormat(context);
SimpleDateFormat timeFormat = new SimpleDateFormat(is24? "HH" : "h a");
timeFormat.setTimeZone(TimeZone.getDefault());
long timeNow = System.currentTimeMillis();
Axis xAxis = new Axis(); Axis xAxis = new Axis();
xAxis.setAutoGenerated(false); xAxis.setAutoGenerated(false);
List<AxisValue> xAxisValues = new ArrayList<AxisValue>(); List<AxisValue> xAxisValues = new ArrayList<AxisValue>();
GregorianCalendar now = new GregorianCalendar();
GregorianCalendar today = new GregorianCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH)); //get the time-tick at the full hour after start_time
SimpleDateFormat timeFormat = new SimpleDateFormat(is24? "HH" : "h a"); GregorianCalendar startGC = new GregorianCalendar();
timeFormat.setTimeZone(TimeZone.getDefault()); startGC.setTimeInMillis(start_time);
long start_hour = today.getTime().getTime(); startGC.set(Calendar.MILLISECOND, 0);
long timeNow = System.currentTimeMillis(); startGC.set(Calendar.SECOND, 0);
for (int l = 0; l <= 24; l++) { startGC.set(Calendar.MINUTE, 0);
if ((start_hour + (60000 * 60 * (l))) < timeNow) { startGC.add(Calendar.HOUR, 1);
if ((start_hour + (60000 * 60 * (l + 1))) >= timeNow) { long start_hour = startGC.getTimeInMillis();
endHour = start_hour + (60000 * 60 * (l));
l = 25;
}
}
}
//Display current time on the graph //Display current time on the graph
SimpleDateFormat longTimeFormat = new SimpleDateFormat(is24? "HH:mm" : "h:mm a"); SimpleDateFormat longTimeFormat = new SimpleDateFormat(is24? "HH:mm" : "h:mm a");
xAxisValues.add(new AxisValue(fuzz(timeNow), (longTimeFormat.format(timeNow)).toCharArray())); xAxisValues.add(new AxisValue(fuzz(timeNow)).setLabel((longTimeFormat.format(timeNow))));
//Add whole hours endTime the axis (as long as they are more than 15 mins away from the current time) long hourTick = start_hour;
for (int l = 0; l <= 24; l++) {
long timestamp = endHour - (60000 * 60 * l); // add all full hours within the timeframe
if((timestamp - timeNow < 0) && (timestamp > start_time)) { while (hourTick < end_time){
if(Math.abs(timestamp - timeNow) > (1000 * 60 * 8 * timespan)){ if(Math.abs(hourTick - timeNow) > (1000 * 60 * 8 * timespan)){
xAxisValues.add(new AxisValue(fuzz(timestamp), (timeFormat.format(timestamp)).toCharArray())); xAxisValues.add(new AxisValue(fuzz(hourTick)).setLabel(timeFormat.format(hourTick)));
}else { } else {
xAxisValues.add(new AxisValue(fuzz(timestamp), "".toCharArray())); //don't print hour label if too close to now to avoid overlaps
} xAxisValues.add(new AxisValue(fuzz(hourTick)).setLabel(""));
} }
//increment by one hour
hourTick += 60*60*1000;
} }
xAxis.setValues(xAxisValues); xAxis.setValues(xAxisValues);
xAxis.setTextSize(10); xAxis.setTextSize(10);
xAxis.setHasLines(true); xAxis.setHasLines(true);
@ -350,6 +472,17 @@ public class BgGraphBuilder {
return xAxis; return xAxis;
} }
public long getPredictionEndTime() {
long maxPredictionDate = System.currentTimeMillis();
for (BgWatchData prediction :
predictionsList) {
if (maxPredictionDate < prediction.timestamp) {
maxPredictionDate = prediction.timestamp;
}
}
return (long) Math.min(maxPredictionDate, System.currentTimeMillis() + MAX_PREDICTION__TIME_RATIO *timespan*1000*60*60);
}
public float fuzz(long value) { public float fuzz(long value) {
return (float) Math.round(value / fuzzyTimeDenom); return (float) Math.round(value / fuzzyTimeDenom);
} }

View file

@ -13,6 +13,7 @@ import android.graphics.Paint;
import android.graphics.Point; import android.graphics.Point;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.Shader; import android.graphics.Shader;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.SystemClock; import android.os.SystemClock;
@ -22,6 +23,7 @@ import android.support.v4.content.LocalBroadcastManager;
import android.support.wearable.view.WatchViewStub; import android.support.wearable.view.WatchViewStub;
import android.support.wearable.watchface.WatchFaceStyle; import android.support.wearable.watchface.WatchFaceStyle;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.view.Display; import android.view.Display;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -30,6 +32,7 @@ import android.view.WindowInsets;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.wearable.DataMap; import com.google.android.gms.wearable.DataMap;
import com.ustwo.clockwise.common.WatchFaceTime; import com.ustwo.clockwise.common.WatchFaceTime;
@ -40,6 +43,7 @@ import com.ustwo.clockwise.wearable.WatchFace;
import java.util.ArrayList; import java.util.ArrayList;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.data.BasalWatchData; import info.nightscout.androidaps.data.BasalWatchData;
import info.nightscout.androidaps.data.BgWatchData; import info.nightscout.androidaps.data.BgWatchData;
import info.nightscout.androidaps.data.ListenerService; import info.nightscout.androidaps.data.ListenerService;
@ -52,6 +56,7 @@ import lecho.lib.hellocharts.view.LineChartView;
*/ */
public class NOChart extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener { public class NOChart extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {
public final static IntentFilter INTENT_FILTER; public final static IntentFilter INTENT_FILTER;
public static final int SCREENSIZE_SMALL = 280;
public TextView mTime, mSgv, mTimestamp, mDelta, mAvgDelta; public TextView mTime, mSgv, mTimestamp, mDelta, mAvgDelta;
public RelativeLayout mRelativeLayout; public RelativeLayout mRelativeLayout;
public long sgvLevel = 0; public long sgvLevel = 0;
@ -96,6 +101,12 @@ public class NOChart extends WatchFace implements SharedPreferences.OnSharedPref
sharedPrefs.registerOnSharedPreferenceChangeListener(this); sharedPrefs.registerOnSharedPreferenceChangeListener(this);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layoutView = inflater.inflate(R.layout.activity_nochart, null); layoutView = inflater.inflate(R.layout.activity_nochart, null);
DisplayMetrics metrics = getResources().getDisplayMetrics();
if(metrics.widthPixels < SCREENSIZE_SMALL || metrics.heightPixels < SCREENSIZE_SMALL){
layoutView = inflater.inflate(R.layout.activity_nochart_small, null);
} else {
layoutView = inflater.inflate(R.layout.activity_nochart, null);
}
performViewSetup(); performViewSetup();
} }
@ -514,4 +525,4 @@ public class NOChart extends WatchFace implements SharedPreferences.OnSharedPref
ListenerService.requestData(this); // attempt endTime recover missing data ListenerService.requestData(this); // attempt endTime recover missing data
} }
} }
} }

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.WatchViewStub
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/watch_view_stub"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rectLayout="@layout/rect_activity_bigchart_small"
app:roundLayout="@layout/round_activity_bigchart_small"
tools:context=".watchfaces.Home"
tools:deviceIds="wear"/>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.WatchViewStub
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/watch_view_stub"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rectLayout="@layout/rect_activity_nochart_small"
app:roundLayout="@layout/round_activity_nochart_small"
tools:context=".watchfaces.Home"
tools:deviceIds="wear"/>

View file

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_square"
android:background="@color/black"
android:id="@+id/main_layout">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAlignment="center"
android:gravity="center_horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-5dp"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingTop="5dp"
android:textAlignment="center">
<TextView
android:id="@+id/delta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal|center"
android:layout_marginRight="5dp"
android:gravity="center_horizontal|bottom"
android:text="---"
android:textColor="#FFFFFF"
android:textSize="24sp" />
<TextView
android:id="@+id/sgv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:text="---"
android:textColor="#FFFFFF"
android:textSize="34sp" />
<TextView
android:id="@+id/avgdelta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal|center"
android:layout_marginLeft="5dp"
android:gravity="center_horizontal|bottom"
android:text="---"
android:textColor="#FFFFFF"
android:textSize="24sp" />
</LinearLayout>
<TextView
android:id="@+id/aps_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-5sp"
android:text="E xU/h IOB: x (x+x)"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="18sp" />
<lecho.lib.hellocharts.view.LineChartView
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="bottom"
android:layout_weight="1"
android:gravity="center_horizontal" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-5sp"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:textAlignment="center">
<TextView
android:id="@+id/watch_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginRight="6dp"
android:paddingTop="-5sp"
android:text="12:00"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="34sp" />
<TextView
android:id="@+id/timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal|center"
android:text="--'"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="24sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>

View file

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_square"
android:background="@color/black"
android:id="@+id/main_layout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical"
android:textAlignment="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-5dp"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingTop="5dp"
android:textAlignment="center">
<TextView
android:id="@+id/delta"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_marginRight="5dp"
android:gravity="center_vertical|center_horizontal|center"
android:text="---"
android:textColor="#FFFFFF"
android:textSize="24sp" />
<TextView
android:id="@+id/sgv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:text="---"
android:textColor="#FFFFFF"
android:textSize="45sp" />
<TextView
android:id="@+id/avgdelta"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="5dp"
android:gravity="center_vertical|center_horizontal|center"
android:text=" ---"
android:textColor="#FFFFFF"
android:textSize="26sp" />
</LinearLayout>
<View
android:id="@+id/dummy1"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="bottom"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/aps_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="No Loop Status"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="21sp" />
<View
android:id="@+id/dummy2"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="bottom"
android:layout_weight="0"
android:gravity="center_horizontal" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|bottom"
android:orientation="horizontal"
android:textAlignment="center">
<TextView
android:id="@+id/watch_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginRight="6dp"
android:text="23:24"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="45sp" />
<TextView
android:id="@+id/timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="--'"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="24sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>

View file

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_square"
android:background="@color/black"
android:id="@+id/main_layout">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAlignment="center"
android:gravity="center_horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-5dp"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingTop="5dp"
android:textAlignment="center">
<TextView
android:id="@+id/delta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal|center"
android:layout_marginRight="5dp"
android:gravity="center_horizontal|bottom"
android:text="---"
android:textColor="#FFFFFF"
android:textSize="24sp" />
<TextView
android:id="@+id/sgv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:text="---"
android:textColor="#FFFFFF"
android:textSize="34sp" />
<TextView
android:id="@+id/avgdelta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal|center"
android:layout_marginLeft="5dp"
android:gravity="center_horizontal|bottom"
android:text="---"
android:textColor="#FFFFFF"
android:textSize="24sp" />
</LinearLayout>
<TextView
android:id="@+id/aps_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-5sp"
android:text="E xU/h IOB: x (x+x)"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="18sp" />
<lecho.lib.hellocharts.view.LineChartView
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="bottom"
android:layout_weight="1"
android:gravity="center_horizontal" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-5sp"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:textAlignment="center">
<TextView
android:id="@+id/watch_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginRight="6dp"
android:paddingTop="-5sp"
android:text="12:00"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="34sp" />
<TextView
android:id="@+id/timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal|center"
android:text="--'"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="24sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>

View file

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_square"
android:background="@color/black"
android:id="@+id/main_layout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical"
android:textAlignment="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-5dp"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingTop="5dp"
android:textAlignment="center">
<TextView
android:id="@+id/delta"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_marginRight="5dp"
android:gravity="center_vertical|center_horizontal|center"
android:text="---"
android:textColor="#FFFFFF"
android:textSize="24sp" />
<TextView
android:id="@+id/sgv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:text="---"
android:textColor="#FFFFFF"
android:textSize="45sp" />
<TextView
android:id="@+id/avgdelta"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="5dp"
android:gravity="center_vertical|center_horizontal|center"
android:text=" ---"
android:textColor="#FFFFFF"
android:textSize="26sp" />
</LinearLayout>
<View
android:id="@+id/dummy1"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="bottom"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/aps_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="No Loop Status"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="21sp" />
<View
android:id="@+id/dummy2"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="bottom"
android:layout_weight="0"
android:gravity="center_horizontal" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|bottom"
android:orientation="horizontal"
android:textAlignment="center">
<TextView
android:id="@+id/watch_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginRight="6dp"
android:text="23:24"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="45sp" />
<TextView
android:id="@+id/timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="--'"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="24sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>