Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented Insulin on Board. #366

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

eduardopietre
Copy link
Contributor

Insulin on Board implementation, all done locally.
OpenAPS docs were used as reference for this implementation: https://openaps.readthedocs.io/en/latest/docs/While%20You%20Wait%20For%20Gear/understanding-insulin-on-board-calculations.html

This commit features:

  • A settings section for insulin on board with 4 settings: enable display, show on chart, duration of insulin activity (OpenAPS dia, but in minutes) and insulin peak time (OpenAPS peak).
  • InsulinOnBoardCalculator, class responsible for calculating the IOB.
  • IOB plotted at main chart, as a blue line and same scale of insulin bolus.
  • Convenience ChartPoint init for a date and insulin amount, for IOB.

Things to notice:

  • At RootViewController there are two TODOs, where the IOB display label should be set. The code to calculate the IOB there is already present.
  • Caching is not used, but the implementation was done considering that cache may be needed and implemented in the future.

Sample screenshot:
Simulator Screen Shot - iPhone 8

Insulin on Board implementation, all done locally.
OpenAPS docs were used as reference for this implementation: https://openaps.readthedocs.io/en/latest/docs/While%20You%20Wait%20For%20Gear/understanding-insulin-on-board-calculations.html

This commit features:
- A settings section for insulin on board with 4 settings: enable display, show on chart, duration of insulin activity (OpenAPS dia, but in minutes) and insulin peak time (OpenAPS peak).
- InsulinOnBoardCalculator, class responsible for calculating the IOB.
- IOB plotted at main chart, as a blue line and same scale of insulin bolus.
- Convenience ChartPoint init for a date and insulin amount, for IOB.

Things to notice:
- At RootViewController there are two TODOs, where the IOB display label should be set. The code to calculate the IOB there is already present.
- Caching is not used, but the implementation was done considering that cache may be needed and implemented in the future.
@paulplant paulplant added the enhancement New feature or request label Jul 5, 2022
@bjornoleh
Copy link
Contributor

Hi,

I had a look at your contribution. Looks good at first glance!

Some suggestions:

  • Perhaps a way to scale the bolus/IOB y-axis could be introduced? When I view my kid's data in follower mode, his boluses/IOB only occupy roughly the lower 1/4 of the chart or less (bolus max 2,5 U, max IOB 5 U).

  • Having an easy way to identify negative IOB events would be great. I can not visually see a -0,27 U IOB event from the last 24 hours, but would love to see this easily. Perhaps colour IOB <0 in red or some other colour?

I am also unsure about what "Enable display" does. I only see the chart turn on/off with the "show on chart" setting. Should the current/historical (during scrolling) IOB value be displayed somewhere?

IMG_8E360349C1AF-1

@loopy321
Copy link
Contributor

This looks great! Thanks!
I was wondering if borrowing from loopkit would aid in implementing COB and predictions to get something like:
https://github.com/LoopKit/Loop/blob/dev/Documentation/Screenshots/Phone%20Graphs.png

@LiroyvH
Copy link
Contributor

LiroyvH commented Aug 26, 2022

We should perhaps also free some screen real-estate to simply show a total IOB (and perhaps COB). Perhaps below the pie-chart is an option. Currently the text there mimics the days setting; so it's pretty much redundant. If IOB is enabled, showing the IOB there as a number may be a nice touch.

Just an idea. :)

@bjornoleh
Copy link
Contributor

Agreed. And perhaps move the pie chart to the far left, so it can sit close to the days setting.

@eduardopietre
Copy link
Contributor Author

eduardopietre commented Aug 26, 2022

Hi,
Thanks for all the feedback!
About the label / displaying the IOB value on screen, there are two TODOs annotations at RootViewController.swift: here and here.
The logic to calculate these values is already on place, the only work missing is the user interface itself.
However, I lack the UI experience and talent needed to create it.

Recently I have had close to no free time to code. COB would be a very nice addition, and could even reuse most of the plotting logic. Unfortunately, I'm not able to work on it right now.
Feedback is appreciated,
Thanks!

@loopy321
Copy link
Contributor

Can IOB be added to the calendar events? I'm guessing here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants