diff --git a/LoopFollow/Controllers/NightScout.swift b/LoopFollow/Controllers/NightScout.swift index 95603359..a1eaef71 100644 --- a/LoopFollow/Controllers/NightScout.swift +++ b/LoopFollow/Controllers/NightScout.swift @@ -330,13 +330,20 @@ extension MainViewController { } // loop through the data so we can reverse the order to oldest first for the graph - for i in 0..= dateTimeUtils.getTimeIntervalNHoursAgo(N: graphHours) { - let reading = ShareGlucoseData(sgv: data[data.count - 1 - i].sgv, date: dateString, direction: data[data.count - 1 - i].direction) + let sgvValue = data[data.count - 1 - i].sgv + + // Skip the current iteration if the sgv value is over 600 + // First time a user starts a G7, they get a value of 4000 + if sgvValue > 600 { + continue + } + + let reading = ShareGlucoseData(sgv: sgvValue, date: dateString, direction: data[data.count - 1 - i].direction) bgData.append(reading) } - } viewUpdateNSBG(sourceName: sourceName) @@ -574,8 +581,12 @@ extension MainViewController { var i = 0 while i <= toLoad { if i < prediction.count { - let prediction = ShareGlucoseData(sgv: Int(round(prediction[i])), date: predictionTime, direction: "flat") - predictionData.append(prediction) + let sgvValue = Int(round(prediction[i])) + // Skip values higher than 600 + if sgvValue <= 600 { + let prediction = ShareGlucoseData(sgv: sgvValue, date: predictionTime, direction: "flat") + predictionData.append(prediction) + } predictionTime += 300 } i += 1