Send OpenAPS timestamp to watch rather than minAgo, for more accurate updates on watch face.
This commit is contained in:
parent
cefe93d0a0
commit
9dca53f968
3 changed files with 21 additions and 21 deletions
|
@ -264,8 +264,8 @@ public class NSDeviceStatus {
|
||||||
JSONObject enacted = openaps.has("enacted") ? openaps.getJSONObject("enacted") : new JSONObject();
|
JSONObject enacted = openaps.has("enacted") ? openaps.getJSONObject("enacted") : new JSONObject();
|
||||||
|
|
||||||
long clock = 0L;
|
long clock = 0L;
|
||||||
if (suggested.has("timestamp"))
|
if (suggested.has("deliverAt"))
|
||||||
clock = DateUtil.fromISODateString(suggested.getString("timestamp")).getTime();
|
clock = DateUtil.fromISODateString(suggested.getString("deliverAt")).getTime();
|
||||||
// check if this is new data
|
// check if this is new data
|
||||||
if (clock != 0 && clock > deviceStatusOpenAPSData.clockSuggested) {
|
if (clock != 0 && clock > deviceStatusOpenAPSData.clockSuggested) {
|
||||||
deviceStatusOpenAPSData.suggested = suggested;
|
deviceStatusOpenAPSData.suggested = suggested;
|
||||||
|
@ -308,6 +308,15 @@ public class NSDeviceStatus {
|
||||||
return Html.fromHtml(string.toString());
|
return Html.fromHtml(string.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double getOpenApsTimestamp() {
|
||||||
|
|
||||||
|
if (deviceStatusOpenAPSData.clockSuggested != 0) {
|
||||||
|
return deviceStatusOpenAPSData.clockSuggested;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Spanned getExtendedOpenApsStatus() {
|
public Spanned getExtendedOpenApsStatus() {
|
||||||
StringBuilder string = new StringBuilder();
|
StringBuilder string = new StringBuilder();
|
||||||
|
|
||||||
|
|
|
@ -552,13 +552,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
String rigBattery = NSDeviceStatus.getInstance().getUploaderStatus().trim();
|
String rigBattery = NSDeviceStatus.getInstance().getUploaderStatus().trim();
|
||||||
|
|
||||||
//OpenAPS status
|
//OpenAPS status
|
||||||
String openApsString = String.valueOf(NSDeviceStatus.getInstance().getOpenApsStatus());
|
Double openApsStatus = NSDeviceStatus.getOpenApsTimestamp();
|
||||||
String openApsStatus = "";
|
|
||||||
if(openApsString != null) {
|
|
||||||
int index = openApsString.indexOf("m");
|
|
||||||
if(index > 0)
|
|
||||||
openApsStatus = openApsString.substring(0, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_STATUS_PATH);
|
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_STATUS_PATH);
|
||||||
//unique content
|
//unique content
|
||||||
|
@ -570,7 +564,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
dataMapRequest.getDataMap().putString("tempBasal", tempBasal);
|
dataMapRequest.getDataMap().putString("tempBasal", tempBasal);
|
||||||
dataMapRequest.getDataMap().putString("battery", "" + phoneBattery);
|
dataMapRequest.getDataMap().putString("battery", "" + phoneBattery);
|
||||||
dataMapRequest.getDataMap().putString("rigBattery", rigBattery);
|
dataMapRequest.getDataMap().putString("rigBattery", rigBattery);
|
||||||
dataMapRequest.getDataMap().putString("openApsStatus", openApsStatus);
|
dataMapRequest.getDataMap().putDouble("openApsStatus", openApsStatus);
|
||||||
dataMapRequest.getDataMap().putString("bgi", bgiString);
|
dataMapRequest.getDataMap().putString("bgi", bgiString);
|
||||||
dataMapRequest.getDataMap().putBoolean("showBgi", mPrefs.getBoolean("wear_showbgi", false));
|
dataMapRequest.getDataMap().putBoolean("showBgi", mPrefs.getBoolean("wear_showbgi", false));
|
||||||
dataMapRequest.getDataMap().putInt("batteryLevel", (phoneBattery >= 30) ? 1 : 0);
|
dataMapRequest.getDataMap().putInt("batteryLevel", (phoneBattery >= 30) ? 1 : 0);
|
||||||
|
|
|
@ -85,7 +85,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
|
|
||||||
public boolean detailedIOB = false;
|
public boolean detailedIOB = false;
|
||||||
public boolean showBGI = false;
|
public boolean showBGI = false;
|
||||||
public String openApsStatus = "0";
|
public Double openApsStatus;
|
||||||
public String externalStatusString = "no status";
|
public String externalStatusString = "no status";
|
||||||
public String sSgv = "---";
|
public String sSgv = "---";
|
||||||
public String sDirection = "--";
|
public String sDirection = "--";
|
||||||
|
@ -267,8 +267,8 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
sBgi = dataMap.getString("bgi");
|
sBgi = dataMap.getString("bgi");
|
||||||
showBGI = dataMap.getBoolean("showBgi");
|
showBGI = dataMap.getBoolean("showBgi");
|
||||||
externalStatusString = dataMap.getString("externalStatusString");
|
externalStatusString = dataMap.getString("externalStatusString");
|
||||||
openApsStatus = dataMap.getString("openApsStatus");
|
|
||||||
batteryLevel = dataMap.getInt("batteryLevel");
|
batteryLevel = dataMap.getInt("batteryLevel");
|
||||||
|
openApsStatus = dataMap.getDouble("openApsStatus");
|
||||||
}
|
}
|
||||||
|
|
||||||
setDataFields();
|
setDataFields();
|
||||||
|
@ -453,18 +453,15 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
if (mLoop != null) {
|
if (mLoop != null) {
|
||||||
if (sharedPrefs.getBoolean("showExternalStatus", true)) {
|
if (sharedPrefs.getBoolean("showExternalStatus", true)) {
|
||||||
mLoop.setVisibility(View.VISIBLE);
|
mLoop.setVisibility(View.VISIBLE);
|
||||||
if (openApsStatus != null && openApsStatus != "") {
|
if (openApsStatus != null) {
|
||||||
mLoop.setText(openApsStatus + "'");
|
int mins = (int) ((System.currentTimeMillis() - openApsStatus) / 1000 / 60);
|
||||||
if (Integer.valueOf(openApsStatus) > 14) {
|
mLoop.setText(mins + "'");
|
||||||
|
if (mins > 14) {
|
||||||
loopLevel = 0;
|
loopLevel = 0;
|
||||||
//if (getCurrentWatchMode() == WatchMode.INTERACTIVE) {
|
mLoop.setBackgroundResource(R.drawable.loop_red_25);
|
||||||
mLoop.setBackgroundResource(R.drawable.loop_red_25);
|
|
||||||
//}
|
|
||||||
} else {
|
} else {
|
||||||
loopLevel = 1;
|
loopLevel = 1;
|
||||||
//if (getCurrentWatchMode() == WatchMode.INTERACTIVE) {
|
mLoop.setBackgroundResource(R.drawable.loop_green_25);
|
||||||
mLoop.setBackgroundResource(R.drawable.loop_green_25);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mLoop.setText("-'");
|
mLoop.setText("-'");
|
||||||
|
|
Loading…
Reference in a new issue