Merge branch 'dev' of https://github.com/MilosKozak/AndroidAPS into dev
This commit is contained in:
commit
15127dc4c6
|
@ -131,7 +131,7 @@ public class GlucoseStatus {
|
|||
|
||||
status.short_avgdelta = average(short_deltas);
|
||||
|
||||
if (prefs.getBoolean("always_use_shortavg", false) || last_deltas.isEmpty()) {
|
||||
if (last_deltas.isEmpty()) {
|
||||
status.delta = status.short_avgdelta;
|
||||
} else {
|
||||
status.delta = average(last_deltas);
|
||||
|
|
|
@ -243,7 +243,12 @@ public class DetermineBasalAdapterAMAJS {
|
|||
|
||||
mGlucoseStatus = new V8Object(mV8rt);
|
||||
mGlucoseStatus.add("glucose", glucoseStatus.glucose);
|
||||
mGlucoseStatus.add("delta", glucoseStatus.delta);
|
||||
|
||||
if(SP.getBoolean("always_use_shortavg", false)){
|
||||
mGlucoseStatus.add("delta", glucoseStatus.short_avgdelta);
|
||||
} else {
|
||||
mGlucoseStatus.add("delta", glucoseStatus.delta);
|
||||
}
|
||||
mGlucoseStatus.add("short_avgdelta", glucoseStatus.short_avgdelta);
|
||||
mGlucoseStatus.add("long_avgdelta", glucoseStatus.long_avgdelta);
|
||||
mV8rt.add(PARAM_glucoseStatus, mGlucoseStatus);
|
||||
|
|
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.data.MealData;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
public class DetermineBasalAdapterMAJS {
|
||||
private static Logger log = LoggerFactory.getLogger(DetermineBasalAdapterMAJS.class);
|
||||
|
@ -251,7 +252,11 @@ public class DetermineBasalAdapterMAJS {
|
|||
mIobData.add("hightempinsulin", iobData.hightempinsulin);
|
||||
|
||||
mGlucoseStatus.add("glucose", glucoseStatus.glucose);
|
||||
mGlucoseStatus.add("delta", glucoseStatus.delta);
|
||||
if(SP.getBoolean("always_use_shortavg", false)){
|
||||
mGlucoseStatus.add("delta", glucoseStatus.short_avgdelta);
|
||||
} else {
|
||||
mGlucoseStatus.add("delta", glucoseStatus.delta);
|
||||
}
|
||||
mGlucoseStatus.add("avgdelta", glucoseStatus.avgdelta);
|
||||
|
||||
mMealData.add("carbs", mealData.carbs);
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.content.SharedPreferences;
|
|||
import android.os.BatteryManager;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
|
@ -503,42 +504,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
private void sendStatus() {
|
||||
if (googleApiClient.isConnected()) {
|
||||
|
||||
String status = "";
|
||||
boolean shortString = true;
|
||||
|
||||
LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
|
||||
|
||||
if (activeloop != null && !activeloop.isEnabled(PluginBase.LOOP)) {
|
||||
status += getString(R.string.disabledloop) + "\n";
|
||||
lastLoopStatus = false;
|
||||
} else if (activeloop != null && activeloop.isEnabled(PluginBase.LOOP)) {
|
||||
lastLoopStatus = true;
|
||||
}
|
||||
|
||||
//Temp basal
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
|
||||
if (pump.isTempBasalInProgress()) {
|
||||
TempBasal activeTemp = pump.getTempBasal();
|
||||
if (shortString) {
|
||||
status += activeTemp.toStringShort();
|
||||
} else {
|
||||
status += activeTemp.toStringMedium();
|
||||
}
|
||||
}
|
||||
|
||||
//IOB
|
||||
MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB();
|
||||
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round();
|
||||
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB();
|
||||
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round();
|
||||
status += (shortString?"":(getString(R.string.treatments_iob_label_string) + " ")) + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob);
|
||||
|
||||
if (mPrefs.getBoolean("wear_detailediob", true)) {
|
||||
status += "("
|
||||
+ DecimalFormatter.to2Decimal(bolusIob.iob) + "|"
|
||||
+ DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
|
||||
}
|
||||
String status = generateStatusString();
|
||||
|
||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_STATUS_PATH);
|
||||
//unique content
|
||||
|
@ -551,6 +517,56 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String generateStatusString() {
|
||||
String status = "";
|
||||
boolean shortString = true;
|
||||
|
||||
LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
|
||||
|
||||
if (activeloop != null && !activeloop.isEnabled(PluginBase.LOOP)) {
|
||||
status += getString(R.string.disabledloop) + "\n";
|
||||
lastLoopStatus = false;
|
||||
} else if (activeloop != null && activeloop.isEnabled(PluginBase.LOOP)) {
|
||||
lastLoopStatus = true;
|
||||
}
|
||||
|
||||
//Temp basal
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
|
||||
if (pump.isTempBasalInProgress()) {
|
||||
TempBasal activeTemp = pump.getTempBasal();
|
||||
if (shortString) {
|
||||
status += activeTemp.toStringShort();
|
||||
} else {
|
||||
status += activeTemp.toStringMedium();
|
||||
}
|
||||
}
|
||||
|
||||
//IOB
|
||||
MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB();
|
||||
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round();
|
||||
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB();
|
||||
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round();
|
||||
status += (shortString?"":(getString(R.string.treatments_iob_label_string) + " ")) + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob);
|
||||
|
||||
if (mPrefs.getBoolean("wear_detailediob", true)) {
|
||||
status += "("
|
||||
+ DecimalFormatter.to2Decimal(bolusIob.iob) + "|"
|
||||
+ DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
|
||||
}
|
||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
if (!mPrefs.getBoolean("wear_showbgi", false) ||profile == null || profile.getIsf(NSProfile.secondsFromMidnight()) == null || profile.getIc(NSProfile.secondsFromMidnight()) == null) {
|
||||
return status;
|
||||
}
|
||||
|
||||
double bgi = -(bolusIob.activity + basalIob.activity)*5*profile.getIsf(NSProfile.secondsFromMidnight());
|
||||
|
||||
status += " " + ((bgi>=0)?"+":"") + DecimalFormatter.to2Decimal(bgi);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (googleApiClient != null && googleApiClient.isConnected()) {
|
||||
|
|
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
|
|||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
||||
/**
|
||||
|
@ -181,6 +182,15 @@ public class StatuslinePlugin implements PluginBase {
|
|||
+ DecimalFormatter.to2Decimal(bolusIob.iob) + "|"
|
||||
+ DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
|
||||
}
|
||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
if (!mPrefs.getBoolean("xdripstatus_showbgi", false) ||profile == null || profile.getIsf(NSProfile.secondsFromMidnight()) == null || profile.getIc(NSProfile.secondsFromMidnight()) == null) {
|
||||
return status;
|
||||
}
|
||||
|
||||
double bgi = -(bolusIob.activity + basalIob.activity)*5*profile.getIsf(NSProfile.secondsFromMidnight());
|
||||
|
||||
status += " " + ((bgi>=0)?"+":"") + DecimalFormatter.to2Decimal(bgi);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -603,6 +603,8 @@
|
|||
<string name="xdripstatus_settings">xDrip Status (watch)</string>
|
||||
<string name="xdripstatus">xDrip Statusline (watch)</string>
|
||||
<string name="xdripstatus_shortname">xds</string>
|
||||
<string name="wear_showbgi_title">Show BGI</string>
|
||||
<string name="wear_showbgi_summary">Add BGI to status line</string>
|
||||
<string name="ns_noupload">No upload to NS</string>
|
||||
<string name="ns_noupload_summary">All data sent to NS are dropped. AAPS is connected to NS but no change in NS is done</string>
|
||||
<string name="key_ns_upload_only" translatable="false">ns_upload_only</string>
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
android:key="wear_detailediob"
|
||||
android:title="@string/wear_detailedIOB_title"
|
||||
android:summary="@string/wear_detailedIOB_summary"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="wear_showbgi"
|
||||
android:title="@string/wear_showbgi_title"
|
||||
android:summary="@string/wear_showbgi_summary"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
|
@ -9,6 +9,11 @@
|
|||
android:key="xdripstatus_detailediob"
|
||||
android:title="@string/wear_detailedIOB_title"
|
||||
android:summary="@string/wear_detailedIOB_summary"/>
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="xdripstatus_showbgi"
|
||||
android:title="@string/wear_showbgi_title"
|
||||
android:summary="@string/wear_showbgi_summary"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
Loading…
Reference in a new issue