Skip to content

Commit

Permalink
Pebble: Fix for standard watchface with DisplayGlucose
Browse files Browse the repository at this point in the history
  • Loading branch information
jamorham committed Nov 5, 2016
1 parent dea61bf commit 3d3914b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,8 @@ public void addBatteryStatusToDictionary(PebbleDictionary dictionary) {
}



public String getBgReading() {
return (use_best_glucose) ? dg.unitized : this.bgGraphBuilder.unitized_string(this.bgReading.calculated_value);
return (use_best_glucose) ? ((dg != null) ? dg.unitized : "") : this.bgGraphBuilder.unitized_string(this.bgReading.calculated_value);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Intent;

import com.eveningoutpost.dexdrip.BestGlucose;
import com.eveningoutpost.dexdrip.Models.BgReading;
import com.eveningoutpost.dexdrip.Models.JoH;
import com.eveningoutpost.dexdrip.Models.UserError.Log;
Expand Down Expand Up @@ -49,15 +50,32 @@ private PebbleDictionary buildDictionary() {
Date now = new Date();
int offsetFromUTC = tz.getOffset(now.getTime());

String bgDelta = getBgDelta();
String bgReadingS = getBgReading();
final String bgDelta = getBgDelta();
final String bgReadingS = getBgReading();
final String slopeOrdinal = getSlopeOrdinal();
//boolean no_signal;

Log.v(TAG, "buildDictionary: slopeOrdinal-" + getSlopeOrdinal() + " bgReading-" + bgReadingS +
" now-" + (int) now.getTime() / 1000 + " bgTime-" + (int) (this.bgReading.timestamp / 1000) +
" phoneTime-" + (int) (new Date().getTime() / 1000) + " getBgDelta-" + bgDelta);
dictionary.addString(ICON_KEY, getSlopeOrdinal());
if (use_best_glucose) {
Log.v(TAG, "buildDictionary: slopeOrdinal-" + slopeOrdinal + " bgReading-" + bgReadingS + //
" now-" + (int) now.getTime() / 1000 + " bgTime-" + (int) (dg.timestamp / 1000) + //
" phoneTime-" + (int) (new Date().getTime() / 1000) + " getBgDelta-" + getBgDelta());
// no_signal = (dg.mssince > Home.stale_data_millis());
} else {
Log.v(TAG, "buildDictionary: slopeOrdinal-" + slopeOrdinal + " bgReading-" + bgReadingS + //
" now-" + (int) now.getTime() / 1000 + " bgTime-" + (int) (this.bgReading.timestamp / 1000) + //
" phoneTime-" + (int) (new Date().getTime() / 1000) + " getBgDelta-" + getBgDelta());
// no_signal = ((new Date().getTime()) - Home.stale_data_millis() - this.bgReading.timestamp > 0);
}

dictionary.addString(ICON_KEY, slopeOrdinal);
dictionary.addString(BG_KEY, bgReadingS);
dictionary.addUint32(RECORD_TIME_KEY, (int) (((this.bgReading.timestamp + offsetFromUTC) / 1000)));

if (use_best_glucose) {
dictionary.addUint32(RECORD_TIME_KEY, (int) (((dg.timestamp + offsetFromUTC) / 1000)));
} else {
dictionary.addUint32(RECORD_TIME_KEY, (int) (((this.bgReading.timestamp + offsetFromUTC) / 1000)));
}

dictionary.addUint32(PHONE_TIME_KEY, (int) ((new Date().getTime() + offsetFromUTC) / 1000));
dictionary.addString(BG_DELTA_KEY, bgDelta);

Expand All @@ -68,8 +86,13 @@ private PebbleDictionary buildDictionary() {


public void sendData() {
this.bgReading = BgReading.last();
if (this.bgReading != null) {
if (use_best_glucose) {
this.dg = BestGlucose.getDisplayGlucose();
} else {
this.bgReading = BgReading.last();
}

if (use_best_glucose ? (this.dg != null) : (this.bgReading != null)) {
sendDownload();
}
}
Expand Down

0 comments on commit 3d3914b

Please sign in to comment.