From 8b378263359b62ab0f8e3973592f6b38e728fc90 Mon Sep 17 00:00:00 2001 From: Andrew Warrington Date: Wed, 3 Jan 2018 10:41:18 +0100 Subject: [PATCH] Steampunk watch face - improvement of the units switching functionality (less time spent on "?" on glucose dial). --- .../wearintegration/WatchUpdaterService.java | 4 +--- .../androidaps/watchfaces/Steampunk.java | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index 1e54dace20..91045ba4d6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -243,19 +243,17 @@ public class WatchUpdaterService extends WearableListenerService implements DataMap dataMap = new DataMap(); dataMap.putString("sgvString", lastBG.valueToUnitsToString(units)); + dataMap.putString("glucoseUnits", units); dataMap.putLong("timestamp", lastBG.date); if (glucoseStatus == null) { dataMap.putString("slopeArrow", ""); dataMap.putString("delta", "--"); dataMap.putString("avgDelta", "--"); - dataMap.putString("glucoseUnits", "-"); } else { dataMap.putString("slopeArrow", slopeArrow(glucoseStatus.delta)); dataMap.putString("delta", deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units)); dataMap.putString("avgDelta", deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, units)); - dataMap.putString("glucoseUnits", units); } - dataMap.putLong("sgvLevel", sgvLevel); dataMap.putDouble("sgvDouble", lastBG.value); dataMap.putDouble("high", highLine); diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java index 9d8dc13239..e28a0eeca6 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java @@ -69,27 +69,31 @@ public class Steampunk extends BaseWatchFace { } if (!sSgv.equals("---")) { - //ensure the glucose dial is the correct units + + float rotationAngle = 0f; //by default, show ? on the dial (? is at 0 degrees on the dial) + if (!sUnits.equals("-")) { + + //ensure the glucose dial is the correct units if (sUnits.equals("mmol")) { mGlucoseDial.setImageResource(R.drawable.steampunk_dial_mmol); } else { mGlucoseDial.setImageResource(R.drawable.steampunk_dial_mgdl); } - } - //rotate glucose dial - float rotationAngle = 0f; //by default, show ? on the dial (? is at 0 degrees on the dial) - if (sUnits.equals("mmol")) { - rotationAngle = Float.valueOf(sSgv) * 18f; //convert to mg/dL, which is equivalent to degrees - } else { - if (!sUnits.equals("-")) { + //convert the Sgv to degrees of rotation + if (sUnits.equals("mmol")) { + rotationAngle = Float.valueOf(sSgv) * 18f; //convert to mg/dL, which is equivalent to degrees + } else { rotationAngle = Float.valueOf(sSgv); //if glucose a value is received, use it to determine the amount of rotation of the dial. } + } + if (rotationAngle > 330) rotationAngle = 330; //if the glucose value is higher than 330 then show "HIGH" on the dial. ("HIGH" is at 330 degrees on the dial) if (rotationAngle != 0 && rotationAngle < 30) rotationAngle = 30; //if the glucose value is lower than 30 show "LOW" on the dial. ("LOW" is at 30 degrees on the dial) + //rotate glucose dial RotateAnimation rotate = new RotateAnimation( lastEndDegrees, rotationAngle - lastEndDegrees, Animation.RELATIVE_TO_SELF, 0.5f,