com.eveningoutpost.dexdrip.UtilityModels.BgGraphBuilder Java Examples

The following examples show how to use com.eveningoutpost.dexdrip.UtilityModels.BgGraphBuilder. 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: BgReading.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public BgReading injectNoise(boolean save) {
    final BgReading bgReading = this;
    if (JoH.msSince(bgReading.timestamp) > Constants.MINUTE_IN_MS * 20) {
        bgReading.noise = "0";
    } else {
        BgGraphBuilder.refreshNoiseIfOlderThan(bgReading.timestamp);
        if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_HIGH) {
            bgReading.noise = "4";
        } else if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TOO_HIGH_FOR_PREDICT) {
            bgReading.noise = "3";
        } else if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TRIGGER) {
            bgReading.noise = "2";
        }
    }
    if (save) bgReading.save();
    return bgReading;
}
 
Example #2
Source File: Ob1G5StateMachine.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private static void processBacksies(List<BackFillStream.Backsie> backsies) {
    boolean changed = false;
    for (BackFillStream.Backsie backsie : backsies) {
        final long time = DexTimeKeeper.fromDexTime(getTransmitterID(), backsie.getDextime());

        final long since = JoH.msSince(time);
        if ((since > HOUR_IN_MS * 6) || (since < 0)) {
            UserError.Log.wtf(TAG, "Backfill timestamp unrealistic: " + JoH.dateTimeText(time) + " (ignored)");
        } else {
            if (BgReading.getForPreciseTimestamp(time, Constants.MINUTE_IN_MS * 4) == null) {
                final BgReading bgr = BgReading.bgReadingInsertFromG5(backsie.getGlucose(), time, "Backfill");
                lastGlucoseBgReading = bgr;
                UserError.Log.d(TAG, "Adding backfilled reading: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose()));
                changed = true;
            }
            UserError.Log.d(TAG, "Backsie: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose()));
        }
    }
    if (changed) {
        updateStreamedTillTimeForBackfill();
    }
}
 
Example #3
Source File: BGHistory.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private void setupCharts() {
    dateButton1.setText(dateFormatter.format(date1.getTime()));

    Calendar endDate = (GregorianCalendar) date1.clone();
    endDate.add(Calendar.DATE, noDays);
    int numValues = noDays * (60 / 2) * 24; // LimiTTer sample rate 1 per 2 minutes
    BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(this, date1.getTimeInMillis(), endDate.getTimeInMillis(), numValues, false);

    chart = (LineChartView) findViewById(R.id.chart);
    chart.setZoomType(ZoomType.HORIZONTAL);
    previewChart = (PreviewLineChartView) findViewById(R.id.chart_preview);
    previewChart.setZoomType(ZoomType.HORIZONTAL);

    chart.setLineChartData(bgGraphBuilder.lineData());
    chart.setOnValueTouchListener(bgGraphBuilder.getOnValueSelectTooltipListener(this));
    previewChart.setLineChartData(bgGraphBuilder.previewLineData(chart.getLineChartData()));

    previewChart.setViewportCalculationEnabled(true);
    chart.setViewportCalculationEnabled(true);
    previewChart.setViewportChangeListener(new ViewportListener());
    chart.setViewportChangeListener(new ChartViewPortListener());

    setupStatistics(date1.getTimeInMillis(), endDate.getTimeInMillis());
}
 
Example #4
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public BgReading injectNoise(boolean save) {
    final BgReading bgReading = this;
    if (JoH.msSince(bgReading.timestamp) > Constants.MINUTE_IN_MS * 20) {
        bgReading.noise = "0";
    } else {
        BgGraphBuilder.refreshNoiseIfOlderThan(bgReading.timestamp);
        if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_HIGH) {
            bgReading.noise = "4";
        } else if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TOO_HIGH_FOR_PREDICT) {
            bgReading.noise = "3";
        } else if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TRIGGER) {
            bgReading.noise = "2";
        }
    }
    if (save) bgReading.save();
    return bgReading;
}
 
Example #5
Source File: SnoozeActivity.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_snooze);
    alertStatus = (TextView) findViewById(R.id.alert_status);
    snoozeValue = (NumberPicker) findViewById(R.id.snooze);

    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        alertStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
        buttonSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    }
    displayStatus();
}
 
Example #6
Source File: Ob1G5StateMachine.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static void processBacksies(List<BackFillStream.Backsie> backsies) {
    boolean changed = false;
    for (BackFillStream.Backsie backsie : backsies) {
        final long time = DexTimeKeeper.fromDexTime(getTransmitterID(), backsie.getDextime());

        final long since = JoH.msSince(time);
        if ((since > HOUR_IN_MS * 6) || (since < 0)) {
            UserError.Log.wtf(TAG, "Backfill timestamp unrealistic: " + JoH.dateTimeText(time) + " (ignored)");
        } else {
            if (BgReading.getForPreciseTimestamp(time, Constants.MINUTE_IN_MS * 4) == null) {
                final BgReading bgr = BgReading.bgReadingInsertFromG5(backsie.getGlucose(), time, "Backfill");
                lastGlucoseBgReading = bgr;
                UserError.Log.d(TAG, "Adding backfilled reading: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose()));
                changed = true;
            }
            UserError.Log.d(TAG, "Backsie: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose()));
        }
    }
    if (changed) {
        updateStreamedTillTimeForBackfill();
    }
}
 
Example #7
Source File: BGHistory.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private void setupCharts() {
    dateButton1.setText(dateFormatter.format(date1.getTime()));

    Calendar endDate = (GregorianCalendar) date1.clone();
    endDate.add(Calendar.DATE, noDays);
    int numValues = noDays * (60 / 2) * 24; // LimiTTer sample rate 1 per 2 minutes
    BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(this, date1.getTimeInMillis(), endDate.getTimeInMillis(), numValues, false);

    chart = (LineChartView) findViewById(R.id.chart);
    chart.setZoomType(ZoomType.HORIZONTAL);
    previewChart = (PreviewLineChartView) findViewById(R.id.chart_preview);
    previewChart.setZoomType(ZoomType.HORIZONTAL);

    chart.setLineChartData(bgGraphBuilder.lineData());
    chart.setOnValueTouchListener(bgGraphBuilder.getOnValueSelectTooltipListener(this));
    previewChart.setLineChartData(bgGraphBuilder.previewLineData(chart.getLineChartData()));

    previewChart.setViewportCalculationEnabled(true);
    chart.setViewportCalculationEnabled(true);
    previewChart.setViewportChangeListener(new ViewportListener());
    chart.setViewportChangeListener(new ChartViewPortListener());

    setupStatistics(date1.getTimeInMillis(), endDate.getTimeInMillis());
}
 
Example #8
Source File: SnoozeActivity.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //KS if (Home.get_holo()) { setTheme(R.style.OldAppTheme); }
    setContentView(R.layout.activity_snooze);
    alertStatus = (TextView) findViewById(R.id.alert_status);
    snoozeValue = (NumberPicker) findViewById(R.id.snooze);

    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        alertStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
        buttonSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    }
    displayStatus();
}
 
Example #9
Source File: Ob1G5StateMachine.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static void processBacksies(List<BackFillStream.Backsie> backsies) {
    boolean changed = false;
    for (BackFillStream.Backsie backsie : backsies) {
        final long time = DexTimeKeeper.fromDexTime(getTransmitterID(), backsie.getDextime());

        final long since = JoH.msSince(time);
        if ((since > HOUR_IN_MS * 6) || (since < 0)) {
            UserError.Log.wtf(TAG, "Backfill timestamp unrealistic: " + JoH.dateTimeText(time) + " (ignored)");
        } else {
            if (BgReading.getForPreciseTimestamp(time, Constants.MINUTE_IN_MS * 4) == null) {
                final BgReading bgr = BgReading.bgReadingInsertFromG5(backsie.getGlucose(), time, "Backfill");
                lastGlucoseBgReading = bgr;
                UserError.Log.d(TAG, "Adding backfilled reading: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose()));
                changed = true;
            }
            UserError.Log.d(TAG, "Backsie: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose()));
        }
    }
    if (changed) {
        updateStreamedTillTimeForBackfill();
    }
}
 
Example #10
Source File: Home.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public void setupCharts() {
    bgGraphBuilder = new BgGraphBuilder(this);
    updateStuff = false;
    chart = (LineChartView) findViewById(R.id.chart);
    chart.setZoomType(ZoomType.HORIZONTAL);

    previewChart = (PreviewLineChartView) findViewById(R.id.chart_preview);
    previewChart.setZoomType(ZoomType.HORIZONTAL);

    chart.setLineChartData(bgGraphBuilder.lineData());
    previewChart.setLineChartData(bgGraphBuilder.previewLineData());
    updateStuff = true;

    previewChart.setViewportCalculationEnabled(true);
    chart.setViewportCalculationEnabled(true);
    previewChart.setViewportChangeListener(new ViewportListener());
    chart.setViewportChangeListener(new ChartViewPortListener());
    setViewport();
}
 
Example #11
Source File: WatchUpdaterService.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private void resendData(long since) {
    Log.d(TAG, "resendData ENTER");
    forceGoogleApiConnect();
    final long startTime = since == 0 ? new Date().getTime() - (60000 * 60 * 24) : since;
    Log.d(TAG, "resendData googleApiClient connected ENTER, sending since: " + JoH.dateTimeText(startTime));
    final BgReading last_bg = BgReading.last();
    if (last_bg != null) {
        List<BgReading> graph_bgs = BgReading.latestForGraph(60, startTime);
        BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(getApplicationContext());
        if (!graph_bgs.isEmpty()) {
            final int battery = PowerStateReceiver.getBatteryLevel(getApplicationContext());
            DataMap entries = dataMap(last_bg, mPrefs, bgGraphBuilder, battery);
            final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
            for (BgReading bg : graph_bgs) {
                dataMaps.add(dataMap(bg, mPrefs, bgGraphBuilder, battery));
            }
            entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
            entries.putDataMapArrayList("entries", dataMaps);
            if (mPrefs.getBoolean("extra_status_line", false)) {
                entries.putString("extra_status_line", StatusLine.extraStatusLine());
            }

            new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, entries);
        }
    }
}
 
Example #12
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public BgReading injectNoise(boolean save) {
    final BgReading bgReading = this;
    if (JoH.msSince(bgReading.timestamp) > Constants.MINUTE_IN_MS * 20) {
        bgReading.noise = "0";
    } else {
        BgGraphBuilder.refreshNoiseIfOlderThan(bgReading.timestamp);
        if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_HIGH) {
            bgReading.noise = "4";
        } else if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TOO_HIGH_FOR_PREDICT) {
            bgReading.noise = "3";
        } else if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TRIGGER) {
            bgReading.noise = "2";
        }
    }
    if (save) bgReading.save();
    return bgReading;
}
 
Example #13
Source File: SnoozeActivity.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Home.get_holo()) { setTheme(R.style.OldAppThemeNoTitleBar); }
    JoH.fixActionBar(this);
    setContentView(R.layout.activity_snooze);
    alertStatus = (TextView) findViewById(R.id.alert_status);
    snoozeValue = (NumberPicker) findViewById(R.id.snooze);

    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        alertStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
        buttonSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    }
    displayStatus();
}
 
Example #14
Source File: SnoozeActivity.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Home.get_holo()) { setTheme(R.style.OldAppThemeNoTitleBar); }
    JoH.fixActionBar(this);
    setContentView(R.layout.activity_snooze);
    alertStatus = (TextView) findViewById(R.id.alert_status);
    snoozeValue = (NumberPicker) findViewById(R.id.snooze);

    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        alertStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
        buttonSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    }
    displayStatus();
}
 
Example #15
Source File: SnoozeActivity.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //KS if (Home.get_holo()) { setTheme(R.style.OldAppTheme); }
    setContentView(R.layout.activity_snooze);
    alertStatus = (TextView) findViewById(R.id.alert_status);
    snoozeValue = (NumberPicker) findViewById(R.id.snooze);

    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        alertStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
        buttonSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    }
    displayStatus();
}
 
Example #16
Source File: Ob1G5StateMachine.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private static void processBacksies(List<BackFillStream.Backsie> backsies) {
    boolean changed = false;
    for (BackFillStream.Backsie backsie : backsies) {
        final long time = DexTimeKeeper.fromDexTime(getTransmitterID(), backsie.getDextime());

        final long since = JoH.msSince(time);
        if ((since > HOUR_IN_MS * 6) || (since < 0)) {
            UserError.Log.wtf(TAG, "Backfill timestamp unrealistic: " + JoH.dateTimeText(time) + " (ignored)");
        } else {
            if (BgReading.getForPreciseTimestamp(time, Constants.MINUTE_IN_MS * 4) == null) {
                final BgReading bgr = BgReading.bgReadingInsertFromG5(backsie.getGlucose(), time, "Backfill");
                lastGlucoseBgReading = bgr;
                UserError.Log.d(TAG, "Adding backfilled reading: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose()));
                changed = true;
            }
            UserError.Log.d(TAG, "Backsie: " + JoH.dateTimeText(time) + " " + BgGraphBuilder.unitized_string_static(backsie.getGlucose()));
        }
    }
    if (changed) {
        updateStreamedTillTimeForBackfill();
    }
}
 
Example #17
Source File: BGHistory.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
private void setupCharts() {
    dateButton1.setText(dateFormatter.format(date1.getTime()));

    Calendar endDate = (GregorianCalendar) date1.clone();
    endDate.add(Calendar.DATE, noDays);
    int numValues = noDays * (60 / 5) * 24;
    BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(this, date1.getTimeInMillis(), endDate.getTimeInMillis(), numValues);

    chart = (LineChartView) findViewById(R.id.chart);
    chart.setZoomType(ZoomType.HORIZONTAL);
    previewChart = (PreviewLineChartView) findViewById(R.id.chart_preview);
    previewChart.setZoomType(ZoomType.HORIZONTAL);

    chart.setLineChartData(bgGraphBuilder.lineData());
    chart.setOnValueTouchListener(bgGraphBuilder.getOnValueSelectTooltipListener());
    previewChart.setLineChartData(bgGraphBuilder.previewLineData());

    previewChart.setViewportCalculationEnabled(true);
    chart.setViewportCalculationEnabled(true);
    previewChart.setViewportChangeListener(new ViewportListener());
    chart.setViewportChangeListener(new ChartViewPortListener());
}
 
Example #18
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public BgReading injectNoise(boolean save) {
    final BgReading bgReading = this;
    if (JoH.msSince(bgReading.timestamp) > Constants.MINUTE_IN_MS * 20) {
        bgReading.noise = "0";
    } else {
        BgGraphBuilder.refreshNoiseIfOlderThan(bgReading.timestamp);
        if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_HIGH) {
            bgReading.noise = "4";
        } else if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TOO_HIGH_FOR_PREDICT) {
            bgReading.noise = "3";
        } else if (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TRIGGER) {
            bgReading.noise = "2";
        }
    }
    if (save) bgReading.save();
    return bgReading;
}
 
Example #19
Source File: WatchUpdaterService.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
private void resendData() {
    if(googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) { googleApiConnect(); }
    long startTime = new Date().getTime() - (60000 * 60 * 24);
    BgReading last_bg = BgReading.last();
    List<BgReading> graph_bgs = BgReading.latestForGraph(60, startTime);
    BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(getApplicationContext());
    if (!graph_bgs.isEmpty()) {
        DataMap entries = dataMap(last_bg, mPrefs, bgGraphBuilder);
        final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
        for (BgReading bg : graph_bgs) {
            dataMaps.add(dataMap(bg, mPrefs, bgGraphBuilder));
        }
        entries.putDataMapArrayList("entries", dataMaps);

        new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient).execute(entries);
    }
}
 
Example #20
Source File: BestGlucose.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
protected static boolean compensateNoise() {
    return (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TRIGGER
            || (BgGraphBuilder.last_noise > BgGraphBuilder.NOISE_TRIGGER_ULTRASENSITIVE
                    && Pref.getBooleanDefaultFalse("engineering_mode")
                    && Pref.getBooleanDefaultFalse("bg_compensate_noise_ultrasensitive")
            ))
            && (BgGraphBuilder.best_bg_estimate > 0)
            && (BgGraphBuilder.last_bg_estimate > 0)
            && (prefs.getBoolean("bg_compensate_noise", false));
}
 
Example #21
Source File: WatchUpdaterService.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public long sgvLevel(double sgv_double, SharedPreferences prefs, BgGraphBuilder bgGB) {
    Double highMark = Double.parseDouble(prefs.getString("highValue", "170"));
    Double lowMark = Double.parseDouble(prefs.getString("lowValue", "70"));
    if(bgGB.unitized(sgv_double) >= highMark) {
        return 1;
    } else if (bgGB.unitized(sgv_double) >= lowMark) {
        return 0;
    } else {
        return -1;
    }
}
 
Example #22
Source File: WatchUpdaterService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void sendData() {
    BgReading bg = BgReading.last();
    if (bg != null) {
        forceGoogleApiConnect();
        if (wear_integration) {
            final int battery = PowerStateReceiver.getBatteryLevel(getApplicationContext());
            new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, dataMap(bg, mPrefs, new BgGraphBuilder(getApplicationContext()), battery));
        }
    }
}
 
Example #23
Source File: Amazfitservice.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private Bitmap createWFBitmapSmallDots(long start, long end) {
    return new BgSparklineBuilder(xdrip.getAppContext())
            .setBgGraphBuilder(new BgGraphBuilder(xdrip.getAppContext()))
            .setStart(start)
            .setEnd(end)
            //.showAxes()
            .setWidthPx(300)
            .setHeightPx(130)
            .setSmallDots()
            .build();
}
 
Example #24
Source File: WatchUpdaterService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private long sgvLevel(double sgv_double, SharedPreferences prefs, BgGraphBuilder bgGB) {
    Double highMark = Double.parseDouble(prefs.getString("highValue", "170"));
    Double lowMark = Double.parseDouble(prefs.getString("lowValue", "70"));
    if (bgGB.unitized(sgv_double) >= highMark) {
        return 1;
    } else if (bgGB.unitized(sgv_double) >= lowMark) {
        return 0;
    } else {
        return -1;
    }
}
 
Example #25
Source File: Amazfitservice.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private Bitmap createWFBitmapTinyDots(long start, long end) {
    return new BgSparklineBuilder(xdrip.getAppContext())
            .setBgGraphBuilder(new BgGraphBuilder(xdrip.getAppContext()))
            .setStart(start)
            .setEnd(end)
            //.showAxes()
            .setWidthPx(300)
            .setHeightPx(130)
            .setTinyDots()
            .build();
}
 
Example #26
Source File: LibreWifiReader.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
static List<StatusItem> megaStatus() {
    final List<StatusItem> l = new ArrayList<>();
    for (Map.Entry<String, String> entry : hostStatus.entrySet()) {
        final long status_time = hostStatusTime.get(entry.getKey());
        if (entry.getValue().length() > 0)
            l.add(new StatusItem(entry.getKey(), entry.getValue() + ((status_time != 0) ? (" " + JoH.niceTimeSince(status_time) + " " + "ago") : ""), JoH.msSince(status_time) <= BgGraphBuilder.DEXCOM_PERIOD ? StatusItem.Highlight.GOOD : JoH.msSince(status_time) <= BgGraphBuilder.DEXCOM_PERIOD * 2 ? StatusItem.Highlight.NOTICE : StatusItem.Highlight.NORMAL));
    }
    return l;
}
 
Example #27
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static String getSlopeArrowSymbolBeforeCalibration() {
    final List<BgReading> last = BgReading.latestUnCalculated(2);
    if ((last!=null) && (last.size()==2)) {
        final double guess_slope = 1; // This is the "Default" slope for Dex and LimiTTer
        final double time_delta = (last.get(0).timestamp-last.get(1).timestamp);
        if (time_delta<=(BgGraphBuilder.DEXCOM_PERIOD * 2)) {
            final double estimated_delta = (last.get(0).age_adjusted_raw_value * guess_slope) - (last.get(1).age_adjusted_raw_value * guess_slope);
            final double estimated_delta2 = (last.get(0).raw_data * guess_slope) - (last.get(1).raw_data * guess_slope);
            Log.d(TAG, "SlopeArrowBeforeCalibration: guess delta: " + estimated_delta + " delta2: " + estimated_delta2 + " timedelta: " + time_delta);
            return slopeToArrowSymbol(estimated_delta / (time_delta / 60000));
        } else { return ""; }
    } else {
        return "";
    }
}
 
Example #28
Source File: BestGlucose.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static String unitizedDeltaString(boolean showUnit, boolean highGranularity, boolean doMgdl, double value1, long timestamp1, double value2, long timestamp2) {

        // timestamps invalid or too far apart return ???
        if ((timestamp1 < 0)
                || (timestamp2 < 0)
                || (value1 < 0)
                || (value2 < 0)
                || (timestamp2 > timestamp1)
                || (timestamp1 - timestamp2 > (20 * 60 * 1000)))
            return "???";

        double value = calculateSlope(value1, timestamp1, value2, timestamp2) * 5 * 60 * 1000;

        return BgGraphBuilder.unitizedDeltaStringRaw(showUnit, highGranularity, value, doMgdl);
    }
 
Example #29
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static String getSlopeArrowSymbolBeforeCalibration() {
    final List<BgReading> last = BgReading.latestUnCalculated(2);
    if ((last!=null) && (last.size()==2)) {
        final double guess_slope = 1; // This is the "Default" slope for Dex and LimiTTer
        final double time_delta = (last.get(0).timestamp-last.get(1).timestamp);
        if (time_delta<=(BgGraphBuilder.DEXCOM_PERIOD * 2)) {
            final double estimated_delta = (last.get(0).age_adjusted_raw_value * guess_slope) - (last.get(1).age_adjusted_raw_value * guess_slope);
            final double estimated_delta2 = (last.get(0).raw_data * guess_slope) - (last.get(1).raw_data * guess_slope);
            Log.d(TAG, "SlopeArrowBeforeCalibration: guess delta: " + estimated_delta + " delta2: " + estimated_delta2 + " timedelta: " + time_delta);
            return slopeToArrowSymbol(estimated_delta / (time_delta / 60000));
        } else { return ""; }
    } else {
        return "";
    }
}
 
Example #30
Source File: WatchUpdaterService.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public void sendData() {
    BgReading bg = BgReading.last();
    if (bg != null) {
        if(googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) { googleApiConnect(); }
        if (wear_integration) {
            new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient).execute(dataMap(bg, mPrefs, new BgGraphBuilder(getApplicationContext())));
        }
    }
}