Clamp prediction values to 39-400 mg/dL#562
Conversation
marionbarker
left a comment
There was a problem hiding this comment.
I would really like the clamped values to be configured as named values. For example.
CLAMP_MAX_PREDICTION = 400
CLAMP_MIN_PREDICTION = 39
Configure those in a constants file and then use them. Try to get away from having hard-coded values that need to be modified, sometimes in multiple places, if we ever decide to make a change.
This is not a requirement for this PR, but a suggestion moving forward.
Test✅ Mostly does as expected. Do we want similar limits for outlier values for glucose. For example if someone fat fingers 1000 into Apple Health instead of 100? Test NarrativeUploaded a nasty pattern to Nightscout URL that includes 25 and 500. Started with glucose axis showing tic marks at 0, 50, 100, 150, 200, 250 The Glucose report is the actual value of 25 or 500, whereas Nightscout shows HIGH. So this only clamps prediction values. The glucose value of 500 is displayed and glucose axis is now 0, 100, 200, 300, 400 and 500. Trio TestGo back to sine wave, change Trio CGM pattern to 160 +/- 100 with period of 1 hour, see if I can get some outlier predictions. Increase hours of prediction. Was 199/309 when 1 hour of prediction. Increase to 3 hours. ✅ For Trio, Min/Max shows: 166/431 for 3 hours, but glucose axis scales do not exceed the max glucose of 500. Loop TestFor Loop, don't need to play games with CGM. Can just add lots of carbs to get a high prediction. Initially, the glucose tic marks are 0, 50, 100, 150, 200, 250 dev version (without this PR): After loop where prediction shows min/max 117/681, the tick marks show 0 to 600 in steps of 100. ✅ build this version on the same phone: tick marks show 0 to 400 in steps of 100 and the prediction curve flat-tops at 400. |
marionbarker
left a comment
There was a problem hiding this comment.
I approve but posted a few questions to consider. Let me know if you want to make modifications or go ahead with this as is.
Replace hard-coded 39/400 mg/dL clamp bounds with globalVariables.minDisplayGlucose and maxDisplayGlucose, shared with the main-screen HIGH/LOW display logic so the range has a single source of truth.
|
Good call — the constants now live in |
marionbarker
left a comment
There was a problem hiding this comment.
Approve by code review and test.
Summary
Fixes #495