Merge pull request #2647 from Philoul/Insight_Pref_Vibration

Add vibration in Insight preferences
This commit is contained in:
Milos Kozak 2020-05-23 18:08:53 +02:00 committed by GitHub
commit 8e49717794
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 4 deletions

View file

@ -597,6 +597,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
bolusMessage.setDuration(0); bolusMessage.setDuration(0);
bolusMessage.setExtendedAmount(0); bolusMessage.setExtendedAmount(0);
bolusMessage.setImmediateAmount(insulin); bolusMessage.setImmediateAmount(insulin);
bolusMessage.setVibration(sp.getBoolean(detailedBolusInfo.isSMB ? R.string.key_disable_vibration_auto : R.string.key_disable_vibration ,false));
bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId(); bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId();
bolusCancelled = false; bolusCancelled = false;
} }
@ -720,7 +721,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
PumpEnactResult cancelTBRResult = cancelTempBasalOnly(); PumpEnactResult cancelTBRResult = cancelTempBasalOnly();
if (cancelTBRResult.success) { if (cancelTBRResult.success) {
PumpEnactResult ebResult = setExtendedBolusOnly((absoluteRate - getBaseBasalRate()) / 60D PumpEnactResult ebResult = setExtendedBolusOnly((absoluteRate - getBaseBasalRate()) / 60D
* ((double) durationInMinutes), durationInMinutes); * ((double) durationInMinutes), durationInMinutes,
sp.getBoolean(R.string.key_disable_vibration_auto,false));
if (ebResult.success) { if (ebResult.success) {
result.success = true; result.success = true;
result.enacted = true; result.enacted = true;
@ -798,7 +800,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
@NonNull @Override @NonNull @Override
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) { public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
PumpEnactResult result = cancelExtendedBolusOnly(); PumpEnactResult result = cancelExtendedBolusOnly();
if (result.success) result = setExtendedBolusOnly(insulin, durationInMinutes); if (result.success) result = setExtendedBolusOnly(insulin, durationInMinutes, sp.getBoolean(R.string.key_disable_vibration,false));
try { try {
fetchStatus(); fetchStatus();
readHistory(); readHistory();
@ -812,7 +814,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
return result; return result;
} }
public PumpEnactResult setExtendedBolusOnly(Double insulin, Integer durationInMinutes) { public PumpEnactResult setExtendedBolusOnly(Double insulin, Integer durationInMinutes, boolean disableVibration) {
PumpEnactResult result = new PumpEnactResult(getInjector()); PumpEnactResult result = new PumpEnactResult(getInjector());
try { try {
DeliverBolusMessage bolusMessage = new DeliverBolusMessage(); DeliverBolusMessage bolusMessage = new DeliverBolusMessage();
@ -820,6 +822,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
bolusMessage.setDuration(durationInMinutes); bolusMessage.setDuration(durationInMinutes);
bolusMessage.setExtendedAmount(insulin); bolusMessage.setExtendedAmount(insulin);
bolusMessage.setImmediateAmount(0); bolusMessage.setImmediateAmount(0);
bolusMessage.setVibration(disableVibration);
int bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId(); int bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId();
InsightBolusID insightBolusID = new InsightBolusID(); InsightBolusID insightBolusID = new InsightBolusID();
insightBolusID.bolusID = bolusID; insightBolusID.bolusID = bolusID;

View file

@ -14,6 +14,7 @@ public class DeliverBolusMessage extends AppLayerMessage {
private double extendedAmount; private double extendedAmount;
private int duration; private int duration;
private int bolusId; private int bolusId;
private boolean disableVibration = false;
public DeliverBolusMessage() { public DeliverBolusMessage() {
super(MessagePriority.NORMAL, true, true, Service.REMOTE_CONTROL); super(MessagePriority.NORMAL, true, true, Service.REMOTE_CONTROL);
@ -22,7 +23,11 @@ public class DeliverBolusMessage extends AppLayerMessage {
@Override @Override
protected ByteBuf getData() { protected ByteBuf getData() {
ByteBuf byteBuf = new ByteBuf(22); ByteBuf byteBuf = new ByteBuf(22);
// 805 => Old value with vibration (2.6.1 and earlier), 252 => new value without vibrations for firmware 3.x
if (disableVibration)
byteBuf.putUInt16LE(252); byteBuf.putUInt16LE(252);
else
byteBuf.putUInt16LE(805);
byteBuf.putUInt16LE(BolusTypeIDs.IDS.getID(bolusType)); byteBuf.putUInt16LE(BolusTypeIDs.IDS.getID(bolusType));
byteBuf.putUInt16LE(31); byteBuf.putUInt16LE(31);
byteBuf.putUInt16LE(0); byteBuf.putUInt16LE(0);
@ -57,6 +62,8 @@ public class DeliverBolusMessage extends AppLayerMessage {
this.duration = duration; this.duration = duration;
} }
public void setVibration(boolean disableVibration) { this.disableVibration = disableVibration;}
public int getBolusId() { public int getBolusId() {
return bolusId; return bolusId;
} }

View file

@ -1017,6 +1017,12 @@
<string name="log_alerts">Log alerts</string> <string name="log_alerts">Log alerts</string>
<string name="enable_tbr_emulation">Enable TBR emulation</string> <string name="enable_tbr_emulation">Enable TBR emulation</string>
<string name="enable_tbr_emulation_summary">Use extended boluses instead of TBRs to bypass the 250%% limit</string> <string name="enable_tbr_emulation_summary">Use extended boluses instead of TBRs to bypass the 250%% limit</string>
<string name="key_disable_vibration" translatable="false">insight_disable_vibration</string>
<string name="disable_vibration">Disable vibrations on manual bolus delivery</string>
<string name="disable_vibration_summary">For bolus and extended bolus (only available with Insight firmware 3.x)</string>
<string name="key_disable_vibration_auto" translatable="false">insight_disable_vibration_auto</string>
<string name="disable_vibration_auto">Disable vibrations on automated bolus delivery</string>
<string name="disable_vibration_auto_summary">For SMB and Temp Basal with TBR emulation (only available with Insight firmware 3.x)</string>
<string name="disconnect_delay">Disconnect delay [s]</string> <string name="disconnect_delay">Disconnect delay [s]</string>
<string name="serial_number">Serial number</string> <string name="serial_number">Serial number</string>
<string name="release_software_version">Release software version</string> <string name="release_software_version">Release software version</string>

View file

@ -48,6 +48,18 @@
android:summary="@string/enable_tbr_emulation_summary" android:summary="@string/enable_tbr_emulation_summary"
android:title="@string/enable_tbr_emulation" /> android:title="@string/enable_tbr_emulation" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_disable_vibration"
android:summary="@string/disable_vibration_summary"
android:title="@string/disable_vibration" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_disable_vibration_auto"
android:summary="@string/disable_vibration_auto_summary"
android:title="@string/disable_vibration_auto" />
<EditTextPreference <EditTextPreference
android:defaultValue="5" android:defaultValue="5"
android:inputType="number" android:inputType="number"

View file

@ -48,6 +48,12 @@
android:summary="@string/enable_tbr_emulation_summary" android:summary="@string/enable_tbr_emulation_summary"
android:title="@string/enable_tbr_emulation" /> android:title="@string/enable_tbr_emulation" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_disable_vibration"
android:summary="@string/disable_vibration_summary"
android:title="@string/disable_vibration" />
<EditTextPreference <EditTextPreference
android:defaultValue="5" android:defaultValue="5"
android:inputType="number" android:inputType="number"