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

View file

@ -14,6 +14,7 @@ public class DeliverBolusMessage extends AppLayerMessage {
private double extendedAmount;
private int duration;
private int bolusId;
private boolean disableVibration = false;
public DeliverBolusMessage() {
super(MessagePriority.NORMAL, true, true, Service.REMOTE_CONTROL);
@ -22,7 +23,11 @@ public class DeliverBolusMessage extends AppLayerMessage {
@Override
protected ByteBuf getData() {
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);
else
byteBuf.putUInt16LE(805);
byteBuf.putUInt16LE(BolusTypeIDs.IDS.getID(bolusType));
byteBuf.putUInt16LE(31);
byteBuf.putUInt16LE(0);
@ -57,6 +62,8 @@ public class DeliverBolusMessage extends AppLayerMessage {
this.duration = duration;
}
public void setVibration(boolean disableVibration) { this.disableVibration = disableVibration;}
public int getBolusId() {
return bolusId;
}

View file

@ -1017,6 +1017,12 @@
<string name="log_alerts">Log alerts</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="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="serial_number">Serial number</string>
<string name="release_software_version">Release software version</string>

View file

@ -48,6 +48,18 @@
android:summary="@string/enable_tbr_emulation_summary"
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
android:defaultValue="5"
android:inputType="number"

View file

@ -48,6 +48,12 @@
android:summary="@string/enable_tbr_emulation_summary"
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
android:defaultValue="5"
android:inputType="number"