carbs absorption settings
This commit is contained in:
parent
ac98852f79
commit
3f641f9c30
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugi
|
|||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.SensitivityMK.SensitivityMKPlugin;
|
||||
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
||||
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
||||
import info.nightscout.utils.LocaleHelper;
|
||||
|
@ -105,6 +106,8 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
|||
if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS))
|
||||
addPreferencesFromResource(R.xml.pref_openapsama);
|
||||
}
|
||||
if (MainApp.getSpecificPlugin(SensitivityMKPlugin.class) != null && MainApp.getSpecificPlugin(SensitivityMKPlugin.class).isEnabled(PluginBase.SENSITIVITY))
|
||||
addPreferencesFromResource(R.xml.pref_absorption);
|
||||
if (Config.ALLPREFERENCES) {
|
||||
addPreferencesFromResource(R.xml.pref_profile);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,12 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.SensitivityMK.SensitivityMKPlugin;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
|
@ -27,7 +32,16 @@ public class AutosensData {
|
|||
time = t.date;
|
||||
carbs = t.carbs;
|
||||
remaining = t.carbs;
|
||||
min5minCarbImpact = SP.getDouble("openapsama_min_5m_carbimpact", 3.0);
|
||||
if (MainApp.getSpecificPlugin(SensitivityMKPlugin.class) != null && MainApp.getSpecificPlugin(SensitivityMKPlugin.class).isEnabled(PluginBase.SENSITIVITY)) {
|
||||
double maxAbsorptionHours = SP.getDouble(R.string.key_absorption_maxtime, 4d);
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile(t.date);
|
||||
double sens = Profile.toMgdl(profile.getIsf(t.date), profile.getUnits());
|
||||
double ic = profile.getIc(t.date);
|
||||
min5minCarbImpact = t.carbs / (maxAbsorptionHours * 60 / 5) * sens / ic;
|
||||
log.debug("Min 5m carbs impact for " + carbs + "g @" + new Date(t.date).toLocaleString() + " for " + maxAbsorptionHours + "h calculated to " + min5minCarbImpact + " ISF: " + sens + " IC: " + ic);
|
||||
} else {
|
||||
min5minCarbImpact = SP.getDouble("openapsama_min_5m_carbimpact", 3.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -599,7 +599,8 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
@Subscribe
|
||||
public void onStatusEvent(EventPreferenceChange ev) {
|
||||
if (ev.isChanged(R.string.key_openapsama_autosens_period) ||
|
||||
ev.isChanged(R.string.key_age)
|
||||
ev.isChanged(R.string.key_age) ||
|
||||
ev.isChanged(R.string.key_absorption_maxtime)
|
||||
) {
|
||||
synchronized (dataLock) {
|
||||
log.debug("Invalidating cached data because of preference change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
|
||||
|
|
|
@ -305,11 +305,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
iobGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
|
||||
iobGraph.getGridLabelRenderer().setNumVerticalLabels(5);
|
||||
|
||||
rangeToDisplay = SP.getInt(R.string.key_rangetodisplay, 6);
|
||||
|
||||
bgGraph.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
rangeToDisplay += 6;
|
||||
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
||||
SP.putInt(R.string.key_rangetodisplay, rangeToDisplay);
|
||||
updateGUI("rangeChange");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -49,11 +49,19 @@ public class SP {
|
|||
}
|
||||
|
||||
static public int getInt(int resourceID, Integer defaultValue) {
|
||||
return SafeParse.stringToInt(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString()));
|
||||
try {
|
||||
return sharedPreferences.getInt(MainApp.sResources.getString(resourceID), defaultValue);
|
||||
} catch (Exception e) {
|
||||
return SafeParse.stringToInt(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
static public int getInt(String key, Integer defaultValue) {
|
||||
return SafeParse.stringToInt(sharedPreferences.getString(key, defaultValue.toString()));
|
||||
try {
|
||||
return sharedPreferences.getInt(key, defaultValue);
|
||||
} catch (Exception e) {
|
||||
return SafeParse.stringToInt(sharedPreferences.getString(key, defaultValue.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
static public long getLong(int resourceID, Long defaultValue) {
|
||||
|
@ -92,6 +100,24 @@ public class SP {
|
|||
editor.apply();
|
||||
}
|
||||
|
||||
static public void putLong(int resourceID, long value) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putLong(MainApp.sResources.getString(resourceID), value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
static public void putInt(String key, int value) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putInt(key, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
static public void putInt(int resourceID, int value) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putInt(MainApp.sResources.getString(resourceID), value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
static public void putString(int resourceID, String value) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(MainApp.sResources.getString(resourceID), value);
|
||||
|
|
|
@ -657,4 +657,9 @@
|
|||
<string name="sensitivity_shortname">SENS</string>
|
||||
<string name="sensitivityoref0">Sensitivity Oref0</string>
|
||||
<string name="sensitivitymk">Sensitivity MK</string>
|
||||
<string name="absorptionsettings_title">Absorption settings</string>
|
||||
<string name="key_absorption_maxtime" translatable="false">absorption_maxtime</string>
|
||||
<string name="absorption_maxtime_title">Meal max absorption time</string>
|
||||
<string name="absorption_maxtime_summary">Time in hours where is expected all carbs from meal will be absorbed</string>
|
||||
<string name="key_rangetodisplay" translatable="false">rangetodisplay</string>
|
||||
</resources>
|
||||
|
|
35
app/src/main/res/xml/pref_absorption.xml
Normal file
35
app/src/main/res/xml/pref_absorption.xml
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:validate="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory
|
||||
android:key="absorption"
|
||||
android:title="@string/absorptionsettings_title">
|
||||
<com.andreabaccega.widget.ValidatingEditTextPreference
|
||||
validate:testType="numericRange"
|
||||
validate:minNumber="1"
|
||||
validate:maxNumber="10"
|
||||
android:digits="0123456789.,"
|
||||
android:defaultValue="3"
|
||||
android:selectAllOnFocus="true"
|
||||
android:inputType="number"
|
||||
android:maxLines="20"
|
||||
android:title="@string/absorption_maxtime_title"
|
||||
android:dialogMessage="@string/absorption_maxtime_summary"
|
||||
android:key="@string/key_absorption_maxtime" />
|
||||
|
||||
<com.andreabaccega.widget.ValidatingEditTextPreference
|
||||
validate:maxNumber="24"
|
||||
validate:minNumber="4"
|
||||
validate:testType="numericRange"
|
||||
android:defaultValue="24"
|
||||
android:dialogMessage="@string/openapsama_autosens_period_summary"
|
||||
android:digits="0123456789"
|
||||
android:inputType="number"
|
||||
android:key="@string/key_openapsama_autosens_period"
|
||||
android:maxLines="20"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:title="@string/openapsama_autosens_period" />
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
|
@ -10,21 +10,6 @@
|
|||
android:key="openapsama_useautosens"
|
||||
android:title="@string/openapsama_useautosens" />
|
||||
|
||||
<com.andreabaccega.widget.ValidatingEditTextPreference
|
||||
validate:maxNumber="24"
|
||||
validate:minNumber="4"
|
||||
validate:testType="numericRange"
|
||||
android:defaultValue="24"
|
||||
android:dependency="openapsama_useautosens"
|
||||
android:dialogMessage="@string/openapsama_autosens_period_summary"
|
||||
android:digits="0123456789"
|
||||
android:inputType="number"
|
||||
android:key="@string/key_openapsama_autosens_period"
|
||||
android:maxLines="20"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:title="@string/openapsama_autosens_period" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
Loading…
Reference in a new issue