Search in sources :

Example 1 with GlucoseReading

use of com.nightscout.core.utils.GlucoseReading in project android-uploader by nightscout.

the class Pebble method sendDownload.

public void sendDownload(GlucoseReading reading, TrendArrow trend, long recordTime, Context cntx, boolean resend) {
    GlucoseReading delta = new GlucoseReading(0, GlucoseUnit.MGDL);
    if (currentReading != null) {
        delta = reading.subtract(lastReading);
    }
    if (resend) {
        delta = lastDelta;
    }
    String deltaStr = "";
    if (delta.asMgdl() > 0) {
        deltaStr += "+";
    }
    deltaStr += delta.asStr(units);
    String bgStr = reading.asStr(units);
    lastRecordTime = recordTime;
    lastReading = reading;
    lastTrend = trend;
    lastDelta = delta;
    recordTime = DateTimeZone.getDefault().convertUTCToLocal(recordTime);
    int batLevel = AndroidUploaderDevice.getUploaderDevice(cntx).getBatteryLevel();
    PebbleDictionary dictionary = buildDictionary(trend, bgStr, (int) (recordTime / 1000), (int) (DateTimeZone.getDefault().convertUTCToLocal(new DateTime().getMillis()) / 1000), deltaStr, String.valueOf(batLevel), pwdName);
    currentReading = dictionary;
    sendDownload(dictionary);
}
Also used : GlucoseReading(com.nightscout.core.utils.GlucoseReading) PebbleDictionary(com.getpebble.android.kit.util.PebbleDictionary) DateTime(org.joda.time.DateTime)

Example 2 with GlucoseReading

use of com.nightscout.core.utils.GlucoseReading in project android-uploader by nightscout.

the class MainActivity method onResume.

@Override
protected void onResume() {
    super.onResume();
    Log.d(TAG, "onResumed called.");
    mWebView.onResume();
    mWebView.resumeTimers();
    // Set and deal with mmol/L<->mg/dL conversions
    Log.d(TAG, "display_options_units: " + preferences.getPreferredUnits().name());
    pebble.config(preferences.getPwdName(), preferences.getPreferredUnits(), getApplicationContext());
    int sgv = (Integer) mTextSGV.getTag(R.string.display_sgv);
    int direction = (Integer) mTextSGV.getTag(R.string.display_trend);
    if (sgv != -1) {
        GlucoseReading sgvReading = new GlucoseReading(sgv, GlucoseUnit.MGDL);
        mTextSGV.setText(getSGVStringByUnit(sgvReading, TrendArrow.values()[direction]));
    }
    mWebView.loadUrl("javascript:updateUnits(" + Boolean.toString(preferences.getPreferredUnits() == GlucoseUnit.MMOL) + ")");
    mHandler.post(updateTimeAgo);
    // FIXME: (klee) need to find a better way to do this. Too many things are hooking in here.
    if (statusBarIcons != null) {
        statusBarIcons.checkForRootOptionChanged();
    }
}
Also used : GlucoseReading(com.nightscout.core.utils.GlucoseReading) SuppressLint(android.annotation.SuppressLint)

Aggregations

GlucoseReading (com.nightscout.core.utils.GlucoseReading)2 SuppressLint (android.annotation.SuppressLint)1 PebbleDictionary (com.getpebble.android.kit.util.PebbleDictionary)1 DateTime (org.joda.time.DateTime)1