Steampunk watch face - improvement of the units switching functionality (less time spent on "?" on glucose dial).
This commit is contained in:
parent
37f262efdc
commit
8b37826335
|
@ -243,19 +243,17 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
|
|
||||||
DataMap dataMap = new DataMap();
|
DataMap dataMap = new DataMap();
|
||||||
dataMap.putString("sgvString", lastBG.valueToUnitsToString(units));
|
dataMap.putString("sgvString", lastBG.valueToUnitsToString(units));
|
||||||
|
dataMap.putString("glucoseUnits", units);
|
||||||
dataMap.putLong("timestamp", lastBG.date);
|
dataMap.putLong("timestamp", lastBG.date);
|
||||||
if (glucoseStatus == null) {
|
if (glucoseStatus == null) {
|
||||||
dataMap.putString("slopeArrow", "");
|
dataMap.putString("slopeArrow", "");
|
||||||
dataMap.putString("delta", "--");
|
dataMap.putString("delta", "--");
|
||||||
dataMap.putString("avgDelta", "--");
|
dataMap.putString("avgDelta", "--");
|
||||||
dataMap.putString("glucoseUnits", "-");
|
|
||||||
} else {
|
} else {
|
||||||
dataMap.putString("slopeArrow", slopeArrow(glucoseStatus.delta));
|
dataMap.putString("slopeArrow", slopeArrow(glucoseStatus.delta));
|
||||||
dataMap.putString("delta", deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units));
|
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("avgDelta", deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, units));
|
||||||
dataMap.putString("glucoseUnits", units);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dataMap.putLong("sgvLevel", sgvLevel);
|
dataMap.putLong("sgvLevel", sgvLevel);
|
||||||
dataMap.putDouble("sgvDouble", lastBG.value);
|
dataMap.putDouble("sgvDouble", lastBG.value);
|
||||||
dataMap.putDouble("high", highLine);
|
dataMap.putDouble("high", highLine);
|
||||||
|
|
|
@ -69,27 +69,31 @@ public class Steampunk extends BaseWatchFace {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sSgv.equals("---")) {
|
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("-")) {
|
if (!sUnits.equals("-")) {
|
||||||
|
|
||||||
|
//ensure the glucose dial is the correct units
|
||||||
if (sUnits.equals("mmol")) {
|
if (sUnits.equals("mmol")) {
|
||||||
mGlucoseDial.setImageResource(R.drawable.steampunk_dial_mmol);
|
mGlucoseDial.setImageResource(R.drawable.steampunk_dial_mmol);
|
||||||
} else {
|
} else {
|
||||||
mGlucoseDial.setImageResource(R.drawable.steampunk_dial_mgdl);
|
mGlucoseDial.setImageResource(R.drawable.steampunk_dial_mgdl);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//rotate glucose dial
|
//convert the Sgv to degrees of rotation
|
||||||
float rotationAngle = 0f; //by default, show ? on the dial (? is at 0 degrees on the dial)
|
if (sUnits.equals("mmol")) {
|
||||||
if (sUnits.equals("mmol")) {
|
rotationAngle = Float.valueOf(sSgv) * 18f; //convert to mg/dL, which is equivalent to degrees
|
||||||
rotationAngle = Float.valueOf(sSgv) * 18f; //convert to mg/dL, which is equivalent to degrees
|
} else {
|
||||||
} else {
|
|
||||||
if (!sUnits.equals("-")) {
|
|
||||||
rotationAngle = Float.valueOf(sSgv); //if glucose a value is received, use it to determine the amount of rotation of the dial.
|
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 > 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)
|
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(
|
RotateAnimation rotate = new RotateAnimation(
|
||||||
lastEndDegrees, rotationAngle - lastEndDegrees,
|
lastEndDegrees, rotationAngle - lastEndDegrees,
|
||||||
Animation.RELATIVE_TO_SELF, 0.5f,
|
Animation.RELATIVE_TO_SELF, 0.5f,
|
||||||
|
|
Loading…
Reference in a new issue