Java Code Examples for com.eveningoutpost.dexdrip.UtilityModels.Constants#MGDL_TO_MMOLL
The following examples show how to use
com.eveningoutpost.dexdrip.UtilityModels.Constants#MGDL_TO_MMOLL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LibreTrendGraph.java From xDrip with GNU General Public License v3.0 | 6 votes |
public static List<PointValue> getTrendDataPointsOld(boolean doMgdl, long start_time, long end_time) { // TODO needs to cut off if would exceed the current graph scope final float conversion_factor_mmol = (float) (doMgdl ? 1 : Constants.MGDL_TO_MMOLL); final LibreBlock libreBlock= LibreBlock.getLatestForTrend(start_time, end_time ); if (libreBlock != null) { final ArrayList<Float> bg_data = getLatestBg(libreBlock); if (bg_data != null) { final ArrayList<PointValue> points = new ArrayList<>(bg_data.size()); long time_offset = 0; for (Float bg : bg_data) { points.add(new PointValue((float) ((libreBlock.timestamp - time_offset) / FUZZER), bg * conversion_factor_mmol)); time_offset += Constants.MINUTE_IN_MS; } return points; } } return null; }
Example 2
Source File: LibreTrendGraph.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
public static List<PointValue> getTrendDataPointsOld(boolean doMgdl, long start_time, long end_time) { // TODO needs to cut off if would exceed the current graph scope final float conversion_factor_mmol = (float) (doMgdl ? 1 : Constants.MGDL_TO_MMOLL); final LibreBlock libreBlock= LibreBlock.getLatestForTrend(start_time, end_time ); if (libreBlock != null) { final ArrayList<Float> bg_data = getLatestBg(libreBlock); if (bg_data != null) { final ArrayList<PointValue> points = new ArrayList<>(bg_data.size()); long time_offset = 0; for (Float bg : bg_data) { points.add(new PointValue((float) ((libreBlock.timestamp - time_offset) / FUZZER), bg * conversion_factor_mmol)); time_offset += Constants.MINUTE_IN_MS; } return points; } } return null; }
Example 3
Source File: LibreTrendGraph.java From xDrip with GNU General Public License v3.0 | 5 votes |
public static List<PointValue> getTrendDataPoints(boolean doMgdl, long start_time, long end_time) { // TODO needs to cut off if would exceed the current graph scope final float conversion_factor_mmol = (float) (doMgdl ? 1 : Constants.MGDL_TO_MMOLL); ArrayList<Float> bg_data = getLatestBgForXMinutes((int) ((end_time - start_time) / Constants.MINUTE_IN_MS) ); if (bg_data == null) { Log.e(TAG, "Error getting data from getLatestBgForXMinutes. Returning"); return null; } LibreTrendLatest libreTrendLatest = LibreTrendUtil.getInstance().getLibreTrendLatest(); if(libreTrendLatest.glucoseLevelRaw == 0) { Log.e(TAG, "libreBlock exists but libreTrendLatest.glucoseLevelRaw is zero "); return null; } final ArrayList<PointValue> points = new ArrayList<>(bg_data.size()); long time_offset = 0; //int i = 0; for (Float bg : bg_data) { if(bg <= 0) { time_offset += Constants.MINUTE_IN_MS; continue; } long bg_time = libreTrendLatest.timestamp - time_offset; if (bg_time <= end_time && bg_time >= start_time) { double time = (double) ((double)(bg_time) / FUZZER); points.add(new PointValue((float) ((double)(bg_time) / FUZZER), bg * conversion_factor_mmol)); } time_offset += Constants.MINUTE_IN_MS; } return points; }
Example 4
Source File: LibreTrendGraph.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public static List<PointValue> getTrendDataPoints(boolean doMgdl, long start_time, long end_time) { // TODO needs to cut off if would exceed the current graph scope final float conversion_factor_mmol = (float) (doMgdl ? 1 : Constants.MGDL_TO_MMOLL); ArrayList<Float> bg_data = getLatestBgForXMinutes((int) ((end_time - start_time) / Constants.MINUTE_IN_MS) ); if (bg_data == null) { Log.e(TAG, "Error getting data from getLatestBgForXMinutes. Returning"); return null; } LibreTrendLatest libreTrendLatest = LibreTrendUtil.getInstance().getLibreTrendLatest(); if(libreTrendLatest.glucoseLevelRaw == 0) { Log.e(TAG, "libreBlock exists but libreTrendLatest.glucoseLevelRaw is zero "); return null; } final ArrayList<PointValue> points = new ArrayList<>(bg_data.size()); long time_offset = 0; //int i = 0; for (Float bg : bg_data) { if(bg <= 0) { time_offset += Constants.MINUTE_IN_MS; continue; } long bg_time = libreTrendLatest.timestamp - time_offset; if (bg_time <= end_time && bg_time >= start_time) { double time = (double) ((double)(bg_time) / FUZZER); points.add(new PointValue((float) ((double)(bg_time) / FUZZER), bg * conversion_factor_mmol)); } time_offset += Constants.MINUTE_IN_MS; } return points; }
Example 5
Source File: BgGraphBuilder.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public static double mmolConvert(double mgdl) { return mgdl * Constants.MGDL_TO_MMOLL; }
Example 6
Source File: BgReading.java From xDrip with GNU General Public License v3.0 | 4 votes |
public double mmolConvert(double mgdl) { return mgdl * Constants.MGDL_TO_MMOLL; }
Example 7
Source File: BgReading.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
public double mmolConvert(double mgdl) { return mgdl * Constants.MGDL_TO_MMOLL; }
Example 8
Source File: CalibrationGraph.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
@NonNull public List<Line> getCalibrationsLine(List<Calibration> calibrations, int color) { if (calibrations == null) return new ArrayList<>(); List<PointValue> values = new ArrayList<PointValue>(); List<PointValue> valuesb = new ArrayList<PointValue>(); List<PointValue> valuesc = new ArrayList<PointValue>(); for (Calibration calibration : calibrations) { if (calibration.estimate_raw_at_time_of_calibration > end_x) { end_x = calibration.estimate_raw_at_time_of_calibration; } PointValue point = new PointValue((float) calibration.estimate_raw_at_time_of_calibration, doMgdl ? (float) calibration.bg : ((float) calibration.bg) * (float) Constants.MGDL_TO_MMOLL); PointValue pointb = new PointValue((float) calibration.raw_value, doMgdl ? (float) calibration.bg : ((float) calibration.bg) * (float) Constants.MGDL_TO_MMOLL); PointValue pointc = new PointValue((float) calibration.adjusted_raw_value, doMgdl ? (float) calibration.bg : ((float) calibration.bg) * (float) Constants.MGDL_TO_MMOLL); String time; if (show_days_since) { final int days_ago = daysAgo(calibration.raw_timestamp); time = (days_ago > 0) ? Integer.toString(days_ago) + "d " : ""; time = time + (JoH.hourMinuteString(calibration.raw_timestamp)); } else { time = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date((long) calibration.raw_timestamp)); } point.setLabel(time); values.add(point); // extra points showing real raw and age_adjusted raw for each calbration point valuesb.add(pointb); valuesc.add(pointc); } Line line = new Line(values); line.setColor(color); line.setHasLines(false); line.setPointRadius(4); line.setHasPoints(true); line.setHasLabels(true); List<Line> lines = new ArrayList<>(); lines.add(line); if (Pref.getBooleanDefaultFalse("engineering_mode")) { // actual raw Line lineb = new Line(valuesb); lineb.setColor(Color.RED); lineb.setHasLines(false); lineb.setPointRadius(1); lineb.setHasPoints(true); lineb.setHasLabels(false); // age adjusted raw Line linec = new Line(valuesc); linec.setColor(Color.YELLOW); linec.setHasLines(false); linec.setPointRadius(1); linec.setHasPoints(true); linec.setHasLabels(false); lines.add(lineb); lines.add(linec); } return lines; }
Example 9
Source File: CalibrationGraph.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public void setupCharts() { chart = (LineChartView) findViewById(R.id.chart); List<Line> lines = new ArrayList<Line>(); //calibration values List<Calibration> calibrations = Calibration.allForSensor(); List<Line> greyLines = getCalibrationsLine(calibrations, Color.parseColor("#66FFFFFF")); calibrations = Calibration.allForSensorInLastFourDays(); List<Line> blueLines = getCalibrationsLine(calibrations, ChartUtils.COLOR_BLUE); Calibration calibration = Calibration.lastValid(); if (calibration != null) { //set header DecimalFormat df = new DecimalFormat("#"); df.setMaximumFractionDigits(2); df.setMinimumFractionDigits(2); String Header = "slope = " + df.format(calibration.slope) + " intercept = " + df.format(calibration.intercept); GraphHeader.setText(Header); //red line List<PointValue> lineValues = new ArrayList<PointValue>(); final float conversion_factor = (float) (doMgdl ? 1 : Constants.MGDL_TO_MMOLL); lineValues.add(new PointValue((float) start_x, (conversion_factor * (float) (start_x * calibration.slope + calibration.intercept)))); lineValues.add(new PointValue((float) end_x, (conversion_factor * (float) (end_x * calibration.slope + calibration.intercept)))); Line calibrationLine = new Line(lineValues); calibrationLine.setColor(ChartUtils.COLOR_RED); calibrationLine.setHasLines(true); calibrationLine.setHasPoints(false); lines.add(calibrationLine); // calibration plugin final CalibrationAbstract plugin = getCalibrationPluginFromPreferences(); if (plugin != null) { final CalibrationAbstract.CalibrationData pcalibration = plugin.getCalibrationData(); final List<PointValue> plineValues = new ArrayList<PointValue>(); plineValues.add(new PointValue((float) start_x, (conversion_factor * (float) (plugin.getGlucoseFromSensorValue(start_x, pcalibration))))); plineValues.add(new PointValue((float) end_x, (conversion_factor * (float) (plugin.getGlucoseFromSensorValue(end_x, pcalibration))))); final Line pcalibrationLine = new Line(plineValues); pcalibrationLine.setColor(Color.parseColor(plugin_color)); pcalibrationLine.setHasLines(true); pcalibrationLine.setHasPoints(false); lines.add(pcalibrationLine); PluginHeader.setText("(" + plugin.getAlgorithmName() + ") " + "s = " + df.format(pcalibration.slope) + " i = " + df.format(pcalibration.intercept)); PluginHeader.setTextColor(Color.parseColor(plugin_color)); } //add lines in order for (Line greyLine : greyLines) { lines.add(greyLine); } for (Line blueLine : blueLines) { lines.add(blueLine); } } Axis axisX = new Axis(); Axis axisY = new Axis().setHasLines(true); axisX.setName("Raw Value"); axisY.setName("Glucose " + (doMgdl ? "mg/dl" : "mmol/l")); data = new LineChartData(lines); data.setAxisXBottom(axisX); data.setAxisYLeft(axisY); chart.setLineChartData(data); }
Example 10
Source File: LibreTrendGraph.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public void setupCharts() { final TextView trendView = (TextView) findViewById(R.id.textLibreHeader); chart = (LineChartView) findViewById(R.id.libre_chart); List<Line> lines = new ArrayList<Line>(); List<PointValue> lineValues = new ArrayList<PointValue>(); final float conversion_factor_mmol = (float) (doMgdl ? 1 : Constants.MGDL_TO_MMOLL); LibreBlock libreBlock= LibreBlock.getLatestForTrend(); if(libreBlock == null) { trendView.setText("No libre data to display"); setupEmptyCharts(); return; } String time = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date((long) libreBlock.timestamp)); ArrayList<Float> bg_data = getLatestBgForXMinutes(MINUTES_TO_DISPLAY); if(bg_data == null) { trendView.setText("Error displaying data for " + time); setupEmptyCharts(); return; } trendView.setText("Scan from " + time); float min = 1000; float max = 0; int i = 0; for(float bg : bg_data ) { if(bg <= 0) { i++; continue; } if(min > bg) { min = bg; } if(max < bg) { max = bg; } lineValues.add(new PointValue(-i, bg * conversion_factor_mmol)); i++; } Line trendLine = new Line(lineValues); trendLine.setColor(ChartUtils.COLOR_RED); trendLine.setHasLines(false); trendLine.setHasPoints(true); trendLine.setPointRadius(3); lines.add(trendLine); final int MIN_GRAPH = 20; if(max - min < MIN_GRAPH) { // On relative flat trend the graph can look very noise althouth with the right resolution it is not that way. // I will add two dummy invisible points that will cause the graph to look with bigger Y range. float average = (max + min) /2; List<PointValue> dummyPointValues = new ArrayList<PointValue>(); Line dummyPointLine = new Line(dummyPointValues); dummyPointValues.add(new PointValue(0, (average - MIN_GRAPH / 2) * conversion_factor_mmol)); dummyPointValues.add(new PointValue(0, (average + MIN_GRAPH / 2) * conversion_factor_mmol)); dummyPointLine.setColor(ChartUtils.COLOR_RED); dummyPointLine.setHasLines(false); dummyPointLine.setHasPoints(false); lines.add(dummyPointLine); } Axis axisX = new Axis(); Axis axisY = new Axis().setHasLines(true); axisX.setTextSize(16); axisY.setTextSize(16); axisX.setName("Time from last scan"); axisY.setName("Glucose " + (doMgdl ? "mg/dl" : "mmol/l")); data = new LineChartData(lines); data.setAxisXBottom(axisX); data.setAxisYLeft(axisY); chart.setLineChartData(data); }
Example 11
Source File: BgReading.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public double mmolConvert(double mgdl) { return mgdl * Constants.MGDL_TO_MMOLL; }
Example 12
Source File: BgReading.java From xDrip with GNU General Public License v3.0 | 4 votes |
public double mmolConvert(double mgdl) { return mgdl * Constants.MGDL_TO_MMOLL; }
Example 13
Source File: BgReading.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public double mmolConvert(double mgdl) { return mgdl * Constants.MGDL_TO_MMOLL; }
Example 14
Source File: CalibrationGraph.java From xDrip with GNU General Public License v3.0 | 4 votes |
@NonNull public List<Line> getCalibrationsLine(List<Calibration> calibrations, int color) { if (calibrations == null) return new ArrayList<>(); List<PointValue> values = new ArrayList<PointValue>(); List<PointValue> valuesb = new ArrayList<PointValue>(); List<PointValue> valuesc = new ArrayList<PointValue>(); for (Calibration calibration : calibrations) { if (calibration.estimate_raw_at_time_of_calibration > end_x) { end_x = calibration.estimate_raw_at_time_of_calibration; } PointValue point = new PointValue((float) calibration.estimate_raw_at_time_of_calibration, doMgdl ? (float) calibration.bg : ((float) calibration.bg) * (float) Constants.MGDL_TO_MMOLL); PointValue pointb = new PointValue((float) calibration.raw_value, doMgdl ? (float) calibration.bg : ((float) calibration.bg) * (float) Constants.MGDL_TO_MMOLL); PointValue pointc = new PointValue((float) calibration.adjusted_raw_value, doMgdl ? (float) calibration.bg : ((float) calibration.bg) * (float) Constants.MGDL_TO_MMOLL); String time; if (show_days_since) { final int days_ago = daysAgo(calibration.raw_timestamp); time = (days_ago > 0) ? Integer.toString(days_ago) + "d " : ""; time = time + (JoH.hourMinuteString(calibration.raw_timestamp)); } else { time = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date((long) calibration.raw_timestamp)); } point.setLabel(time); values.add(point); // extra points showing real raw and age_adjusted raw for each calbration point valuesb.add(pointb); valuesc.add(pointc); } Line line = new Line(values); line.setColor(color); line.setHasLines(false); line.setPointRadius(4); line.setHasPoints(true); line.setHasLabels(true); List<Line> lines = new ArrayList<>(); lines.add(line); if (Pref.getBooleanDefaultFalse("engineering_mode")) { // actual raw Line lineb = new Line(valuesb); lineb.setColor(Color.RED); lineb.setHasLines(false); lineb.setPointRadius(1); lineb.setHasPoints(true); lineb.setHasLabels(false); // age adjusted raw Line linec = new Line(valuesc); linec.setColor(Color.YELLOW); linec.setHasLines(false); linec.setPointRadius(1); linec.setHasPoints(true); linec.setHasLabels(false); lines.add(lineb); lines.add(linec); } return lines; }
Example 15
Source File: CalibrationGraph.java From xDrip with GNU General Public License v3.0 | 4 votes |
public void setupCharts() { chart = (LineChartView) findViewById(R.id.chart); List<Line> lines = new ArrayList<Line>(); //calibration values List<Calibration> calibrations = Calibration.allForSensor(); List<Line> greyLines = getCalibrationsLine(calibrations, Color.parseColor("#66FFFFFF")); calibrations = Calibration.allForSensorInLastFourDays(); List<Line> blueLines = getCalibrationsLine(calibrations, ChartUtils.COLOR_BLUE); Calibration calibration = Calibration.lastValid(); if (calibration != null) { //set header DecimalFormat df = new DecimalFormat("#"); df.setMaximumFractionDigits(2); df.setMinimumFractionDigits(2); String Header = "slope = " + df.format(calibration.slope) + " intercept = " + df.format(calibration.intercept); GraphHeader.setText(Header); //red line List<PointValue> lineValues = new ArrayList<PointValue>(); final float conversion_factor = (float) (doMgdl ? 1 : Constants.MGDL_TO_MMOLL); lineValues.add(new PointValue((float) start_x, (conversion_factor * (float) (start_x * calibration.slope + calibration.intercept)))); lineValues.add(new PointValue((float) end_x, (conversion_factor * (float) (end_x * calibration.slope + calibration.intercept)))); Line calibrationLine = new Line(lineValues); calibrationLine.setColor(ChartUtils.COLOR_RED); calibrationLine.setHasLines(true); calibrationLine.setHasPoints(false); lines.add(calibrationLine); // calibration plugin final CalibrationAbstract plugin = getCalibrationPluginFromPreferences(); if (plugin != null) { final CalibrationAbstract.CalibrationData pcalibration = plugin.getCalibrationData(); final List<PointValue> plineValues = new ArrayList<PointValue>(); plineValues.add(new PointValue((float) start_x, (conversion_factor * (float) (plugin.getGlucoseFromSensorValue(start_x, pcalibration))))); plineValues.add(new PointValue((float) end_x, (conversion_factor * (float) (plugin.getGlucoseFromSensorValue(end_x, pcalibration))))); final Line pcalibrationLine = new Line(plineValues); pcalibrationLine.setColor(Color.parseColor(plugin_color)); pcalibrationLine.setHasLines(true); pcalibrationLine.setHasPoints(false); lines.add(pcalibrationLine); PluginHeader.setText("(" + plugin.getAlgorithmName() + ") " + "s = " + df.format(pcalibration.slope) + " i = " + df.format(pcalibration.intercept)); PluginHeader.setTextColor(Color.parseColor(plugin_color)); } //add lines in order for (Line greyLine : greyLines) { lines.add(greyLine); } for (Line blueLine : blueLines) { lines.add(blueLine); } } Axis axisX = new Axis(); Axis axisY = new Axis().setHasLines(true); axisX.setName("Raw Value"); axisY.setName("Glucose " + (doMgdl ? "mg/dl" : "mmol/l")); data = new LineChartData(lines); data.setAxisXBottom(axisX); data.setAxisYLeft(axisY); chart.setLineChartData(data); }
Example 16
Source File: LibreTrendGraph.java From xDrip with GNU General Public License v3.0 | 4 votes |
public void setupCharts() { final TextView trendView = (TextView) findViewById(R.id.textLibreHeader); chart = (LineChartView) findViewById(R.id.libre_chart); List<Line> lines = new ArrayList<Line>(); List<PointValue> lineValues = new ArrayList<PointValue>(); final float conversion_factor_mmol = (float) (doMgdl ? 1 : Constants.MGDL_TO_MMOLL); LibreBlock libreBlock= LibreBlock.getLatestForTrend(); if(libreBlock == null) { trendView.setText("No libre data to display"); setupEmptyCharts(); return; } String time = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date((long) libreBlock.timestamp)); ArrayList<Float> bg_data = getLatestBgForXMinutes(MINUTES_TO_DISPLAY); if(bg_data == null) { trendView.setText("Error displaying data for " + time); setupEmptyCharts(); return; } trendView.setText("Scan from " + time); float min = 1000; float max = 0; int i = 0; for(float bg : bg_data ) { if(bg <= 0) { i++; continue; } if(min > bg) { min = bg; } if(max < bg) { max = bg; } lineValues.add(new PointValue(-i, bg * conversion_factor_mmol)); i++; } Line trendLine = new Line(lineValues); trendLine.setColor(ChartUtils.COLOR_RED); trendLine.setHasLines(false); trendLine.setHasPoints(true); trendLine.setPointRadius(3); lines.add(trendLine); final int MIN_GRAPH = 20; if(max - min < MIN_GRAPH) { // On relative flat trend the graph can look very noise althouth with the right resolution it is not that way. // I will add two dummy invisible points that will cause the graph to look with bigger Y range. float average = (max + min) /2; List<PointValue> dummyPointValues = new ArrayList<PointValue>(); Line dummyPointLine = new Line(dummyPointValues); dummyPointValues.add(new PointValue(0, (average - MIN_GRAPH / 2) * conversion_factor_mmol)); dummyPointValues.add(new PointValue(0, (average + MIN_GRAPH / 2) * conversion_factor_mmol)); dummyPointLine.setColor(ChartUtils.COLOR_RED); dummyPointLine.setHasLines(false); dummyPointLine.setHasPoints(false); lines.add(dummyPointLine); } Axis axisX = new Axis(); Axis axisY = new Axis().setHasLines(true); axisX.setTextSize(16); axisY.setTextSize(16); axisX.setName("Time from last scan"); axisY.setName("Glucose " + (doMgdl ? "mg/dl" : "mmol/l")); data = new LineChartData(lines); data.setAxisXBottom(axisX); data.setAxisYLeft(axisY); chart.setLineChartData(data); }
Example 17
Source File: BgReading.java From xDrip with GNU General Public License v3.0 | 4 votes |
public double mmolConvert(double mgdl) { return mgdl * Constants.MGDL_TO_MMOLL; }
Example 18
Source File: BgGraphBuilder.java From xDrip with GNU General Public License v3.0 | 4 votes |
public static double mmolConvert(double mgdl) { return mgdl * Constants.MGDL_TO_MMOLL; }