Display HIGH/LOW for out-of-range BG on main screen#565
Conversation
Show "HIGH" when BG >= 400 and "LOW" when BG <= 39, matching Dexcom sensor range behavior. Reduce font size for these labels to fit the display.
| self.updateBGTextAppearance() | ||
|
|
||
| Observable.shared.bgText.value = Localizer.toDisplayUnits(String(latestBG)) | ||
| if latestBG <= 39 { |
There was a problem hiding this comment.
Should these limits (39, 400) be defined in a global file to be reused?
(with #562)
There was a problem hiding this comment.
Please use named constants - see comments in PR #562
Also - do we really want to limit Libre output - which I think can go to 500. Also - some finger stick meters can go higher.
There was a problem hiding this comment.
Thanks both. The thresholds are now in globalVariables.minDisplayGlucose / globalVariables.maxDisplayGlucose (0e86e9c) so future changes live in one place.
On the upper bound — fair point about Libre and meters. I've kept it at 400 for this PR so it stays consistent with the prediction clamp in #562, but I agree it's worth revisiting. Two ways we could handle it cleanly later:
- Make the threshold user-configurable (e.g. in Graph Settings), so Libre users can bump it.
- Only substitute HIGH/LOW for CGM readings and let manual BG entries through untouched.
The HIGH/LOW labels still reflect reality — they're just dropping the exact digits — but either of the options above would give users who want the precise number a path to it.
|
|
||
| BGText.textColor = color | ||
|
|
||
| if latestBG <= 39 || latestBG >= 400 { |
There was a problem hiding this comment.
This could also be global values
There was a problem hiding this comment.
Done — using globalVariables.minDisplayGlucose / globalVariables.maxDisplayGlucose from Globals.swift (0e86e9c).
Move the 39/400 mg/dL thresholds into globalVariables so the main screen HIGH/LOW display logic shares a single source of truth instead of repeating magic numbers across call sites.
marionbarker
left a comment
There was a problem hiding this comment.
Approved by code review and test.
Restore `let lastBGTime = entries[latestEntryIndex].date` in viewUpdateNSBG. Dev currently fails to compile with "Cannot find 'lastBGTime' in scope" because two PRs that merged into dev on the same day textually did not conflict but semantically interfered: - #537 (Live Activity) added `Storage.shared.lastBgReadingTimeSeconds.value = lastBGTime` later in the function, relying on the existing local. - #565 (Display HIGH/LOW) removed the local declaration as part of an unrelated refactor; that branch was cut before #537 landed, so from its perspective the local was unused. Git's 3-way merge produced a syntactically clean file but the surviving reference now dangles. Re-adding the local is the minimal, intent-preserving fix.
Restore `let lastBGTime = entries[latestEntryIndex].date` in viewUpdateNSBG. Dev currently fails to compile with "Cannot find 'lastBGTime' in scope" because two PRs that merged into dev on the same day textually did not conflict but semantically interfered: - #537 (Live Activity) added `Storage.shared.lastBgReadingTimeSeconds.value = lastBGTime` later in the function, relying on the existing local. - #565 (Display HIGH/LOW) removed the local declaration as part of an unrelated refactor; that branch was cut before #537 landed, so from its perspective the local was unused. Git's 3-way merge produced a syntactically clean file but the surviving reference now dangles. Re-adding the local is the minimal, intent-preserving fix.
Restore `let lastBGTime = entries[latestEntryIndex].date` in viewUpdateNSBG. Dev currently fails to compile with "Cannot find 'lastBGTime' in scope" because two PRs that merged into dev on the same day textually did not conflict but semantically interfered: - #537 (Live Activity) added `Storage.shared.lastBgReadingTimeSeconds.value = lastBGTime` later in the function, relying on the existing local. - #565 (Display HIGH/LOW) removed the local declaration as part of an unrelated refactor; that branch was cut before #537 landed, so from its perspective the local was unused. Git's 3-way merge produced a syntactically clean file but the surviving reference now dangles. Re-adding the local is the minimal, intent-preserving fix.
Summary
setBGTextColor→updateBGTextAppearanceto reflect its broader roleCloses #503