wear first carbs

This commit is contained in:
AdrianLxM 2018-03-04 15:37:55 +01:00
parent ef75e2759c
commit e2b829a60a
3 changed files with 28 additions and 6 deletions

View file

@ -668,9 +668,9 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
if (lowResMode) {
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, predictionList, tempWatchDataList, basalWatchDataList, bolusWatchDataList, pointSize, midColor, gridColour, basalBackgroundColor, basalCenterColor, bolusColor, timeframe);
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, predictionList, tempWatchDataList, basalWatchDataList, bolusWatchDataList, pointSize, midColor, gridColour, basalBackgroundColor, basalCenterColor, bolusColor, 0, timeframe);
} else {
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, predictionList, tempWatchDataList, basalWatchDataList, bolusWatchDataList, pointSize, highColor, lowColor, midColor, gridColour, basalBackgroundColor, basalCenterColor, bolusColor, timeframe);
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, predictionList, tempWatchDataList, basalWatchDataList, bolusWatchDataList, pointSize, highColor, lowColor, midColor, gridColour, basalBackgroundColor, basalCenterColor, bolusColor, Color.GREEN, timeframe);
}
chart.setLineChartData(bgGraphBuilder.lineData());

View file

@ -630,9 +630,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
if (lowResMode) {
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, predictionList, tempWatchDataList, basalWatchDataList, null, pointSize, midColor, gridColor, basalBackgroundColor, basalCenterColor, bolusColor, timeframe);
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, predictionList, tempWatchDataList, basalWatchDataList, null, pointSize, midColor, gridColor, basalBackgroundColor, basalCenterColor, bolusColor, 0, timeframe);
} else {
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList,predictionList, tempWatchDataList, basalWatchDataList, null, pointSize, highColor, lowColor, midColor, gridColor, basalBackgroundColor, basalCenterColor, bolusColor, timeframe);
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList,predictionList, tempWatchDataList, basalWatchDataList, null, pointSize, highColor, lowColor, midColor, gridColor, basalBackgroundColor, basalCenterColor, bolusColor, Color.GREEN, timeframe);
}
chart.setLineChartData(bgGraphBuilder.lineData());

View file

@ -51,6 +51,8 @@ public class BgGraphBuilder {
public int basalCenterColor;
public int basalBackgroundColor;
private int bolusInvalidColor;
private int carbsColor;
public boolean singleLine = false;
private List<PointValue> inRangeValues = new ArrayList<PointValue>();
@ -60,7 +62,7 @@ public class BgGraphBuilder {
//used for low resolution screen.
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<BgWatchData> predictionsList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> bolusWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusInvalidColor, int timespan) {
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<BgWatchData> predictionsList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> bolusWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusInvalidColor, int carbsColor, int timespan) {
this.start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago
this.bgDataList = aBgList;
this.predictionsList = predictionsList;
@ -80,12 +82,13 @@ public class BgGraphBuilder {
this.basalCenterColor = basalCenterColor;
this.basalBackgroundColor = basalBackgroundColor;
this.bolusInvalidColor = bolusInvalidColor;
this.carbsColor = carbsColor;
this.end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.)
this.predictionEndTime = getPredictionEndTime();
this.end_time = (predictionEndTime>end_time)?predictionEndTime:end_time;
}
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<BgWatchData> predictionsList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> bolusWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusInvalidColor, int timespan) {
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<BgWatchData> predictionsList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> bolusWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusInvalidColor, int carbsColor, int timespan) {
this.start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago
this.bgDataList = aBgList;
this.predictionsList = predictionsList;
@ -104,6 +107,7 @@ public class BgGraphBuilder {
this.basalCenterColor = basalCenterColor;
this.basalBackgroundColor = basalBackgroundColor;
this.bolusInvalidColor = bolusInvalidColor;
this.carbsColor = carbsColor;
this.end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.)
this.predictionEndTime = getPredictionEndTime();
this.end_time = (predictionEndTime>end_time)?predictionEndTime:end_time;
@ -172,6 +176,7 @@ public class BgGraphBuilder {
lines.add(basalLine((float) minChart, factor, highlight));
lines.add(bolusLine((float) minChart));
lines.add(bolusInvalidLine((float) minChart));
lines.add(carbsLine((float) minChart));
lines.add(smbLine((float) minChart));
lines.add(predictionLine());
@ -252,6 +257,23 @@ public class BgGraphBuilder {
return line;
}
private Line carbsLine(float offset) {
List<PointValue> pointValues = new ArrayList<PointValue>();
for (BolusWatchData bwd: bolusWatchDataList) {
if(bwd.date > start_time && bwd.date <= end_time && !bwd.isSMB && bwd.isValid && bwd.carbs > 0) {
pointValues.add(new PointValue(fuzz(bwd.date), (float) offset+2));
}
}
Line line = new Line(pointValues);
line.setColor(Color.GREEN);
line.setHasLines(false);
line.setPointRadius(pointSize*2);
line.setHasPoints(true);
return line;
}
private Line predictionLine() {