Skip to content

Commit

Permalink
address an issue where the two points after an initial calibration wo…
Browse files Browse the repository at this point in the history
…uld have wildly wrong predictive values
  • Loading branch information
StephenBlackWasAlreadyTaken committed Feb 3, 2015
1 parent 05c4125 commit b635acd
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public static void initialCalibration(double bg1, double bg2, Context context) {
calculate_w_l_s();
CalibrationSendQueue.addToQueue(calibration, context);
}
adjustRecentBgReadings(5);
CalibrationRequest.createOffset(lowerCalibration.bg, 35);
Notifications.notificationSetter(context);
}
Expand Down Expand Up @@ -287,6 +288,7 @@ public static void create(CalRecord[] calRecords, Context context, boolean overr

calibration.save();

adjustRecentBgReadings(5);
CalibrationSendQueue.addToQueue(calibration, context);
Calibration.requestCalibrationIfRangeTooNarrow();
}
Expand Down Expand Up @@ -476,11 +478,13 @@ private double calculateWeight() {
Log.w(TAG, "CALIBRATIONS TIME PERCENTAGE WEIGHT: " + time_percentage);
return Math.max((((((slope_confidence + sensor_confidence) * (time_percentage))) / 2) * 100), 1);
}

public static void adjustRecentBgReadings() { // This just adjust the last 30 bg readings transition from one calibration point to the next
public static void adjustRecentBgReadings() {// This just adjust the last 30 bg readings transition from one calibration point to the next
adjustRecentBgReadings(30);
}
public static void adjustRecentBgReadings(int adjustCount) {
//TODO: add some handling around calibration overrides as they come out looking a bit funky
List<Calibration> calibrations = Calibration.latest(3);
List<BgReading> bgReadings = BgReading.latest(30);
List<BgReading> bgReadings = BgReading.latest(adjustCount);
if (calibrations.size() == 3) {
int denom = bgReadings.size();
Calibration latestCalibration = calibrations.get(0);
Expand Down Expand Up @@ -622,7 +626,7 @@ public static List<Calibration> allForSensorInLastFourDays() {
.where("slope_confidence != 0")
.where("sensor_confidence != 0")
.where("timestamp > ?", (new Date().getTime() - (60000 * 60 * 24 * 4)))
.orderBy("_ID desc")
.orderBy("timestamp desc")
.execute();
}

Expand Down

0 comments on commit b635acd

Please sign in to comment.