Skip to content

Display HIGH/LOW for out-of-range BG on main screen#565

Merged
marionbarker merged 2 commits intodevfrom
feature/high-low-bg-display
Apr 9, 2026
Merged

Display HIGH/LOW for out-of-range BG on main screen#565
marionbarker merged 2 commits intodevfrom
feature/high-low-bg-display

Conversation

@bjorkert
Copy link
Copy Markdown
Contributor

Summary

  • Show "HIGH" when BG >= 400 and "LOW" when BG <= 39 on the main screen, matching Dexcom sensor range behavior
  • Reduce font size (85pt → 65pt) when displaying HIGH/LOW so the text fits
  • Rename setBGTextColorupdateBGTextAppearance to reflect its broader role

Closes #503

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.
Copy link
Copy Markdown
Collaborator

@codebymini codebymini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bjorkert bjorkert self-assigned this Mar 21, 2026
self.updateBGTextAppearance()

Observable.shared.bgText.value = Localizer.toDisplayUnits(String(latestBG))
if latestBG <= 39 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these limits (39, 400) be defined in a global file to be reused?
(with #562)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Make the threshold user-configurable (e.g. in Graph Settings), so Libre users can bump it.
  2. 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 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be global values

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@bjorkert bjorkert changed the base branch from main to dev April 9, 2026 09:40
Copy link
Copy Markdown
Collaborator

@marionbarker marionbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by code review and test.

@marionbarker marionbarker merged commit 9c79601 into dev Apr 9, 2026
@marionbarker marionbarker deleted the feature/high-low-bg-display branch April 9, 2026 14:26
bjorkert added a commit that referenced this pull request Apr 9, 2026
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.
bjorkert added a commit that referenced this pull request Apr 9, 2026
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.
marionbarker pushed a commit that referenced this pull request Apr 9, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Display "Low" and "High" for out-of-range glucose values

3 participants