From 2b17fc5155cd384e3a8a2468ec93b549fa610043 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Fri, 18 Nov 2016 01:35:46 +0100 Subject: [PATCH] wear painting temps --- .../wearintegration/WatchUpdaterService.java | 18 ++++++++++-------- .../nightscout/androidaps/BgGraphBuilder.java | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 17 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 27b215e136..3328e58406 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 @@ -250,36 +250,38 @@ public class WatchUpdaterService extends WearableListenerService implements long startTime = System.currentTimeMillis() - (long)(60000 * 60 * 5.5); + ArrayList basals = new ArrayList<>(); //TODO: Adrian: replace fake data long from = startTime; - long to = (System.currentTimeMillis()+ startTime)/2; + long now = System.currentTimeMillis(); + long to = (now + from)/2; double amount = 0.5; double afterwards = 0.8; basals.add(basalMap(from, to, amount, afterwards)); from = to; - to = System.currentTimeMillis(); + to = now; amount = 0.8; basals.add(basalMap(from, to, amount, amount)); ArrayList temps = new ArrayList<>(); - from = (long)(startTime + (1/8d)*(to - startTime)); + from = (long)(startTime + (1/8d)*(now - startTime)); double fromBasal = 0.5; - to = (long)(startTime + (2/8d)*(to - startTime)); + to = (long)(startTime + (2/8d)*(now - startTime)); double toBasal = 0.5; amount = 3; temps.add(tempDatamap(from, fromBasal, to, toBasal, amount)); - from = (long)(startTime + (6/8d)*(to - startTime)); - fromBasal = 0; - to = (long)(startTime + (7/8d)*(to - startTime)); - toBasal = 0; + from = (long)(startTime + (6/8d)*(now - startTime)); + fromBasal = 0.8; + to = (long)(startTime + (7/8d)*(now - startTime)); + toBasal = 0.8; amount = 0; temps.add(tempDatamap(from, fromBasal, to, toBasal, amount)); diff --git a/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java b/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java index 006eede27e..411a3d2475 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java +++ b/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java @@ -116,9 +116,11 @@ public class BgGraphBuilder { double factor = (maxChart-minChart)/maxTemp; // in case basal is the highest, don't paint it totally at the top. factor = Math.min(factor, ((maxChart-minChart)/maxTemp)*(2/3d)); - - lines.add(tempValuesLine((float) minChart, factor)); - + for (TempWatchData twd: tempWatchDataList) { + if(twd.endTime > start_time) { + lines.add(tempValuesLine(twd, (float) minChart, factor)); + } + } return lines; } @@ -157,16 +159,15 @@ public class BgGraphBuilder { } - public Line tempValuesLine(float offset, double factor) { + public Line tempValuesLine(TempWatchData twd, float offset, double factor) { List lineValues = new ArrayList(); - - for (TempWatchData twd: tempWatchDataList) { - lineValues.add(new PointValue(fuzz(twd.startTime), offset + (float)(factor*twd.startBasal))); - lineValues.add(new PointValue(fuzz(twd.startTime), offset +(float)(factor*twd.amount))); + long begin = (long) Math.max(start_time, twd.startTime); + lineValues.add(new PointValue(fuzz(begin), offset + (float)(factor*twd.startBasal))); + lineValues.add(new PointValue(fuzz(begin), offset +(float)(factor*twd.amount))); lineValues.add(new PointValue(fuzz(twd.endTime), offset + (float)(factor*twd.amount))); lineValues.add(new PointValue(fuzz(twd.endTime), offset + (float)(factor*twd.endBasal))); - } + Line valueLine = new Line(lineValues); valueLine.setHasPoints(false);