unify trend arrow AAPS <-> watch
This commit is contained in:
parent
ce59c3afd4
commit
d43393e2af
|
@ -29,12 +29,9 @@ import java.util.stream.Collectors;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.android.AndroidInjection;
|
import dagger.android.AndroidInjection;
|
||||||
import info.nightscout.androidaps.interfaces.Config;
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.interfaces.GlucoseUnit;
|
|
||||||
import info.nightscout.androidaps.interfaces.Profile;
|
|
||||||
import info.nightscout.androidaps.database.AppRepository;
|
import info.nightscout.androidaps.database.AppRepository;
|
||||||
import info.nightscout.androidaps.database.entities.Bolus;
|
import info.nightscout.androidaps.database.entities.Bolus;
|
||||||
import info.nightscout.androidaps.database.entities.GlucoseValue;
|
import info.nightscout.androidaps.database.entities.GlucoseValue;
|
||||||
|
@ -42,8 +39,11 @@ import info.nightscout.androidaps.database.entities.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.extensions.GlucoseValueExtensionKt;
|
import info.nightscout.androidaps.extensions.GlucoseValueExtensionKt;
|
||||||
import info.nightscout.androidaps.extensions.TemporaryBasalExtensionKt;
|
import info.nightscout.androidaps.extensions.TemporaryBasalExtensionKt;
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin;
|
import info.nightscout.androidaps.interfaces.ActivePlugin;
|
||||||
|
import info.nightscout.androidaps.interfaces.Config;
|
||||||
|
import info.nightscout.androidaps.interfaces.GlucoseUnit;
|
||||||
import info.nightscout.androidaps.interfaces.IobCobCalculator;
|
import info.nightscout.androidaps.interfaces.IobCobCalculator;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.interfaces.Profile;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
|
@ -59,7 +59,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProv
|
||||||
import info.nightscout.androidaps.receivers.ReceiverStatusStore;
|
import info.nightscout.androidaps.receivers.ReceiverStatusStore;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper;
|
import info.nightscout.androidaps.utils.DefaultValueHelper;
|
||||||
import info.nightscout.androidaps.utils.ToastUtils;
|
import info.nightscout.androidaps.utils.TrendCalculator;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
@Inject public AppRepository repository;
|
@Inject public AppRepository repository;
|
||||||
@Inject ReceiverStatusStore receiverStatusStore;
|
@Inject ReceiverStatusStore receiverStatusStore;
|
||||||
@Inject Config config;
|
@Inject Config config;
|
||||||
|
@Inject public TrendCalculator trendCalculator;
|
||||||
|
|
||||||
public static final String ACTION_RESEND = WatchUpdaterService.class.getName().concat(".Resend");
|
public static final String ACTION_RESEND = WatchUpdaterService.class.getName().concat(".Resend");
|
||||||
public static final String ACTION_OPEN_SETTINGS = WatchUpdaterService.class.getName().concat(".OpenSettings");
|
public static final String ACTION_OPEN_SETTINGS = WatchUpdaterService.class.getName().concat(".OpenSettings");
|
||||||
|
@ -322,7 +323,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
dataMap.putString("delta", "--");
|
dataMap.putString("delta", "--");
|
||||||
dataMap.putString("avgDelta", "--");
|
dataMap.putString("avgDelta", "--");
|
||||||
} else {
|
} else {
|
||||||
dataMap.putString("slopeArrow", slopeArrow(glucoseStatus.getDelta()));
|
dataMap.putString("slopeArrow", trendCalculator.getTrendArrow(lastBG).getSymbol());
|
||||||
dataMap.putString("delta", deltastring(glucoseStatus.getDelta(), glucoseStatus.getDelta() * Constants.MGDL_TO_MMOLL, units));
|
dataMap.putString("delta", deltastring(glucoseStatus.getDelta(), glucoseStatus.getDelta() * Constants.MGDL_TO_MMOLL, units));
|
||||||
dataMap.putString("avgDelta", deltastring(glucoseStatus.getShortAvgDelta(), glucoseStatus.getShortAvgDelta() * Constants.MGDL_TO_MMOLL, units));
|
dataMap.putString("avgDelta", deltastring(glucoseStatus.getShortAvgDelta(), glucoseStatus.getShortAvgDelta() * Constants.MGDL_TO_MMOLL, units));
|
||||||
}
|
}
|
||||||
|
@ -358,25 +359,6 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
return deltastring;
|
return deltastring;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String slopeArrow(double delta) {
|
|
||||||
if (delta <= (-3.5 * 5)) {
|
|
||||||
return "\u21ca";
|
|
||||||
} else if (delta <= (-2 * 5)) {
|
|
||||||
return "\u2193";
|
|
||||||
} else if (delta <= (-1 * 5)) {
|
|
||||||
return "\u2198";
|
|
||||||
} else if (delta <= (1 * 5)) {
|
|
||||||
return "\u2192";
|
|
||||||
} else if (delta <= (2 * 5)) {
|
|
||||||
return "\u2197";
|
|
||||||
} else if (delta <= (3.5 * 5)) {
|
|
||||||
return "\u2191";
|
|
||||||
} else {
|
|
||||||
return "\u21c8";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void resendData() {
|
private void resendData() {
|
||||||
if (googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) {
|
if (googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) {
|
||||||
googleApiConnect();
|
googleApiConnect();
|
||||||
|
@ -391,16 +373,10 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
|
|
||||||
if (!graph_bgs.isEmpty()) {
|
if (!graph_bgs.isEmpty()) {
|
||||||
DataMap entries = dataMapSingleBG(last_bg, glucoseStatus);
|
DataMap entries = dataMapSingleBG(last_bg, glucoseStatus);
|
||||||
if (entries == null) {
|
|
||||||
ToastUtils.showToastInUiThread(this, resourceHelper.gs(R.string.noprofile));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
|
final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
|
||||||
for (GlucoseValue bg : graph_bgs) {
|
for (GlucoseValue bg : graph_bgs) {
|
||||||
DataMap dataMap = dataMapSingleBG(bg, glucoseStatus);
|
DataMap dataMap = dataMapSingleBG(bg, glucoseStatus);
|
||||||
if (dataMap != null) {
|
dataMaps.add(dataMap);
|
||||||
dataMaps.add(dataMap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
entries.putDataMapArrayList("entries", dataMaps);
|
entries.putDataMapArrayList("entries", dataMaps);
|
||||||
(new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, entries);
|
(new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, entries);
|
||||||
|
@ -505,7 +481,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
tb2 = iobCobCalculator.getTempBasalIncludingConvertedExtended(now); //use "now" to express current situation
|
tb2 = iobCobCalculator.getTempBasalIncludingConvertedExtended(now); //use "now" to express current situation
|
||||||
if (tb2 == null) {
|
if (tb2 == null) {
|
||||||
//express the cancelled temp by painting it down one minute early
|
//express the cancelled temp by painting it down one minute early
|
||||||
temps.add(tempDatamap(tb_start, tb_before, now - 1 * 60 * 1000, endBasalValue, tb_amount));
|
temps.add(tempDatamap(tb_start, tb_before, now - 60 * 1000, endBasalValue, tb_amount));
|
||||||
} else {
|
} else {
|
||||||
//express currently running temp by painting it a bit into the future
|
//express currently running temp by painting it a bit into the future
|
||||||
Profile profileNow = profileFunction.getProfile(now);
|
Profile profileNow = profileFunction.getProfile(now);
|
||||||
|
@ -523,7 +499,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
//onset at the end
|
//onset at the end
|
||||||
Profile profileTB = profileFunction.getProfile(runningTime);
|
Profile profileTB = profileFunction.getProfile(runningTime);
|
||||||
double currentAmount = TemporaryBasalExtensionKt.convertedToAbsolute(tb2, runningTime, profileTB);
|
double currentAmount = TemporaryBasalExtensionKt.convertedToAbsolute(tb2, runningTime, profileTB);
|
||||||
temps.add(tempDatamap(now - 1 * 60 * 1000, endBasalValue, runningTime + 5 * 60 * 1000, currentAmount, currentAmount));
|
temps.add(tempDatamap(now - 60 * 1000, endBasalValue, runningTime + 5 * 60 * 1000, currentAmount, currentAmount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,31 @@
|
||||||
package info.nightscout.androidaps.database.entities
|
package info.nightscout.androidaps.database.entities
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName
|
import androidx.room.Embedded
|
||||||
import androidx.room.*
|
import androidx.room.Entity
|
||||||
|
import androidx.room.ForeignKey
|
||||||
|
import androidx.room.Index
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
import info.nightscout.androidaps.database.TABLE_GLUCOSE_VALUES
|
import info.nightscout.androidaps.database.TABLE_GLUCOSE_VALUES
|
||||||
import info.nightscout.androidaps.database.embedments.InterfaceIDs
|
import info.nightscout.androidaps.database.embedments.InterfaceIDs
|
||||||
import info.nightscout.androidaps.database.interfaces.DBEntryWithTime
|
import info.nightscout.androidaps.database.interfaces.DBEntryWithTime
|
||||||
import info.nightscout.androidaps.database.interfaces.TraceableDBEntry
|
import info.nightscout.androidaps.database.interfaces.TraceableDBEntry
|
||||||
import java.util.TimeZone
|
import java.util.*
|
||||||
|
|
||||||
@Entity(tableName = TABLE_GLUCOSE_VALUES,
|
@Entity(
|
||||||
|
tableName = TABLE_GLUCOSE_VALUES,
|
||||||
foreignKeys = [ForeignKey(
|
foreignKeys = [ForeignKey(
|
||||||
entity = GlucoseValue::class,
|
entity = GlucoseValue::class,
|
||||||
parentColumns = ["id"],
|
parentColumns = ["id"],
|
||||||
childColumns = ["referenceId"])],
|
childColumns = ["referenceId"]
|
||||||
|
)],
|
||||||
indices = [
|
indices = [
|
||||||
Index("id"),
|
Index("id"),
|
||||||
Index("nightscoutId"),
|
Index("nightscoutId"),
|
||||||
Index("sourceSensor"),
|
Index("sourceSensor"),
|
||||||
Index("referenceId"),
|
Index("referenceId"),
|
||||||
Index("timestamp")
|
Index("timestamp")
|
||||||
])
|
]
|
||||||
|
)
|
||||||
data class GlucoseValue(
|
data class GlucoseValue(
|
||||||
@PrimaryKey(autoGenerate = true)
|
@PrimaryKey(autoGenerate = true)
|
||||||
override var id: Long = 0,
|
override var id: Long = 0,
|
||||||
|
@ -51,53 +57,55 @@ data class GlucoseValue(
|
||||||
fun isRecordDeleted(other: GlucoseValue): Boolean =
|
fun isRecordDeleted(other: GlucoseValue): Boolean =
|
||||||
isValid && !other.isValid
|
isValid && !other.isValid
|
||||||
|
|
||||||
enum class TrendArrow (val text:String, val symbol:String){
|
enum class TrendArrow(val text: String, val symbol: String) {
|
||||||
@SerializedName("NONE") NONE("NONE", "??"),
|
NONE("NONE", "??"),
|
||||||
@SerializedName("TripleUp")TRIPLE_UP("TripleUp", "X"),
|
TRIPLE_UP("TripleUp", "X"),
|
||||||
@SerializedName("DoubleUp")DOUBLE_UP("DoubleUp", "\u21c8"),
|
DOUBLE_UP("DoubleUp", "\u21c8"),
|
||||||
@SerializedName("SingleUp")SINGLE_UP("SingleUp", "\u2191"),
|
SINGLE_UP("SingleUp", "\u2191"),
|
||||||
@SerializedName("FortyFiveUp")FORTY_FIVE_UP("FortyFiveUp", "\u2197"),
|
FORTY_FIVE_UP("FortyFiveUp", "\u2197"),
|
||||||
@SerializedName("Flat")FLAT("Flat", "\u2192"),
|
FLAT("Flat", "\u2192"),
|
||||||
@SerializedName("FortyFiveDown")FORTY_FIVE_DOWN("FortyFiveDown", "\u2198"),
|
FORTY_FIVE_DOWN("FortyFiveDown", "\u2198"),
|
||||||
@SerializedName("SingleDown")SINGLE_DOWN("SingleDown", "\u2193"),
|
SINGLE_DOWN("SingleDown", "\u2193"),
|
||||||
@SerializedName("DoubleDown")DOUBLE_DOWN("DoubleDown", "\u21ca"),
|
DOUBLE_DOWN("DoubleDown", "\u21ca"),
|
||||||
@SerializedName("TripleDown")TRIPLE_DOWN("TripleDown", "X")
|
TRIPLE_DOWN("TripleDown", "X")
|
||||||
;
|
;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromString(direction : String?) = values().firstOrNull {it.text == direction} ?: NONE
|
|
||||||
|
fun fromString(direction: String?) =
|
||||||
|
values().firstOrNull { it.text == direction } ?: NONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class SourceSensor(val text : String) {
|
enum class SourceSensor(val text: String) {
|
||||||
@SerializedName("AndroidAPS-Dexcom") DEXCOM_NATIVE_UNKNOWN("AndroidAPS-Dexcom"),
|
DEXCOM_NATIVE_UNKNOWN("AndroidAPS-Dexcom"),
|
||||||
@SerializedName("AndroidAPS-DexcomG6") DEXCOM_G6_NATIVE("AndroidAPS-DexcomG6"),
|
DEXCOM_G6_NATIVE("AndroidAPS-DexcomG6"),
|
||||||
@SerializedName("AndroidAPS-DexcomG5") DEXCOM_G5_NATIVE("AndroidAPS-DexcomG5"),
|
DEXCOM_G5_NATIVE("AndroidAPS-DexcomG5"),
|
||||||
@SerializedName("Bluetooth Wixel") DEXCOM_G4_WIXEL("Bluetooth Wixel"),
|
DEXCOM_G4_WIXEL("Bluetooth Wixel"),
|
||||||
@SerializedName("xBridge Wixel") DEXCOM_G4_XBRIDGE("xBridge Wixel"),
|
DEXCOM_G4_XBRIDGE("xBridge Wixel"),
|
||||||
@SerializedName("G4 Share Receiver") DEXCOM_G4_NATIVE("G4 Share Receiver"),
|
DEXCOM_G4_NATIVE("G4 Share Receiver"),
|
||||||
@SerializedName("Medtrum A6") MEDTRUM_A6("Medtrum A6"),
|
MEDTRUM_A6("Medtrum A6"),
|
||||||
@SerializedName("Network G4") DEXCOM_G4_NET("Network G4"),
|
DEXCOM_G4_NET("Network G4"),
|
||||||
@SerializedName("Network G4 and xBridge") DEXCOM_G4_NET_XBRIDGE("Network G4 and xBridge"),
|
DEXCOM_G4_NET_XBRIDGE("Network G4 and xBridge"),
|
||||||
@SerializedName("Network G4 and Classic xDrip") DEXCOM_G4_NET_CLASSIC("Network G4 and Classic xDrip"),
|
DEXCOM_G4_NET_CLASSIC("Network G4 and Classic xDrip"),
|
||||||
@SerializedName("DexcomG5") DEXCOM_G5_XDRIP("DexcomG5"),
|
DEXCOM_G5_XDRIP("DexcomG5"),
|
||||||
@SerializedName("G6 Native") DEXCOM_G6_NATIVE_XDRIP("G6 Native"),
|
DEXCOM_G6_NATIVE_XDRIP("G6 Native"),
|
||||||
@SerializedName("G5 Native") DEXCOM_G5_NATIVE_XDRIP("G5 Native"),
|
DEXCOM_G5_NATIVE_XDRIP("G5 Native"),
|
||||||
@SerializedName("G6 Native / G5 Native") DEXCOM_G6_G5_NATIVE_XDRIP("G6 Native / G5 Native"),
|
DEXCOM_G6_G5_NATIVE_XDRIP("G6 Native / G5 Native"),
|
||||||
@SerializedName("Network libre") LIBRE_1_NET("Network libre"),
|
LIBRE_1_NET("Network libre"),
|
||||||
@SerializedName("BlueReader") LIBRE_1_BLUE("BlueReader"),
|
LIBRE_1_BLUE("BlueReader"),
|
||||||
@SerializedName("Transmiter PL") LIBRE_1_PL("Transmiter PL"),
|
LIBRE_1_PL("Transmiter PL"),
|
||||||
@SerializedName("Blucon") LIBRE_1_BLUCON("Blucon"),
|
LIBRE_1_BLUCON("Blucon"),
|
||||||
@SerializedName("Tomato") LIBRE_1_TOMATO("Tomato"),
|
LIBRE_1_TOMATO("Tomato"),
|
||||||
@SerializedName("Rfduino") LIBRE_1_RF("Rfduino"),
|
LIBRE_1_RF("Rfduino"),
|
||||||
@SerializedName("LimiTTer") LIBRE_1_LIMITTER("LimiTTer"),
|
LIBRE_1_LIMITTER("LimiTTer"),
|
||||||
@SerializedName("Glimp") GLIMP("Glimp"),
|
GLIMP("Glimp"),
|
||||||
@SerializedName("Libre2") LIBRE_2_NATIVE("Libre2"),
|
LIBRE_2_NATIVE("Libre2"),
|
||||||
@SerializedName("Poctech") POCTECH_NATIVE("Poctech"),
|
POCTECH_NATIVE("Poctech"),
|
||||||
@SerializedName("MM600Series") MM_600_SERIES("MM600Series"),
|
MM_600_SERIES("MM600Series"),
|
||||||
@SerializedName("Eversense") EVERSENSE("Eversense"),
|
EVERSENSE("Eversense"),
|
||||||
@SerializedName("Random") RANDOM("Random"),
|
RANDOM("Random"),
|
||||||
@SerializedName("Unknown") UNKNOWN("Unknown"),
|
UNKNOWN("Unknown"),
|
||||||
|
|
||||||
IOB_PREDICTION("IOBPrediction"),
|
IOB_PREDICTION("IOBPrediction"),
|
||||||
A_COB_PREDICTION("aCOBPrediction"),
|
A_COB_PREDICTION("aCOBPrediction"),
|
||||||
|
|
Loading…
Reference in a new issue