diff --git a/.github/workflows/pr_dependencies_check.yml b/.github/workflows/pr_dependencies_check.yml new file mode 100644 index 00000000..2bb90c27 --- /dev/null +++ b/.github/workflows/pr_dependencies_check.yml @@ -0,0 +1,23 @@ +name: Prevent Blocked PRs from being Merged + +on: + pull_request: + types: + - opened + - edited + - closed + - reopened + issues: + types: + - opened + - edited + - deleted + - transferred + - closed + - reopened + +jobs: + blocking_issues: + runs-on: ubuntu-latest + steps: + - uses: Levi-Lesches/blocking-issues@v2 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..c445005e --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,66 @@ +name: publish + +# Controls when the action will run. +on: + # Remark: uncomment one section only + # Remark: Next 1 line requires manual action, Click on action tab, then publish + # workflow_dispatch + # Remark: Next 5 lines triggers the workflow on push events for the main branch + push: + branches: + - dev + paths-ignore: + - "README.md" + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: write + if: github.repository_owner == 'nightscout' + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.x + + - name: Create, Activate and share a Python Virtual Env + run: | + python -m venv venv + source venv/bin/activate + # Persist venv related variables across the steps below + # See: https://stackoverflow.com/a/74669486/386517 + echo "PATH=$PATH" >> "$GITHUB_ENV" + echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> "$GITHUB_ENV" + + - name: Install Python Dependencies + run: pip install -r requirements.txt + + - name: Get Playwright Version (Headless Browser) + run: | + echo "PLAYWRIGHT_VERSION=$(playwright --version | cut -d ' ' -f 2)" >> $GITHUB_ENV + + - name: Cache Playwright Binaries + id: playwright + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ env.PLAYWRIGHT_VERSION }} + + - name: Install Playwright (if not cached) + if: steps.playwright.outputs.cache-hit != 'true' + run: playwright install --with-deps chromium + + - name: Build Website + run: mkdocs build + + - name: Push Website to gh-pages Branch + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: site diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..8b3e1ba3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +# macOS +.DS_Store + + +# Python Virtual Environment +venv*/ + +# Mkdocs +target/ +/build/ +/site/ + +# JS +node_modules/ + +# Playwright +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..dbbe3558 --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md new file mode 100644 index 00000000..fb638a8c --- /dev/null +++ b/README.md @@ -0,0 +1,262 @@ +Repository for [Trio documentation (under development)](https://docs.diy-trio.org) + +## Install + +- [**Clone**](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) this project +- Install **Python 3** + For help getting *Python* installed, see "[Properly Installing Python](http://docs.python-guide.org/en/latest/starting/installation/)". +- Install a **Python Virtual Environment**. + In this example, I use [`venv`](https://realpython.com/python-virtual-environments-a-primer/#how-can-you-work-with-a-python-virtual-environment), but use whichever you prefer. + ```shell + cd trio-docs # where you cloned the trio-docs repository + + # Creates a virtual environment using Python 3 in the venv folder + python3 -m venv venv + + # Activate the virtual environment + # IMPORTANT: Run the next line **each time** you start a new shell window/tab + source venv/bin/activate + ``` +- **Install** the **dependencies** (that is the project's required *Python* packages) + ```shell + cd trio-docs # where you cloned the trio-docs repository + + python -m pip install -r requirements.txt + ``` + +## Run + + +### Preview Changes + +Once [installed](#install), you can preview the doc locally as you make changes: + +- Run the **`mkdocs serve`** command locally in a separate terminal window and keep it running: + ```shell + cd trio-docs # where you cloned the trio-docs repository + source bin/venv/activate # Do this once when opening a shell or if the shell prompt no longer displays `(venv)` + + mkdocs serve + ``` + By default, this runs a local web server that hosts the documentation at http://127.0.0.1:8000/ . +* Preview the site in your Web browser. + Most changes will update automatically as you edit. + Configuration and navigation changes will require restarting `mkdocs serve`. + +### Build the Website Locally + +```shell +cd trio-docs # where you cloned the trio-docs repository +source venv/bin/activate # Do this once when opening a shell or if the shell prompt no longer displays `(venv)` + +mkdocs build +``` + +This does not generate the website's PDF version. + +### Build the PDF + +To export the website as a PDF: + +```shell +cd trio-docs # where you cloned the trio-docs repository +source venv/bin/activate # Do this once when opening a shell or if the shell prompt no longer displays `(venv)` + +MKDOCS_EXPORTER_PDF=true mkdocs build +``` + + The PDF file is generated in`site/trio-docs.pdf`. + +## Contribute + +You can contribute to the Trio documentation by correcting typos or suggesting new content. + +### Using the Terminal + +``` +cd trio-docs # where you cloned the trio-docs repository + +# Activate the Python virtual environment +# (if the shell prompt does not display `(venv)`) +source venv/bin/activate + +# Declare the official remote trio-docs GitHub repository +# The remote repository name convention is: +# - origin denotes your copy of the `trio-docs` repository on GitHub +# - upstream denotes the official `trio-docs` repository on GitHub +# You already created `origin` before. +# `upstream` does not exist yet, we now need to create it. +# +# These are shortcuts for the remote repositories +# short name => long name (URL) +# We use the short name not to memorize and type the long name (see line below) each time we need to interact with it. +# +git remote add upstream https://github.com/nightscout/trio-docs.git + +# Fetch the changes from the remote repositories +git fetch origin +git fetch upstream + +# Jump on the `dev` branch +# `dev` contains the source code for the site ready to be deployed) +git switch dev + +# Bring recent changes for the `dev` branch back from the official trio-docs repository (`upstream`) +git merge upstream/dev + +# Example: We want to add a FAQ page in the `docs/resources/` folder + +# Create (`-c`) and jump on a new feature branch where to add the FAQ page +# +git switch -c add_FAQ_page + +# Create then edit the new FAQ file (`faq.md`) +MY_FAVORITE_EDITOR_HERE docs/resources/faq.md + +# Edit, preview, repeat... +# until you are satisfied with the changes. + +# ➡️ 🏬: Add the FAQ page to the warehouse +git add docs/resources/faq.md + +# 🏬 ➡️ 🚚: Move all the changes from the warehouse into your **local** repository +git commit -am "Add FAQ page" + +# 🚚 ➡️ ⛅️: Push your feature branch `doc/add_FAQ_page` to your remote repository +git push -u origin add_FAQ_page +``` + +- Now open the **official trio-docs repository** in your **Web browser** + https://github.com/nightscout/trio-docs/pulls +- Click the **pull-requests tab** + This page displays a box saying you can create a Pull-Request for your branch. +- Click the button to do so, then follow the instructions. + +### Add a Plugin + +- Create a feature branch +- Add the pinned version of the new plugin to the **`requirements.in`** file + ```shell + MY_FAVORITE_EDITOR_HERE requirements.in + + # Add the pinned version (i.e. plugin name + version) to `requirements.in + XXX_PLUGIN_NAME_HERE==XXX_PLUGIN_VERSION_HERE + ``` + For example, add this line `mkdocs-exporter==6.1.1` to `requirements.in` +- Generate **`requirements.txt`** + ```shell + cd trio-docs + + # IMPORTANT: The project's virtual environment MUST be activated first + source venv/bin/activate + + # Remove already installed plugins + python -m pip freeze --exclude-editable | xargs python -m pip uninstall -y + + # Install the dependencies listed in `requirements.in` + # This installs the indirect dependencies these plugins depend upon. + pip install -r requirements.in + + # Generate `requirements.txt` with both direct AND indirect dependencies + pip freeze > requirements.txt + + # Commit the changes (where XXX denotes the plugin name) + git add requirements.in requirements.txt + git commit -m "➕ Add dependency XXX" + ``` + +## Tips & Tricks + +> [!NOTE] +> Please add! + +### Add a Chapter + +Using the `#` sign shows a chapter on the menu/index. The amount of `#`'s determines the level. + +**Example**: + +```markdown +# README + +## Tips & Tricks + +### Add a Chapter + +### Link to Another File +``` + +> [!TIP] +> If you want to avoid a chapter ending up in the menu/index, use bold text by: +> +> - either surrounding the text with 2-star signs `**` +> - or adding `` before the text and `` after the text (without spaces). +> +> | Input | Result | +> | ------------------ | ------------- | +> | `**bold text**` | **bold text** | +> | `bold text` | **bold text** | + +### Link to Another File + +When linking to another Markdown file (ending with `.md`) in another directory, the link must start with `../`. + +**Example**: `../directoryname/filename.md` + +### Migrate a Sphinx page to Mkdocs + +#### Migrate an Admonition from Sphinx to Mkdocs + +> [!NOTE] +> **What is an admonition?** +> An **admonition** is a rectangular box with a **title** (optional) and a text **body**. +> Each admonition type has a **specific icon** and box **border color**. +> +> For instance, a *warning* admonition has a yellow icon and border. Its icon is an exclamation sign in a yellow triangle. + +This is what an admonition looks like in **Sphinx**: + +```markdown +:::{warning} +This is not medical advice. +Understanding the changes you are making is important, and always be sure to exercise caution. +When in doubt, consult your diabetes care team for settings guidance. +::: +``` + +Here is what the same admonition looks like in "**Mkdocs**-material": + +```markdown +!!! warning + + This is not medical advice. + Understanding the changes you are making is important, and always be sure to exercise caution. + When in doubt, consult your diabetes care team for settings guidance. +``` + +where: +- The **title** line contains (in this order): + - 3 exclamation characters `!!!` + - a space ` ` + - the [admonition **type**](https://squidfunk.github.io/mkdocs-material/reference/admonitions/#supported-types), (`warning` in the above example) + - a space + - an optional **title** (none in this example) surrounded by double quotes. + We could have used `"Not a Medical Advice"` to set a title. +- Each line of the **body text** (lines below the title) + **must** be **indented 4-spaces**. + I use the `␠` character to denote a space (` `) in the example below. to make it stand out. Do not copy and paste this, it is only for visual purposes. + ```markdown + !!! warning "Not medical advice" + ␠␠␠␠ + ␠␠␠␠ Understanding the changes you are making is important [...] + ``` + +> [!TIP] +> **Separate the Title and Body with an Empty Line** +> +> - Adding a blank line (4 spaces indented) between the title and the body of the text makes a visual distinction for the reader. +> This is not required. +> - When present in the body text, empty lines must also use a 4-space indentation. + +> [!NOTE] +> Mkdocs (the site generation engine) does not provide admonitions but [mkdocs-material (the theme) does](https://squidfunk.github.io/mkdocs-material/reference/admonitions) via the `pymdownx` Markdown extension. diff --git a/dev-requirements.in b/dev-requirements.in new file mode 100644 index 00000000..70af3818 --- /dev/null +++ b/dev-requirements.in @@ -0,0 +1 @@ +mkdocs-translate diff --git a/docs/Analyze/EvaluateBasal.md b/docs/Analyze/EvaluateBasal.md new file mode 100644 index 00000000..4de49ac3 --- /dev/null +++ b/docs/Analyze/EvaluateBasal.md @@ -0,0 +1,44 @@ +## Evaluate Basal + +!!! warning "Not a Medical Advice" + + This is not medical advice. + Understanding the changes you are making is important, and always be sure to exercise caution. + When in doubt, consult your diabetes care team for settings guidance. + + +### Before Adjusting Basal Rates + +1. **Consider CR and ISF _First_** + - *Were carbs eaten in the last 3 hours?* + - *Are you in open loop?* + + !!! warning "Caution" + + Until you understand how the Trio algorithm works, you should only make basal adjustments after basal testing in an open loop. + +1. **Is this a one-time event, or does it happen consistently over multiple days?** + Make sure it happens twice at the same time of day before making any adjustments. + +### How to Adjust Basal + +!!! tip + + A general rule of thumb is to adjust the basal rate 1 hour before the CGM shows a change in glucose levels that you want to correct. This is determined by the approximate peak time of rapid-acting insulin. + +!!! example + + This person noticed an increase in their average CGM readings starting around 1:00 AM. They were in open loop and had no late-night snacks so that they could rule out CR and ISF as factors. Because the rise began at 1:00 AM, they should increase their basal rate at 12:00 AM. + +![Adjust Basal](img/adjustBasal.png){width="600px"} +{align=center} + +### Nightscout + +Nightscout (NS) is a valuable resource that provides detailed information for analyzing your settings. Nightscout reports and Loopalyzer can be great tools for understanding your data. + +#### Build Nightscout +[Instructions to build Nightscout](https://nightscout.github.io/nightscout/new_user/) + +#### Using Nightscout for Basal Adjustments +[How to use Loopalyzer](https://nightscout.github.io/nightscout/reports/#loopalyzer) diff --git a/docs/Analyze/EvaluateCR.md b/docs/Analyze/EvaluateCR.md new file mode 100644 index 00000000..60fdafb2 --- /dev/null +++ b/docs/Analyze/EvaluateCR.md @@ -0,0 +1,27 @@ +## Evaluate CR + +!!! warning "Not a Medical Advice" + + This is not medical advice. + It is important to understand your changes and always exercise caution. + When in doubt, consult your diabetes care team for settings guidance. + +### Before Adjusting CR + +With Trio, there is a reduced requirement for precise carb entries, although some precision will still improve outcomes. Some users prefer overestimating carb entries and giving a smaller percentage of the upfront bolus. Note: If you overestimate the carb entry and bolus for 100% upfront, the algorithm is limited in its ability to only suspend insulin as a means to prevent hypoglycemia following a meal. + +If you have been giving 100% of the needed bolus for meals, it might be best to try a smaller percentage upfront rather than adjusting your CR. + +### Nightscout + +Nightscout (NS) is a valuable resource that provides detailed information for analyzing your settings. Nightscout reports and Loopalyzer can be great tools for understanding your data. + +#### Build Nightscout +[Instructions to build Nightscout](https://nightscout.github.io/nightscout/new_user/) + +#### How to Use Nightscout for CR Adjustments +[How to use Loopalyzer](https://nightscout.github.io/nightscout/reports/#loopalyzer) + +Nightscout reports can provide crucial information to observe how fast the carbs decay. Open the day-to-day report in Nightscount and check the COB box and IOB box. You will see COB as orange “triangles.” If they decay too soon (in less than 2 hours or so, depending on the type and size of the meal), the carbs were either underestimated, CR could be too high a number, or ISF could be too low (carb decay is related to the fraction of CR/ISF) If you carbs take too long to decay, your insulin to carb ratio may be too strong. This can get complicated if meals overlap, but it is still possible. You may want to utilize the day-to-day report when that situation occurs. + +If the carb absorption observed by the algorithm is too slow, COB will eventually be cut down. This presents as a vertical drop in COB in the day-to-day report. This helps avoid overdosing on overestimated or not-eaten carbs or if physical activity delays digestion or mutes the BG rise. diff --git a/docs/Analyze/img/adjustBasal.png b/docs/Analyze/img/adjustBasal.png new file mode 100644 index 00000000..87108a05 Binary files /dev/null and b/docs/Analyze/img/adjustBasal.png differ diff --git a/docs/CNAME b/docs/CNAME new file mode 100644 index 00000000..1103a139 --- /dev/null +++ b/docs/CNAME @@ -0,0 +1 @@ +docs.diy-trio.org diff --git a/docs/Configuration/Configure.md b/docs/Configuration/Configure.md new file mode 100644 index 00000000..3d945010 --- /dev/null +++ b/docs/Configuration/Configure.md @@ -0,0 +1,18 @@ +# Device Configuration +This section covers the first two sections of Trio settings: [Closed Loop](#closed-loop) and [Devices](./Devices.md) + +## Closed Loop +Closed loop is turned off by default. This means Trio cannot make adjustments autonomously. Until you enable closed loop, the system relies on your approval of its actions. + +### When Should I Close the Loop? + +Closed loop allows the system to make insulin adjustments automatically. Your goal for looping is to enable this setting to reduce the time spent managing your diabetes. However, entering closed loop too early can make it difficult for new loopers wanting to optimize their application settings. If this is your first time looping, this setting should remain disabled until your profile settings (CR, ISF, basal rates) are correctly set. You should monitor Trio's predictions and suggestions to see if they are appropriate for you. Please look at the corresponding CR, ISF, and basal rates sections for more information on their adjustment. + +## Settings +**I've been using Loop. Can I copy my settings?** + +**_No._** Users coming from Loop usually adjust their ISF and CR settings to compensate for fluctuations in insulin needs throughout the day. When using those settings for Trio, the algorithm also adjusts to compensate for the fluctuations, which may result in over- or under-dosing. Please review the steps of monitoring Trio predictions and change your settings accordingly. It would help if you also read the section on [Coming from Other AID Systems](transition-qa.md). + +!!! tip + + Remember that everyone's diabetes is different, and there is no one-size-fits-all, so take the time to optimize your settings for the Oref algorithm. diff --git a/docs/Configuration/Devices.md b/docs/Configuration/Devices.md new file mode 100644 index 00000000..12db20cf --- /dev/null +++ b/docs/Configuration/Devices.md @@ -0,0 +1,25 @@ +# Devices +Adding devices to Trio is easy. You can only have one pump and one CGM active simultaneously. If you want to switch to another pump or CGM, delete the current device first. When you select a device, you will be guided through its setup with an on-screen guide. + +## Pump +This section asks you to select your insulin delivery system. For more information on supported pumps, you can find them under [Compatible Pumps](../Getting-Started/pump.md). Omnipod Eros and older Medtronic devices don't support Bluetooth. These devices require a Rileylink, OrangeLink, or EmaLink to translate communication between your phone's Bluetooth signals and the pump's radio communication signals. + +During pump setup, you will be asked to choose your insulin type. This will determine your duration of insulin action and peak action time. These settings can be changed later, though it is not recommended. + +## CGM +This section asks you to choose your glucose data source. Most options are self-explanatory. For more information on supported CGMs, please visit [Compatible CGMs](../settings/devices/cgm.md). + +### Changing transmitter on Dexcom G6 + +If you are using a Dexcom G6 sensor, you must remember to change your transmitter ID in the Trio app whenever you change transmitters. + +### Changing Dexcom G6 or G7 sensor + +Change the sensor through the Dexcom G6 or G7 app. Trio will automatically pick up the reading; you don't need to do anything else. + +### xDrip as BG source + +xDrip is not recommended with the Trio app, as native connections to CGM are more stable. + +## Watch +This section asks you to add a watch to Trio. Apple Watch and some Garmin watches are compatible. On an Apple Watch, you can add carbs and boluses, set a temporary target, and show BG, IOB, COB, etc. Garmin watches only display data and will not let you interact by adding carbs or insulin. diff --git a/docs/Configuration/transition-qa.md b/docs/Configuration/transition-qa.md new file mode 100644 index 00000000..41f9609c --- /dev/null +++ b/docs/Configuration/transition-qa.md @@ -0,0 +1,187 @@ +# Transition from other closed-loop solutions + +If you've been using other closed-loop solutions, it's essential to understand the differences between the one you're used to and Trio. + +In this section of the documentation, we'll explain the differences from a user perspective. + +## Coming From AndroidAPS +AndroidAPS and Trio are based on the same algorithm (Oref) and base system (Artificial Pancreas System, APS). While there are several differences between AndroidAPS and Trio, the main algorithm is the same, +meaning you can expect Trio to behave the same way AndroidAPS does generally. + +??? note "Benefits of AndroidAPS" + + - Custom automation + - Detailed reporting + - Working remote bolus (for caregivers, not working at the moment in Trio) + - A built-in learning program + +??? note "Benefits of Trio" + + - Trio works on your iPhone and Apple Watch + - Trio has dynamic CR support + +??? note "Should I switch from AndroidAPS to Trio?" + + - If you have been successful with AndroidAPS but prefer the Apple ecosystem, you can easily transition to Trio. + - If you've struggled to get stable BG with AndroidAPS, you may have the same issues with Trio. + +Take some time to read the docs and fine-tune your settings.
Once your settings are in order, consider switching to Trio. + +## Coming From iOS Loop +iOS Loop uses different algorithms, meaning it has a different approach than Trio. If you're coming from iOS Loop, you must change how you think. Please read that statement again three times, as it is crucial. + +??? note "Benefits of Loop" + + - A very clean, minimalistic user interface + - A built-in onboarding guide + - Simple settings + - A dedicated Loop Follow app for caregivers + +??? note "Benefits of Trio" + + - Unannounced meals + - Less user interaction/correction + - Dynamic ISF and CR + - Highly customizable temporary profiles + - Adaptive algorithm + +??? note "Should I switch from Loop to Trio?" + + - If Loop works well for you, you should not switch to Trio. + - Switching to Trio will not resolve Loop build issues. The build process is the same for both Loop and Trio. + - If you find it difficult to understand how Loop works, Trio is even more complex. + + You should consider switching to Trio if you've been using Loop for a while and have issues that Loop can't solve even after tweaking and re-tweaking your settings and profile. + +### Common Reasons Users Switch from Loop and How Trio Addresses Them + +??? note "Incorrect or missing carb entries" + + Trio has a feature called Unannounced Meals (UAM). With this option enabled and properly configured, Trio will react to rising BG by giving insulin through a Super Micro Bolus (SMB) even if no carbohydrates are registered. UAM helps in two scenarios: forgetting to add carbohydrates for a meal and entering carbohydrates but not the correct amount. + +??? note "Lots of manual corrections and "fake carbs" + + With UAM and SMB active and properly configured, Trio will make any necessary corrections. There is no need to add "fake carbs" to make Trio give insulin, as many Loop users are used to. + +??? note "Persistent highs because of variations in Insulin Sensitivity Factor (ISF) and Insulin-to-Carbohydrate Ratio (CR)" + + Many people with diabetes need more insulin as their BG rises. Because Loop uses constant, pre-set ISF and CR values; it cannot address the unexpected change in sensitivity. With dynamic ISF and dynamic CR enabled and properly configured, Trio will give enough insulin to lower those highs without user interaction. More aggressive settings might lead to a low. With less aggressive settings, it will take Trio some time to get BG back in range. The key is to find the effective balance between conservative and aggressive to meet your needs. + +??? note "Recurring/Rebound Lows" + + Properly configured, Trio will not give you insulin if you don't need it. A typical issue with Loop is that it stops delivering insulin when BG falls and then gives insulin from the "negative IOB" once BG starts rising again. For some users, this is too much insulin and leads to recurring lows. Properly configured, Trio will not overcompensate for the rapid BG rise after a low. + +??? note "Difficulties dealing with exercise" + + Exercise is good for everyone, including people with diabetes. People with insulin-dependent diabetes often struggle with lows during exercise and highs afterward. Trio has a built-in exercise mode that will reduce basal and ISF whenever you set a higher temporary BG target. Trio also has Profile Presets that can help you get the right amount of insulin during exercise. Profiles can also adjust CR, unlike temporary targets. + +??? note "Frequent, consistent variations in profile (Basal, ISF, CR)" + + Illness, menstrual cycle, inactive days, active days, home office days, stressful events... In these situations, the overall insulin need differs from your usual need. Like Loop's Overrides, Trio has Profiles that can change basal rate, ISF, CR, and target BG within a pre-set timeframe. What Trio Profiles do that Loop Overrides do not do is provide the option to temporarily disable SMBs and apply adjustments to only basal, basal, and ISF, basal and CR, or all three. + + +If any of those sound familiar, consider a switch to Trio + +!!! important + + You must read extensively and adapt to a new approach to diabetes management. + +**What's All That Talk About Changing the Way I Think?** + +Loop is carb-centric. Loop users have been instructed to enter carbs, including future carbs (fat, protein), to ensure Loop gives the right amount of insulin. Some users also enter "fake carbs" to force Loop to give more insulin. + +The Trio algorithm does not consider future carbs. What does this mean? The algorithm considers many factors, adds guardrails, and then acts by setting a temporary basal, administering a bolus (SMB), or both. Future carbs are not considered. The algorithm does not care about any future carbohydrates you might have entered. + +**Wait, what!? You have to consider carbohydrates, right? Why else would I add them?** +*Trio considers carbohydrates only once absorbed and part of Carbohydrates On Board (COB).* + +### Mealtime Strategy + +??? note "So what's the mealtime strategy then?" + + 1. Use the bolus calculator before you eat. Enter carbohydrates (and fat and protein if you want). Look at the recommended bolus and tap the info button if you disagree with it. + 2. Change the recommendation if you want to, and then bolus. If the recommendation is way off, you should check your settings. Remember that the recommendation is based on your settings, including the "Recommended bolus percentage" setting. + 3. Depending on your insulin type and sensitivity, you should consider doing this some minutes before eating. You do not need to adjust the carbohydrate timestamp to the actual time you plan to eat; you can keep it when you announce the meal and pre-bolus. + 4. Enjoy your meal. In most cases, Trio will set a temporary low/zero basal. + 5. If Trio detects BG is rising faster or more than expected, it will give more insulin (SMB) depending on the settings. + 6. If Trio detects BG falling, a low/zero temporary basal will continue. + 7. If you think Trio is not giving enough or too much insulin, you should look at your settings, including MAX IOB and all SMB-related settings. + +??? note "Does everyone do it like that?" + + No + +??? note "What are the alternatives?" + + - Some Trio users don't bolus for meals. They wait for Trio to detect rising BG and let Trio handle it. This usually leads to a temporary high BG, but Trio will get you back to target with the correct settings. If you're OK with a temporary high, then go ahead and try to skip bolus. You can start with small meals and tune your settings. You will need aggressive settings to let Trio give enough insulin. + - Some Trio users do a manual pre-bolus and skip entering carbs. Trio will predict a low BG until the meal kicks in and BG begins rising. If the pre-bolus is insufficient, Trio will give more insulin based on your settings. Yes, even without entering any carbohydrates. This approach will also result in a temporary high that is shorter than the completely unattended approach. + +??? note "What do most people do?" + + Most Trio users take a bit of all these approaches. They have an apple without entering anything into the app. Then, they pre-bolus for lunch because it is high in carbohydrates. Then, they use the calculator for dinner. This is all OK, and it comes down to the variation you accept for your BG. + +## Coming From iAPS + +### iAPS Ver 2.3.3 or Earlier + +Transitioning from iAPS 2.3.3 to Trio is currently straightforward. The screens and menus will be very familiar. + +#### Settings + +Your settings will need to be entered manually, but they can all be entered one-by-one from your iAPS settings without adjustment. If you have Nightscout, you can import your Pump Settings, Basal Profile, ISF, CR, Target Glucose, and previous CGM readings from the Nightscout Menu. + +Import Settings With Nightscout + + 1. Connect Nightscout to your Trio app (If you've already connected your Nightscout site, skip to step 2) + * Open the Settings Menu ⚙️ in the Trio app + * Tap `Nightscout` to open the Nightscout Menu + * Tap `Connect >` + * Enter your Nightscout URL and API Secret in the spaces provided + * Press `Connect to Nightscout` + 2. Verify the `Glucose Units` in the Trio app match the units used in Nightscout (If they do not match, the import will fail) + * Open the Settings Menu ⚙️ in the Trio app + * Tap `Preferences` to open the Preferences Menu + * Verify the `Glucose Units` are correct + 4. Import settings + * Open the Settings Menu ⚙️ in the Trio app + * Tap `Nightscout` to open the Nightscout Menu + * Tap `Import settings` + 5. Backfill Glucose + * In the same Nightscout Menu, you can also backfill missing glucose readings from Nightscout +
+ +!!! warning "Dynamic Settings" + + Because Trio is a separate app, your historical data from iAPS will not transfer. It is recommended that you wait 7 days before you enable dynamic settings. In the meantime, you may notice some adjustments made by autosens. + +### iAPS ver 3.0 or Later + +#### Settings + +As with iAPS ver 2.3.3, your settings must be entered manually and/or [transferred from Nightscout](#iaps-ver-233-or-earlier). It is also recommended that you wait 7 days before enabling dynamic settings. In the meantime, you may notice some adjustments made by autosens. + +#### Other Differences + +Trio was forked from iAPS ver 2.3.3. If you used iAPS prior to February 2024, you may recognize the main screen. As the Trio app develops, the screen and menus will diverge substantially from iAPS 2.3.3 and 3.0+. For now, the focus has been on the code behind the scenes. For a comprehensive list of all changes and updates made to create Trio, please view the [PR](https://github.com/nightscout/Trio/pull/2) that merged all the foundational, developmental work into the main version used today. + +## Coming From Commercial Closed-Loop Systems + +Are you using a commercial closed-loop system like Insulet's Omnipod 5, Tandem's Control IQ, Medtronic's 780G, etc.? If you're happy, please stay; if you're not getting the desired results, take the time to read through the [Coming From iOS Loop](#coming-from-ios-loop) chapter to see the main issues Trio solves. + +**I Want to Try Trio. How Do I Proceed?** + +- Read the documentation. +- Build the app. +- Go through all the settings and tap the setting name to get an explanation of what each setting does. + + +If you have any questions, feel free to reach out on [Discord](https://discord.gg/FnwFEFUwXE) or [Facebook](https://www.facebook.com/groups/diytrio). But please read the docs first. + +#### Watch the Loop and Learn Videos on Trio (Previously Referred to as "iAPS"): +- [Open Mic: iAPS ver 2.0 with Magnus Reintz & Theresa Hastings, 8.3.2023](https://youtu.be/Jubfy-s9URI?si=cKOMb2mcHzBJdPIb) +- [iAPS ver 2.0 with Magnus Reintz & Theresa Hastings: Starting Trio, 8.17.2023](https://youtu.be/9I1nuHbcUHo?si=wlRurW3Qh_60ss2d) +- [iAPS ver 2.0 Q&A with Magnus Reintz, Tom Barrows, Jonas Hummelstrand & Theresa Hastings, 30 August 2023](https://youtu.be/Li3AKjSrdPw?si=WwLctkAGjVsbDLNs) + + + + diff --git a/docs/Getting-Started/Overview.md b/docs/Getting-Started/Overview.md new file mode 100644 index 00000000..550a1860 --- /dev/null +++ b/docs/Getting-Started/Overview.md @@ -0,0 +1,31 @@ +# Overview + +## What is Trio? +Trio is an open-source artificial pancreas system based on the OpenAPS (Oref0) algorithm. Using your entered settings, carbohydrates, and historical data, it aims to automate insulin delivery to reduce the time spent managing your diabetes. Before starting with Trio, you should consider alternative commercial options such as the Tandem Control-IQ and Omnipod 5 or other open-source applications like Loop and AndroidAPS. + +!!! important "Important" + + _Trio is not approved by any healthcare authority. You build and run this system at your own risk._ + +## Getting Started +Before starting with Trio, you should understand CR, ISF, and Basal Rates. + +If you do not understand the terminology, please read the appropriate documentation here: + +[Carb Ratio (CR)](../settings/configuration/carbratios.md) + +[Insulin Sensitivity Factor (ISF)](../settings/configuration/insulinsensitivities.md) + +[Basal Rates](../settings/configuration/basalprofile.md) +
+ +If you require help defining and determining those settings, please seek assistance from your diabetes healthcare team. + +To use Trio, you are required to build the application from the source code. This does not require substantial technical know-how but is a time-consuming process. You may need to carry this out through several sessions on your first attempt. + +Upon installation, you will need to configure your settings appropriately. For step-by-step instructions on using the app, follow the [start-up guide](http://diy-trio.org/start-up-guide). + +**Ready to Get Started?** +Head to the [New User Guide](../Setup/New-User-Setup.md) to get started! + + diff --git a/docs/Getting-Started/cgm.md b/docs/Getting-Started/cgm.md new file mode 100644 index 00000000..0fd8e006 --- /dev/null +++ b/docs/Getting-Started/cgm.md @@ -0,0 +1,34 @@ +# CGM +This section allows you to choose your glucose data source. Most options are self-explanatory. For more information on compatible CGMs, please see the following: [link](../settings/devices/cgm.md#compatible-cgm) + +CGM selection includes the following: +* [Nightscout](#nightscout) +* [xDrip](#xdrip-xdrip4ios) +* [Dexcom G5/Dexcom G6/Dexcom ONE](#dexcom-g5-g6-and-dexcom-one) +* [Dexcom G7/Dexcom ONE+](#dexcom-g7-and-dexcom-one) +* [Glucose Simulator](#glucose-simulator) +* [Libre Transmitter](#libre-transmitter) +* [Medtronic Enlite](#medtronic-enlite) + +## Nightscout +While using Nightscout as a CGM is an option, it should be avoided if possible because it does not keep Trio running in the background like other CGM options. + +## xDrip (xDrip4iOS) +To use xDrip4iOS as a cgm source, you must build it yourself with the same Apple Developer account you used to build your Trio app. You cannot use Shuggah or a version distributed by someone else's TestFlight. Please see the following for instructions on how to build xDrip4iOS yourself: [link](../operate/build.md#xdrip4ios-as-cgm-source) + +However, if you are using Dexcom G6 or ONE with xDrip4iOS, you can choose the Dexcom G6 option in Trio rather than xDrip4iOS, and Trio will intercept the glucose readings even if you're using Shuggah or someone else's TestFlight of xDrip4iOS. + +## Dexcom G5, G6 and Dexcom ONE +Trio can intercept glucose readings between the transmitter and the Dexcom app. If you are using a Dexcom G5, G6, or ONE sensor, tap Configuration CGM to enter your transmitter's 6-digit ID. Dexcom Share Credentials are not necessary. When you switch transmitters, you must delete your current transmitter from Trio by tapping Configuration CGM, scrolling down, and tapping Delete CGM. Once you do this, you can add the new transmitter with its Transmitter ID. + +## Dexcom G7 and Dexcom ONE+ +As long as the Dexcom G7 or ONE+ app is installed on the same phone, Trio can intercept its glucose readings. When a new G7 or ONE+ sensor is paired to the Dexcom app, Trio will automatically start reading it. + +## Glucose Simulator +This option should ***only*** be used when learning how to interact with the app. It should not be used to learn how the algorithm will respond, nor should it ever be used on a living being. + +## Libre Transmitter +This option can be used to pair a compatible Libre cgm directly to Trio without going through a separate app like xDrip4iOS. + +## Medtronic Enlite +The Minimed Enlite CGM, available with the Medtronic 522/722, 523/723, and 554/754, wirelessly sends glucose readings to the pump. Trio can read the Medtronic CGM data directly from the pump using a RileyLink-compatible device. diff --git a/docs/Getting-Started/img/dash.png b/docs/Getting-Started/img/dash.png new file mode 100644 index 00000000..f5770efa Binary files /dev/null and b/docs/Getting-Started/img/dash.png differ diff --git a/docs/Getting-Started/img/eros.png b/docs/Getting-Started/img/eros.png new file mode 100644 index 00000000..5fbc06b0 Binary files /dev/null and b/docs/Getting-Started/img/eros.png differ diff --git a/docs/Getting-Started/img/esc.png b/docs/Getting-Started/img/esc.png new file mode 100644 index 00000000..a231aed1 Binary files /dev/null and b/docs/Getting-Started/img/esc.png differ diff --git a/docs/Getting-Started/img/light_button.png b/docs/Getting-Started/img/light_button.png new file mode 100644 index 00000000..866717d6 Binary files /dev/null and b/docs/Getting-Started/img/light_button.png differ diff --git a/docs/Getting-Started/img/pump.png b/docs/Getting-Started/img/pump.png new file mode 100644 index 00000000..33eede98 Binary files /dev/null and b/docs/Getting-Started/img/pump.png differ diff --git a/docs/Getting-Started/img/pump_firmware.png b/docs/Getting-Started/img/pump_firmware.png new file mode 100644 index 00000000..bf28b302 Binary files /dev/null and b/docs/Getting-Started/img/pump_firmware.png differ diff --git a/docs/Getting-Started/img/pump_model.jpg b/docs/Getting-Started/img/pump_model.jpg new file mode 100644 index 00000000..b655f69c Binary files /dev/null and b/docs/Getting-Started/img/pump_model.jpg differ diff --git a/docs/Getting-Started/iphone.md b/docs/Getting-Started/iphone.md new file mode 100644 index 00000000..7b252860 --- /dev/null +++ b/docs/Getting-Started/iphone.md @@ -0,0 +1,73 @@ +## Compatible Devices + +Trio requires a relatively recent iPhone. The faster the phone, the better for the algorithm and battery life. You need a minimum version of the mobile operating software, called the phone's "iOS", to be installed on your iPhone. Trio is compatible with iPhones running on iOS 16 or newer. + +### iPhone + +These devices are compatible with iOS 16 and newer iOS. + +- iPhone 15, all variants +- iPhone 14, all variants +- iPhone 13, all variants +- iPhone 12, all variants +- iPhone 11, all variants +- iPhone X, all variants +- iPhone 8, all variants +- iPhone SE (3rd generation; 2022 first release) +- iPhone SE (2nd generation; 2020 first release) + +#### iOS Version and Developer Mode + +**Find Your iOS Version** + +Your phone's iOS version can be found under the phone Settings -> General -> About display. The iOS number is found on the `Software Version` line. When you start looping, you should delay iOS updates until others have confirmed the software functions as normal on the newest update. + +!!! warning + + Using iOS Beta versions on the iPhone used for insulin delivery is **never** recommended. + +**Developer Mode - Mac Build** + +With iOS 16 and watchOS 9, Apple added a feature called "Developer Mode." This feature must be enabled on your iPhone and Apple Watch to allow the installation of Trio. To learn more, click on this link: [Apple Link about Developer Mode](https://developer.apple.com/documentation/xcode/enabling-developer-mode-on-a-device). + +When you build Trio on your phone from Xcode directly, you must enable Developer Mode. This is also required in order to use the Trio app on a watch paired to your phone. + +!!! tip "Developer Mode with iOS 16, watchOS 9" + + If you already have Trio, built with Xcode on a Mac, on your phone/watch, when you update to iOS 16/watchOS 9, you will be told that Trio requires Developer Mode to run. + + You cannot run Trio on your phone (or watch) until you have enabled Developer Mode on the device(s). + +#### Automatic Updates + +Apple provides frequent updates to the iOS. These updates often include critical security patches and improved new features. Updates to iOS _could_ make Trio stop working. +**Minor** updates (like 16.5 -> 16.5.1) are usually not an issue. +**Major** updates (like 17.x -> 18.x) often contain changes that Trio developers need to include in the app. + +!!! warning "Turn Off Automatic Update Installs!" + + * Once you accept an iOS update, you cannot go backward + * Some iOS updates require updates to Xcode and macOS before people can build Trio on that device again + * It is rare, but iOS updates have caused Trio to stop working until other updates were made and Trio was rebuilt on that phone + * Turn off automatic updates so you can choose when to update your phone and avoid being caught without a working Trio app + * Google the instructions for your device: + 1) Configure your phone to *download* the updates automatically + 2) Choose to perform the *installation* of the updates manually + +#### Battery Health + +Make sure your phone's battery is functioning optimally. Your phone will become a critical health device, and you want it to keep working. + +* Make sure a charger and cord are in your diabetes supplies +* Consider buying a battery pack, keep it charged, and add it to your travel bag + +!!! tip "Low Power Mode" + + Some people have reported that Trio continues working in the background (phone locked) even in [Low Power Mode](https://support.apple.com/en-us/HT205234). Others have reported that they still get red loops. You can experiment to determine if your phone/iOS/app is able to maintain green loops in low-power mode. Otherwise, the best practice is to avoid Low-Power Mode. + + +### Apple Watch + +Trio has a companion app for the Apple Watch. The companion app shows the loop status and current insulin and carbs onboard. It also lets you add carbs, do a manual bolus, and set a temporary target. However, the companion app only serves as a remote control for the iPhone app; connection to the CGM and pump is still done through your iPhone, and you will have to bring it with you. + +Apple Watch Series 3 and newer are supported. Newer versions of the Apple Watch have better battery life and support always-on display. diff --git a/docs/Getting-Started/pump.md b/docs/Getting-Started/pump.md new file mode 100644 index 00000000..55f886dc --- /dev/null +++ b/docs/Getting-Started/pump.md @@ -0,0 +1,153 @@ +## Compatible Pumps + +There are three pumps compatible with Trio: + +* Omnipod Dash pumps +* Omnipod Eros pumps +* Older Medtronic pumps +* DanaRS (_Coming Soon!_) + + +No other pumps work with Trio at this time, but other open-source closed-loop options, such as [AAPS: Android Artificial Pancreas System](https://androidaps.readthedocs.io/en/latest/index.html) and [OpenAPS](https://openaps.readthedocs.io/en/latest/), support other pumps. + +### Omnipod Pumps + +!!! not "Reminder and Disclaimer" + + The use of Omnipod pumps with Trio is not supported by Insulet, although they are aware it is happening. Do not call Insulet asking for help with your Trio build, setup, or operation. You are fully responsible for your use of Trio and do so at your own risk. Please read these documents and familiarize yourself with Trio before using the app. + +#### Omnipod Eros + +Eros pods were launched in 2013 and continue to be sold by Insulet. As of December 2023, they are no longer available in the US but are obtainable in other countries for now. Eros pods are also referred to as "Omnipod System", "Omnipod Classic", or "Gen3". The Eros uses radio waves for communication between the Pod and the PDM. The iPhone does not support these radio waves, so in order to use Eros with Trio, you need to get a separate device that can translate radio waves to Bluetooth. These devices are called RileyLink, EmaLink, etc. + +![eros](img/eros.png) +{align=center} + +#### Omnipod DASH + +The DASH pods were launched in 2019 and use Bluetooth, so they don't require a RileyLink or similar device as they connect directly to the phone. DASH pods are easy to identify with their blue tab instead of the clear tab used on Eros and Omnipod 5. + +![dash](img/dash.png) +{align=center} + +!!! danger "Omnipod 5" + + **Omnipod 5 pods are _NOT_ compatible with Trio** + + +### Medtronic Pumps + +![pump](img/pump.png) +{align=center}) + +There are a number of Medtronic insulin pumps manufactured between 2006 – 2012 which are Trio compatible. Compatibility has two requirements: (1) pump model and (2) firmware. + +* Medtronic 515 or 715 (any firmware) +* Medtronic 522 or 722 (any firmware) +* Medtronic 523 or 723 (firmware 2.4 or lower) +* Medtronic Worldwide Veo 554 or 754 (firmware 2.6A or lower) +* Medtronic Canadian/Australian Veo 554 or 754 (firmware 2.7A or lower) + +If you have one of the pumps listed above, you are good to go on Trio! Congrats! + +#### Medtronic Pump Model + +To determine your pump model, look at the backside of your pump. There should be a sticker on the underside of the pump. On the right-hand side of the sticker, it says REF MMT-XXXXXX + +![pump_model](img/pump_model.jpg) +{align=center} + + * MMT ---> Pump Manufacturer Model (MiniMed Medtronic) + * 722 ---> Pump Model Number + * NA ---> Pump Region (NA=North America, CA=Canada/Australia, WW=Worldwide) + * S ---> Pump Color (S=Smoke, L=Clear/Lucite, B=Blue, P=Pink/Purple) + +Some pumps may have an “L” or “S” or "R" before the pump region, e.g., a model number like MMT-722LNAS. This does not affect Trio compatibility. + +#### Medtronic Pump Firmware + +A pump’s firmware is the internal software that runs your pump. Older Medtronic firmware allows Trio to act as a “remote control” to set temp basals and report back pump data. Newer firmware has disabled that “remote control” access and, therefore, cannot be used with these DIY closed-loop systems. There is currently no ability to downgrade a pump’s firmware or replace it with older firmware. Before you buy a used pump, make sure you are getting one with compatible firmware. You cannot change the firmware on a Medtronic pump. + +The firmware on all 515/715 and 522/722 model Medtronic pumps is compatible with Trio. You will only need to check the firmware version for 523/723 and 554/754 model Medtronic pumps. + +* Medtronic 515 or 715 (any firmware) +* Medtronic 522 or 722 (any firmware) +* Medtronic 523 or 723 (firmware 2.4 or lower) +* Medtronic Worldwide Veo 554 or 754 (firmware 2.6A or lower) +* Medtronic Canadian/Australian Veo 554 or 754 (firmware 2.7A or lower) + +To find your pump’s firmware, you will need to power it on. If the pump has not been powered on for some time (i.e., it has been in storage without a battery for a while), it will run through a start-up count, and the firmware version will appear on the bottom right of the pump’s screen. Don’t turn away, as the version number will only be displayed for a little while before the screen moves on to other information displays. + +If the pump has been active recently or has a reservoir installed, follow these steps: + +1. Press the ![esc](img/esc.png) button on your pump. + +2. Scroll down to the bottom of the status display by clicking the ![light](img/light_button.png) button. + +3. Read the bottom line of the display. + +![pump_firmware](img/pump_firmware.png) +{align=center} + +#### Medtronic Pump Differences + +If you are in the position of being able to shop around for different pump models, there are some slight differences between the Trio-compatible Medtronic pumps. + +**500 vs 700**: The difference between the Medtronic 500 series and the 700 series pumps is the size of the insulin reservoirs. The 500 series pumps use a 180-unit reservoir, and the 700 series pumps use a 300-unit reservoir (or a smaller 180-unit reservoir, if you want). + +**x15/x22 vs x23/x54**: The noteworthy differences between the x15 and x22 pumps versus the x23 and x54 series pumps are: + +* The x23/x54 pumps will allow for smaller insulin deliveries in certain situations if the smaller scroll rate is selected in the Bolus>Setup>Scroll Rate menu. **Trio will have the insulin delivery automatically rounded by the pump to the units available in the pump model, and any smaller adjustments (to make up for the rounding) will be made through Trio’s use of temp basals. If you want the smaller increments of basal rates, you can still enter those values in the Trio app's settings and Trio will use those values for the purposes of insulin delivery calculations.** + +|Pump Model |Basal increments |Bolus increments |Range | +|---------|---------|---------|---------| +|515/715
and
522/722 | 0.05
0.1 | 0.1
0.1 | deliveries of less than 10 units
greater than 10 units | +|523/723
and
554/754 | 0.025
0.05
0.1 | 0.025
0.05
0.1 | between 0.025 to 0.975 units
between 1 to 9.95 units
greater than 10 units | + +* Additionally, because of the way Trio fetches information from the pump, the x23/x54 series of pumps are slightly better at conserving battery life through the use of the MySentry packets to collect information from the pump. x22 pumps do not use MySentry. + +* The x23/x54 series pumps are also faster at delivering boluses greater than 10 units. On an x23 pump, a 13-unit bolus takes 5:00 minutes to complete. On an x22 pump, a 13-unit bolus takes 8:40 minutes to complete. + +#### Finding a Medtronic Pump + +Finding a compatible Medtronic pump is probably the most difficult part for most new Trio users. Our suggestions: + +* Talk to friends in the diabetic community. + +* Ask your endocrinologist. + +* Ask at a local JDRF chapter meeting if someone has an old backup pump they'd be willing to donate to you. + +* Join diabetic supply groups on Facebook, both for-trade and for-sale groups. [Looping in a time of COVID](https://www.facebook.com/groups/1087611668259945/) is a group focused on DIY looping devices and supplies. Be sure to read their rules before joining. + +* Check Craigslist often and be willing to expand your search area to include larger cities. + +* Check out the **HelpAround, NextDoor, OfferUp, and LetGo** apps for pumps. + +The most successful results appear to come from either one-on-one discussions with fellow diabetics/doctors or the use of apps (Craigslist, NextDoor, LetGo, HelpAround). If you are using Craigslist, you may use an app on your iPhone to make the searching easier. There are apps to search multiple cities for pre-set keywords and set up alerts. + +#### Safe Purchasing + +If you choose to purchase from a remote or unknown seller, here are some tips for safe purchasing: + +* Use PayPal and purchase using the "Goods and Services" payment option. This costs nothing for the buyer, but the seller will lose 2.95% of the sale to PayPal fees. PayPal offers some protection for both buyer and seller in the event of fraud. + +* Ask for photos of the pump. Check the serial number on the backside of the pump and verify it matches the pump's serial number shown in the display menu. Ask for a short video of the pump or at least a photo of the pump turned on so that you can see the pump's firmware and model number. Cracks and some wear on these pumps are expected. These pumps are not usually free of marks. Many people are successfully looping on pumps with cracks and rub marks, but you may want to ask if you are concerned about any you see in photos. + +* Beware if the bottom of the reservoir/motor sleeve has the drive support cap pushed out, as shown [here](https://loopkit.github.io/loopdocs/troubleshooting/pump-errors/#motor-error). Those pumps will generally not work (or only work intermittently); however, some people have successfully repaired those pumps, as shown in that link. Just to make sure you know, it should be checked in advance. + +* Repairs to cracks or missing bits of plastic on battery cap area and reservoir caps are possible and not very difficult in most situations. You can read more about how to repair those [here](https://loopkit.github.io/loopdocs/troubleshooting/pump-errors/#crackmissing-piece-repairs). + +* Ask for shipping that includes a tracking number. USPS Priority Mail's smallest box is a great option. It's only $10.40 domestically in the US and provides tracking. Ask the seller to add some packing protection around the pump, such as bubble wrap, to keep it safe during shipping. Ensure you get a tracking number within a reasonable period after you have paid. + +Red flags that may indicate a scam: + +* Asking for payment through "friends and family" on PayPal, especially if you don't know the person or have any solid references for them. Paying in that way offers you no buyer protection. It's just like giving the seller cash, so you had better trust the seller. + +* Offering an "almost new" pump is a big red flag. These pumps were manufactured between 2006-2012. It is highly unlikely that a pump of that age is unused and sitting in shrink wrap. There are some out there, but they are scarce. + +* The seller is not able to provide new pictures of the pump when requested. Sure, they posted some photos with the ad, but what if they downloaded them from other people's ads? The seller should be able to furnish a couple of "new" photos at your request. A good one to ask for is the battery and reservoir tops so you can see their condition. + +#### Pump Supplies + +Medtronic will not typically sell pump supplies directly to customers who have yet to purchase a registered Medtronic pump. Ask your insurance about purchasing pump supplies through a durable medical equipment (DME) provider. Typically, the DME provider will coordinate with your insurance and doctor's office to get the necessary insurance approval and prescriptions for the supplies. If you are brand new to Medtronic infusion sites, ask for help from friends to try a variety of infusion sets before purchasing an entire 90-day supply of any type in particular. diff --git a/docs/Setup/New-User-Setup.md b/docs/Setup/New-User-Setup.md new file mode 100644 index 00000000..867bf57b --- /dev/null +++ b/docs/Setup/New-User-Setup.md @@ -0,0 +1,91 @@ +# New User Setup + +Welcome to the New User Setup Guide! This guide walks you through how to set up your Trio app once you have installed it on your phone. If you still need to install the app, head to the [Build Instructions](../operate/build.md) and come back here when you are ready to start the setup process! + +To set up your Trio app, touch the settings icon ⚙️ located on the bottom right of the main screen. Each step contains links to information on setting up each part of your Trio app. Use this as your home base to refer back to as you set up your app. + +## Step 1: Connect your Devices + +The first step in setting up your Trio app is to connect your devices to the app. + +### Verify Compatibility + +If you have not already, please verify that your devices are compatible: + + 1. [Phones/Watches](../Getting-Started/iphone.md) + 2. [Pumps](../Getting-Started/pump.md) + 3. [CGMs](../settings/devices/cgm.md) + +### Connect Devices + +Once you have verified that you are using compatible devices, you can connect them in the Trio app settings menu. + +![Devices Settings](img/DeviceMenu.png){ width="300px" } +{align=center} + + 1. [Pump](../Configuration/Devices.md#pump) + 2. [CGM](../Configuration/Devices.md#cgm) + 3. [Watch (optional)](../Configuration/Devices.md#watch) + +## Step 2: Add Profile Settings + +The next step is to enter your main profile settings: Basal, ISF, CR, and Target Glucose. + +!!! important "Important" + + If you use `mg/dL`, you must first change the 'Glucose Units' **before** entering your profile settings. + + This is found in the Trio Settings menu under 'Preferences' + + + 1. [Basal](../settings/configuration/basalprofile.md) + 2. [Insulin Sensitivity Factor (ISF)](../settings/configuration/insulinsensitivities.md) + 3. [Carb Ratio (CR)](../settings/configuration/carbratios.md) + 4. [Set Target Glucose](../settings/configuration/targetglucose.md) + +## Step 3: Adjust Safety Limits + +The next step is to adjust the standard safety limits that will allow Trio to function effectively. There are many more settings that are not mentioned in this section. It is not advised to adjust those until you have familiarized yourself with the system by using it for a while. + +!!! warning + + **DO NOT ENABLE DYNAMIC SETTINGS YET** + + It is essential that Trio have enough data to make sound recommendations. It is essential that your settings are tuned to be used in an Oref algorithm and you feel comfortable using the Trio app. It is not recommended to enable dynamic settings until ALL criteria below are met: + + - You are confident that your ISF, CR, and Basal Rates are tuned for use in the Oref algorithm + - You have used Trio with a real CGM and real pump (not simulators) for the recommended minimum of 7 consecutive days + - You are comfortable with the Trio app + + 1. [Recommended Bolus Percentage](../settings/configuration/preferences/trio.md#recommended-bolus-percentage) + 2. [Max IOB](../settings/configuration/preferences/mainsettings.md#max-iob) + 3. [Max COB](../settings/configuration/preferences/mainsettings.md#max-cob) + 4. [Bolus Increment](../settings/configuration/preferences/smbsettings.md#bolus-increment) + 5. [Enable SMB](../settings/configuration/preferences/smbsettings.md) + 6. [Enable UAM](../settings/configuration/preferences/smbsettings.md#enable-uam) + 7. HANDS OFF DYNAMIC SETTINGS! + +## Step 4: Enable Closed Loop + +Closed loop functionality is turned off by default. This means Trio cannot make adjustments automatically. The system relies solely on you to make any recommended adjustments while Closed Loop is OFF. You can control your pump and bolus with the Trio app, but nothing can be done without your approval. This is often referred to as running an 'open loop.' + +![Enable Closed loop](img/closeLoop.png) +{align=center} + +[More on closing the loop](../Configuration/Configure.md) + +## Step 5: Change App Icon (Optional) + +Under "App Icons" in the Settings Menu, you can find various icons for your Trio app. + +![Change App Icon](img/changeAppIcon.png) +{align=center} + + +Have a special icon in mind? +You can use your own custom icon by following the instructions under [Customizations](../operate/customize.md). + +***Congratulations!*** You've completed the New User Setup for Trio! + + + diff --git a/docs/Setup/img/DeviceMenu.png b/docs/Setup/img/DeviceMenu.png new file mode 100644 index 00000000..b4aa2076 Binary files /dev/null and b/docs/Setup/img/DeviceMenu.png differ diff --git a/docs/Setup/img/changeAppIcon.png b/docs/Setup/img/changeAppIcon.png new file mode 100644 index 00000000..22fa0ac7 Binary files /dev/null and b/docs/Setup/img/changeAppIcon.png differ diff --git a/docs/Setup/img/closeLoop.png b/docs/Setup/img/closeLoop.png new file mode 100644 index 00000000..7ad05f86 Binary files /dev/null and b/docs/Setup/img/closeLoop.png differ diff --git a/docs/assets/images/background.png b/docs/assets/images/background.png new file mode 100644 index 00000000..bc53884b Binary files /dev/null and b/docs/assets/images/background.png differ diff --git a/docs/assets/images/favicon.ico b/docs/assets/images/favicon.ico new file mode 100644 index 00000000..c77358a6 Binary files /dev/null and b/docs/assets/images/favicon.ico differ diff --git a/docs/assets/images/trio-logo.png b/docs/assets/images/trio-logo.png new file mode 100644 index 00000000..ca245435 Binary files /dev/null and b/docs/assets/images/trio-logo.png differ diff --git a/docs/assets/javascripts/mathjax.js b/docs/assets/javascripts/mathjax.js new file mode 100644 index 00000000..5209b3c1 --- /dev/null +++ b/docs/assets/javascripts/mathjax.js @@ -0,0 +1,19 @@ +window.MathJax = { + tex: { + inlineMath: [["\\(", "\\)"]], + displayMath: [["\\[", "\\]"]], + processEscapes: true, + processEnvironments: true, + }, + options: { + ignoreHtmlClass: ".*|", + processHtmlClass: "arithmatex", + }, +}; + +document$.subscribe(() => { + MathJax.startup.output.clearCache(); + MathJax.typesetClear(); + MathJax.texReset(); + MathJax.typesetPromise(); +}); diff --git a/docs/assets/javascripts/mkdocs-exporter.js b/docs/assets/javascripts/mkdocs-exporter.js new file mode 100644 index 00000000..5457fce6 --- /dev/null +++ b/docs/assets/javascripts/mkdocs-exporter.js @@ -0,0 +1,31 @@ +/** + * An interface with the MkDocs Exporter plugin. + */ +window.MkDocsExporter = { + /** + * Render the page... + */ + render: async () => { + if (window.MathJax) { + if (typeof window.MathJax.typesetPromise === "function") { + await window.MathJax.typesetPromise(); + } + } + + if (window.mermaid) { + if (typeof window.mermaid.run === "function") { + for (const element of document.querySelectorAll(".mermaid > code")) { + const container = document.createElement("div"); + + container.className = "mermaid"; + + await mermaid.run({ nodes: [element] }); + + element.parentElement.appendChild(container); + container.appendChild(element.children[0]); + element.remove(); + } + } + } + }, +}; diff --git a/docs/assets/stylesheets/extra.css b/docs/assets/stylesheets/extra.css new file mode 100644 index 00000000..4fce8843 --- /dev/null +++ b/docs/assets/stylesheets/extra.css @@ -0,0 +1,35 @@ +/* + * Materialize links that open in a new window/tab with a right-up arrow icon + */ +.md-main a[target="_blank"]::after, +.document a[target="_blank"]::after { + content: "↗"; + display: inline-block; + margin-left: 0.2em; + width: 1em; + height: 1em; +} + +/* + * Add admonition type: important (red exclamation sign) + * See: https://squidfunk.github.io/mkdocs-material/reference/admonitions/#custom-admonitions + */ + +:root { + --md-admonition-icon--important: url('data:image/svg+xml;charset=utf-8,'); +} + +.md-typeset .admonition.important, +.md-typeset details.important { + border-color: rgb(245, 0, 87); +} +.md-typeset .important > .admonition-title, +.md-typeset .important > summary { + background-color: rgba(245, 0, 87, 0.1); +} +.md-typeset .important > .admonition-title::before, +.md-typeset .important > summary::before { + background-color: rgb(245, 0, 87); + -webkit-mask-image: var(--md-admonition-icon--important); + mask-image: var(--md-admonition-icon--important); +} diff --git a/docs/assets/stylesheets/pdf.scss b/docs/assets/stylesheets/pdf.scss new file mode 100644 index 00000000..af46bfb5 --- /dev/null +++ b/docs/assets/stylesheets/pdf.scss @@ -0,0 +1,76 @@ +:root { + --width: 21cm; + --margin: 1.20cm; + --height: 29.7cm; + --offset: calc(var(--margin) * 2); +} + +@page { + size: A4; + margin: 1.20cm; +} + +hr:has(+ div.md-source-file), +.md-source-file { + display: none !important; +} + +summary::after { + display: none; +} + +.front-cover { + margin: var(--margin); + height: calc(var(--height) - var(--offset)); + page-break-after: always; + border: 1px solid #fff; + position: relative; + + img { + position: absolute; + bottom: 0; + left: 0; + width: 100%; + image-rendering: optimizeQuality; + } + + >section { + color: #fff; + padding: 0.635cm; + max-width: 10.25cm; + word-wrap: break-word; + margin-top: calc(var(--height) / 2 - var(--offset) - 2cm); + font-size: 13pt; + + >.title { + font-size: 26pt; + font-weight: 500; + line-height: 1.1; + color: #fff; + } + } +} + +h1, +h2, +h3 { + string-set: chapter content(); +} + +body { + print-color-adjust: exact; + text-rendering: geometricPrecision; +} + +.md-main .md-main__inner { + margin: 0; +} + +.md-content .md-content__inner { + margin: 0; + padding: 0; + + &::before { + height: 0; + } +} diff --git a/docs/assets/stylesheets/primary_color.css b/docs/assets/stylesheets/primary_color.css new file mode 100644 index 00000000..f8ddda6f --- /dev/null +++ b/docs/assets/stylesheets/primary_color.css @@ -0,0 +1,5 @@ +:root { + --md-primary-fg-color: #2980b9; + /* --md-primary-fg-color--light: #ecb7b7; */ + /* --md-primary-fg-color--dark: #90030c; */ +} diff --git a/docs/assets/templates/covers/back.html.j2 b/docs/assets/templates/covers/back.html.j2 new file mode 100644 index 00000000..5a1d81bc --- /dev/null +++ b/docs/assets/templates/covers/back.html.j2 @@ -0,0 +1,43 @@ + +
+
+
{{ config.site_name }}
+
+
diff --git a/docs/assets/templates/covers/front.html.j2 b/docs/assets/templates/covers/front.html.j2 new file mode 100644 index 00000000..1298293c --- /dev/null +++ b/docs/assets/templates/covers/front.html.j2 @@ -0,0 +1,94 @@ + +
+ + +
+
{{ config.site_name }}
+
+ version {{ version }} +

+ Download the latest version on: https://docs.diy-trio.org +

+
+
{{ page.title }}
+
+
diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..5698fc45 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,50 @@ +!!! warning "Work-In-Progress" + + **PLEASE NOTE THIS DOCUMENTATION IS STILL BEING WRITTEN BY OUR AWESOME COMMUNITY. UNTIL IT IS FINISHED, PLEASE DO NOT SET UP YOUR TRIO BASED ON THIS DOCUMENTATION ALONE. CONTACT THE COMMUNITY ON DISCORD OR FACEBOOK TO MAKE SURE YOU GET IT RIGHT AND STAY SAFE** + +# What is Trio? + +![Trio Logo](assets/images/trio-logo.png){ width="150", align="right" } + +Trio is an automated insulin delivery system for iOS based on the [OpenAPS algorithm](https://github.com/OpenAPS/oref0) with [adaptations for Trio](https://github.com/nightscout/trio-oref). + +The project started as Ivan Valkou's [FreeAPS X](https://github.com/ivalkou/freeaps) implementation of the OpenAPS algorithm for iPhone and later forked and rebranded as iAPS. +Since then, many developers have contributed substantial work, leading to a range of new features and enhancements. + +Following the release of version 3.0.0, the project's direction significantly changed due to differing views on development, open source, and peer review. This led to the separation from the iAPS repository and the birth of Trio as a distinct entity. This transition marks the project's new phase, symbolizing its evolution and the collaborative development's dynamic nature. + +Trio continues to leverage a variety of frameworks from the DIY looping community and remains at the forefront of DIY diabetes management solutions, constantly evolving with valuable contributions from its community. + +Before starting with Trio, you should evaluate all your closed-loop options, including: + +* Commercial systems such as Medtronic's 780G, Tandem's Control-IQ, or Insulet's Omnipod 5 +* Other open-source applications like [Loop](https://loopkit.github.io/loopdocs/) and [AndroidAPS](https://androidaps.readthedocs.io/) + +!!! warning "Warning" + Trio is a DIY, open-source community project. + It has not been evaluated by any regulatory agency and is for use at your own risk. + + +# Getting Started + +Before starting with Trio, you should understand [carb ratio (CR)](./settings/configuration/carbratios.md#insulin-carbohydrate-ratio), [insulin sensitivity factor (ISF)](./settings/configuration/insulinsensitivities.md#insulin-sensitivity-factor), and [basal rates](./settings/configuration/basalprofile.md#basal-profile). If you have read the documentation and still require help identifying your settings, please seek advice from your healthcare provider. + +To use Trio, you are required to build the application from the source code. This does not require substantial technical know-how but is a time-consuming process. You may need several sessions to complete your first build. + +Upon installation, you will need to configure your settings appropriately. By default Trio acts no differently than your pump, with the exception that it may recommend temporary basals from time to time. The magic happens by turning on ["Closed Loop"](./Configuration/Configure.md#closed-loop), enabling [Super Micro Bolus (SMB)](./settings/configuration/preferences/smbsettings.md#smb-settings) features, and turning on [dynamic features](./settings/configuration/preferences/dynamicsettings.md#dynamic-settings). + +>In general, these are the first three settings you will want to configure as you gain confidence in the app and your settings: +> + +>- Enable Closed Loop for automation +>- Increase Max IOB to "average meal bolus + 3x max daily basal" +>- Enable SMB and UAM for automatic bolusing (ensure your ISF is optimized before enabling this) +>See [Configure](./Configuration/Configure.md#device-configuration) for more information on Trio configuration. + +If you are considering a transition from another closed loop system, please read [this section](./Configuration/transition-qa.md) first. + +# Contribution + +Trio is built by a volunteer community. If you are interested in helping as a programmer, you can contribute to the Trio or OpenAPS code base. Trio is mostly written in SwiftUI, and the OpenAPS algorithm is written in JS. + +You can also provide support in online support groups by helping users adjust their settings and troubleshoot common errors. diff --git a/docs/js/.keep b/docs/js/.keep new file mode 100644 index 00000000..e69de29b diff --git a/docs/operate/build.md b/docs/operate/build.md new file mode 100644 index 00000000..d96b286f --- /dev/null +++ b/docs/operate/build.md @@ -0,0 +1,484 @@ +# Build and Update + +**Jump to...** +Build with [GitHub](#build-trio-with-github) | [Mac-Xcode](#build-trio-with-xcode) | [Script](#build-trio-with-script) +Update with [GitHub](#update-trio-with-github) | [Mac-Xcode](#update-trio-with-xcode) +Special Section on Trio App Group [Special Section on Trio App Group](#special-section-on-trio-app-group) + +## Build Trio with GitHub + +The Trio repository contains instructions for building the Trio app using a browser and GitHub. More detailed instructions are also available in LoopDocs. + +* [GitHub Build Instructions](https://github.com/nightscout/Trio/blob/main/fastlane/testflight.md) +* [LoopDocs: GitHub Build Overview](https://loopkit.github.io/loopdocs/browser/bb-overview/) +* [LoopDocs: GitHub Build Other Apps](https://loopkit.github.io/loopdocs/browser/other-apps/) + +!!! tip + + If using the LoopDocs instructions you need the important information below to build Trio instead of Loop + +**Every app you build will use the same [6 Secrets](https://loopkit.github.io/loopdocs/browser/intro-summary/#make-a-secrets-reference-file).** + +* Fork from: [https://github.com/nightscout/Trio](https://github.com/nightscout/Trio) +* Identifiers for Trio: see [Table of Identifiers](#table-of-identifiers) +* You use the `Trio App Group` for Trio, see [Create the `Trio App Group`](#create-the-trio-app-group) +* Add the `Trio App Group` to these identifiers: + * `Trio` + * `Trio Watch` + * `Trio WatchKit Extension` +* In `App Store Connect`, the `Bundle ID` for Trio will be: `org.nightscout.TEAMID.trio` + +### Create the `Trio App Group` + +If you already have a `Trio App Group` + +* You can skip this step - your existing App Groups are found at this link: [App Group List](https://developer.apple.com/account/resources/identifiers/list/applicationGroup) +* If your `Trio App Group` was created from a Mac with Xcode, you may choose to edit the Description to make the **NAME** match + +If you do not have a `Trio App Group`: + +* Go to [Register an App Group](https://developer.apple.com/account/resources/identifiers/applicationGroup/add/) on the Apple developer site and use the table below to help you create one. + +| NAME | Xcode version (NAME) | IDENTIFIER | +|:--|:--|:--| +| Trio App Group | group org nightscout TEAMID trio trio-app-group| group.org.nightscout.TEAMID.trio.trio-app-group | + +### Table of Identifiers + +* If you built previously using a Mac with Xcode, you may see the Xcode version in your **NAME** column - it starts with XC and then the **IDENTIFIER** is appended where the `.` is replaced with a space, the example for Trio is shown in detail +* If you built during early beta testing, you might not have `Trio` at the beginning of each **IDENTIFIER** and the full **NAME** may be slightly different +* Optional: You can click on a given row, and edit the Description to match the **NAME** from the table below. This might make building easier in the future + +| NAME | Xcode version (NAME) | IDENTIFIER | +|:--|:--|:--| +| Trio | XC org nightscout TEAMID trio | org.nightscout.TEAMID.trio | +| Trio LiveActivity | - | org.nightscout.TEAMID.trio.LiveActivity | +| Trio Watch | XC IDENTIFIER | org.nightscout.TEAMID.trio.watchkitapp | +| Trio WatchKit Extension | XC IDENTIFIER | org.nightscout.TEAMID.trio.watchkitapp.watchkitextension | + +### Add Trio App Group to Identifiers + +Open the [App IDs Identifier page for your Apple Developer Account](https://developer.apple.com/account/resources/identifiers/list). + +Click on the `Trio` Identifier and assign the `Trio App Group` to the Identifier - see graphic below. + +![add Trio App Group to identifiers](img/choose-trio-app-group.png) + +Repeat this for the other 2 identifiers that need to have an App Group assigned: `Trio Watch` and `Trio WatchKit Extension` + +### Configure Trio App + +Follow the directions in [LoopDocs](https://loopkit.github.io/loopdocs/browser/prepare-app/#create-loop-app-in-app-store-connect), but use the Trio `Bundle ID` + +* In `App Store Connect`, the `Bundle ID` for Trio will be: `org.nightscout.TEAMID.trio` + +### Create Certificates + +Follow the directions in [LoopDocs](https://loopkit.github.io/loopdocs/browser/certs/) but run the `Create Certificates` action for the Trio fork. + +### Build Trio + +Follow the directions in [LoopDocs](https://loopkit.github.io/loopdocs/browser/build-yml/) but run the `Build Trio` action for the Trio fork. + +## Optional + +### One-Time Update to Display Branch And Commit in Testflight + +The Trio build can be configured to display the branch name and commit ID as test notes in TestFlight. This is an optional step, which can be especially useful if building the `dev` branch. + +First, you must have already built Trio and have it available on [Apple App Store Connect](https://appstoreconnect.apple.com/apps). + +* Tap on the `TestFlight` tab +* Choose any build to open a new detailed screen for that build +* In the `Test Details` section, type anything you want + +After you have done this one-time step, each successive build will include the branch name and commit automatically. + +You can add additional tests notes for any build if you desire. + +[Top of Page](#build-and-update) + +## Update Trio with GitHub + +First, make sure any Apple License agreements have been accepted: + +* [Apple Developer Page](https://developer.apple.com/account) + +Second, make sure you have a valid Distributor certificate; if not, see [Distribution Certificate](#distribution-certificate): + +* [Apple Certificate Page](https://developer.apple.com/account/resources/certificates/list) + +### One-time Update for Trio App Group + +If you built previously, before the App Group changed from `Loop` to `Trio`, you need to do this step. Then you can [Continue Updating](#continue-updating). + +* [Create the `Trio App Group`](#create-the-trio-app-group) +* Examine the [Table of Identifiers](#table-of-identifiers) - it is optional, but editing the descriptions to match the **Names** in that table will make following directions easier in the future +* Update the [App Group to be the `Trio App Group` for the Identifiers (Trio, Trio Watch and Trio Watchkit Extension)](#add-trio-app-group-to-identifiers) +* Run the **Action: 3. Create Certificates** to make certificates that go with the new `Trio App Group` + +### Continue Updating + +Open your fork at `github.com/YOUR-USERNAME/Trio` with your GitHub username instead of `YOUR-USERNAME` + +* Look to see if your fork is up to date +* If your fork shows that your branch is behind, sync the branch to get the latest updates + +### Distribution Certificate + +When you first build using GitHub, a Distribution Certificate is generated. It typically is valid for one year. You should get an email from Apple when you are within 30 days of that certificate expiring. When it expires, you can no longer build a new app. (Existing apps in TestFlight are not affected, they get the full 90 days.) + +The directions to renew your Distribution Certificate are found in [LoopDocs: Renew Certificate](https://loopkit.github.io/loopdocs/browser/bb-update/#renew-certificate). + +### Build Trio + +Select **Actions: 4. Build Trio** and wait about an hour for your updated app to appear in TestFlight. + +[Top of Page](#build-and-update) + +## Build Trio with Xcode + +If you build Trio on your Mac using Xcode, the recommendation is to use the [**TrioBuildSelectScript**](#build-trio-with-script) to build your code. + +### Build Trio with Script + +The **`TrioBuildSelectScript`** is similar to the script used to build Loop. If you need it, extensive instructions for that script are provided at these links: [LoopDocs: Build Select Script](https://loopkit.github.io/loopdocs/build/step14/#build-select-script) and [Loop and Learn: Build Select Script](https://www.loopandlearn.org/build-select/). + +The **`TrioBuildSelectScript`** offers the choice to: + +1. [`Build Trio`](#build-trio) +2. [`Build Related Apps`](#build-related-apps) +3. [`Run Maintenance Utilities`](#run-maintenance-utilities) +4. `Exit Script` + +To execute the **`TrioBuildSelectScript`**, open a terminal on your Mac and copy and paste the command below into the terminal. Then, read and follow the directions. + +``` +/bin/bash -c "$(curl -fsSL \ + https://raw.githubusercontent.com/loopandlearn/lnl-scripts/main/TrioBuildSelectScript.sh)" +``` + +### Build Trio + +When you select **`Build Trio`**, you will be provided with a choice of branches with information to guide your selection and URL for documentation. This script will then download a fresh copy of your selected branch and guide you through building with Xcode on your Mac. + +* Once the download completes, the script will also + * Create the automatic signing file + * Offer to remove provisioning profiles from your computer to ensure the build will last an entire year + * Provide instructions for how to build the app once Xcode opens + * Open Xcode with your new download. +* At this point, the main menu is displayed again for you to select another option or to exit the script + +The download is placed in your `Downloads` folder in a directory called `BuildTrio`. The downloaded clone is found in a folder with the branch name, date, and time encoded. + +### Build Related Apps + +When you select **`Build Related Apps`**, you will be provided with a choice of apps that users of Trio often use. Once you make your selection, the script will provide similar steps to download and build the selected app. + +The choices are: + +1. `Build Loop Follow` +2. `Build xDrip4iOS` +3. `Return to Menu` + +### Run Maintenance Utilities + +When you select **`Run Maintenance Utilities`**, you will be provided with a choice of utilities helpful for Mac builders. + +The following options are offered: + +1. `Delete Old Downloads` +2. `Clean Derived Data` +3. `Xcode Cleanup (The Big One)` +4. `Clean Profiles` +5. `Return to Menu` + +For more information, refer to [Loop and Learn: Maintenance Utitilites](https://www.loopandlearn.org/build-select/#utilities-disk) documentation. + + +### Build Errors + +If you encounter any build issues, please look at the [LoopDocs Build](https://loopkit.github.io/loopdocs/build/build_errors/) errors page. Only some things on that page are relevant for building Trio, but many potential issues will likely be covered there. You will also get helpful advice about what info to provide if you need to ask for help. When you have identified the error message(s), you can use the search tool in LoopDocs to see if your error is mentioned. + +If you need it, you are most likely to get help in one of these groups: + +* [Discord: Trio channel](https://discord.gg/FnwFEFUwXE) +* [Facebook group: Trio](https://www.facebook.com/groups/1351938092206709) +* Facebook groups like [Loop and Learn](https://www.facebook.com/groups/LOOPandLEARN) and [Looped](https://www.facebook.com/groups/1782449781971680) primarily focus on Loop but offer a wide variety of support surrounding all types of DIY Looping. + +### xDrip4iOS as CGM Source + +!!! important + + LibreTransmitter is provided as part of Trio. xDrip4iOS is **not** required to interact with your compatible Libre sensor using Trio. + +If you want to use xDrip4iOS as a CGM source via “shared app group,” you must also build that app from a source with the same developer ID used for building Trio. Scripts are available for these apps as well. All scripts follow the same download and build pattern and configure automatic signing files for you. + +The download is placed in your `Downloads` folder in a directory called `BuildxDrip4iOS`. The downloaded clone is found in a folder with the branch name, date, and time encoded. + +These can be accessed using the [**TrioBuildSelectScript**](#build-trio-with-script) menu options mentioned above. Or you can run each script individually. + +### xDrip4iOS + +!!! important + + You must build xDrip4iOS version 5.3.1 or newer to have access to the Trio App Group required to work with Trio. + +``` +/bin/bash -c "$(curl -fsSL \ + https://raw.githubusercontent.com/loopandlearn/lnl-scripts/main/BuildxDrip4iOS.sh)" +``` + +### Alternative Branch for Trio + +Sometimes, specific branches are offered for testing. Any desired branch can be cloned using the **`Build Trio`** script. After the final quote of the script command, add a space, hyphen, space, and branch_name. An example is shown below: replace `branch_name` with your desired branch. Note that specific branches like this are not deleted as part of the `Delete Old Downloads` utility discussed in [Maintenance Utilities](#run-maintenance-utilities). + +``` +/bin/bash -c "$(curl -fsSL \ + https://raw.githubusercontent.com/loopandlearn/lnl-scripts/main/BuildTrio.sh)" - branch_name +``` + +[Top of Page](#build-and-update) + +## Update Trio with Xcode + +Because Trio uses submodules, there are actions you need to perform when updating that are easiest using the command line interface (CLI) in a terminal opened in the same folder as the Trio workspace. + +If you prefer, you can use the [Build Script](#build-trio-with-script) to download and build a fresh copy. + +This section tells you how to update the version you already have on your computer. + +Open Xcode. If your Trio workspace is not already open, you can usually find it in the recent projects, as shown in the graphic below. You can also pull down the Xcode menu for `File`, select `Open Recent`, and find your workspace. + +![xcode welcome screen](img/update-xcode-source-control-welcome.png) + +### Open Terminal + +Once you have Xcode open with your previous build of Trio, the first thing to do is open a terminal. Here are two methods - choose one: + +1. Use Xcode, `Behaviors`, `Open Terminal` if you configured [Xcode Behaviors](#xcode-behaviors) +2. Locate the `Trio` folder using [Where is my Download](#where-is-my-download) + +### Customizations + +Always attempt to [Update your Code](#update-your-code) first. Typically, your customizations can be left alone and `git` will merge the new code without requiring any additional action on your part. + +* If you have a customization, you can often proceed with the update with no issues +* If your customization conflicts with a file or submodule that is being updated, you get a clear error message and need to proceed to [Fix Trio Conflicts](#fix-trio-conflicts) + +### Update your Code + +In the terminal, you will copy and paste this pair of commands to update your workspace and all your submodules. + +``` +git fetch +git pull --recurse +``` + +The first command `git fetch` brings down any updates about the state of the Trio workspace repository from GitHub. + +The second command `git pull --recurse` does several things: + +* Brings down any updates about the state of the submodule repositories from GitHub, e.g., `Fetching submodule XXXX` repeated for each submodule +* Merges any changes from GitHub into your local copy of the Trio workspace +* For each submodule, it updates the version to match the one selected in GitHub, see [Submodule Update](#submodule-update) for more details + +There can be errors in several places, for example: + +``` { .txt .no-copy } +error: Your local changes to the following files would be overwritten by merge: + FreeAPS/folder/file.swift +Please commit your changes or stash them before you merge. +Aborting +``` + +The `pull` command halts at this error and does not move on updating the submodules. You must first fix the Trio workspace files using [Fix Trio Conflicts](#fix-trio-conflicts). + +* If there was no error similar to the one shown above, you will see the word `Updating` with the list of files changed. +* If there were no updates, you'll see `Already up to date` + +### Submodule Update + +* If there are no updates to submodules, you won't see any submodule update messages - that is not uncommon +* If there are updates to one or more submodules with no errors, you will see messages indicating the submodules are being checked out similar to the one below + +``` { .txt .no-copy } +Submodule path 'ModuleName': checked out 'f11abde5e2eea2cbf7ac80f3f4bc4bc6e7f6de56' +``` + +If you see the word `error` or `conflict` on the output, similar to the following, head over to [Fix Submodule Conflicts](#fix-submodule-conflicts). + +``` { .txt .no-copy } +error: Your local changes to the following files would be overwritten by checkout: + SubModuleName/folder/file.swift +Please commit your changes or stash them before you switch branches. +Aborting +fatal: Unable to checkout 'f11abde5e2eea2cbf7ac80f3f4bc4bc6e7f6de56' in submodule path 'SubModuleName' +``` + +If you saw no errors, you are ready to build. + +### Fix Trio Conflicts + +If you have customizations in the Trio code (in the workspace) that cause a conflict when you `pull`, it is best to delete those and start fresh. (Expert users know how to handle this, these directions are for novices): + +``` +git reset --hard +git clean -fd +git pull +``` + +You should see the words: `Your branch is up to date with origin/main` (or `dev` or other branch if you are not running `main`.) + +Now you need to continue to update the submodules with this command: + +``` +git submodule update +``` + +If there are no conflicts, you are ready to build the Trio app to your phone. + +If there are conflicts similar to those shown in [Submodule Update](#submodule-update), fix them before building. + +### Fix Submodule Conflicts + +If you have customizations in the submodules that conflict with the update, you see a message `fatal: Unable to checkout` the submodule. It is easiest to discard the customizations and reapply them manually after the update: + +* Read which submodule failed to `checkout` +* Change directory to that module: `cd modulename` +* Discard your changes: `git reset --hard; git clean -fd` +* Return to the Trio folder and try again: `cd ..; git submodule update` + +If another submodule fails to checkout, repeat the steps for that `modulename`. + +If there are no errors, the Trio code is now updated. + +If Xcode is not open, you can open it by typing `xed .` in the Trio folder of your terminal window. + +You can now build the updated Trio app to your phone. + +### First Xcode Build with Trio App Group + +If you previously built using Xcode when the Loop App Group was used, you may need to let Xcode connect with *Apple* to update the new `Trio App Group`. See instructions at [Mac Build after App Group Change](#mac-build-after-app-group-change). + + +[Top of Page](#build-and-update) + +## Xcode Behaviors + +You can add Behaviors to your version of Xcode. These custom Behaviors only need to be added once. + +You will create a shell script and add it to Xcode. + +* `Open Terminal` will open a terminal in the workspace or project folder currently in use by Xcode + +### Prepare the Shell Script + +Open a new terminal: + +Step 1: Create a folder to store your shell scripts by copying and pasting the next line (only do this one time or you will get an error message): + +``` +mkdir ~/scripts +``` + +Step 2: Copy and paste this command into your terminal to prepare the `Open Terminal` shell script: + +``` +touch ~/scripts/open_terminal.sh; open -e ~/scripts/open_terminal.sh +``` + +Copy and paste the following lines into the editor and then save and close the file. + +``` +#!/bin/bash +open -a Terminal "`pwd`" +``` + +Step 3: Make the shell script executable; Copy and paste this command into your terminal: + +``` +chmod +x ~/scripts/*.sh +``` + +### Add Behaviors to Xcode + +Under the Xcode menu item, select `Behaviors`, `Edit Behaviors` + +Follow these steps (refer to the graphic below): + +1. At the bottom of the window, click the `+` sign +2. Under the `Custom` section, you should see the `New Behavior` row, enter `Open Terminal` +3. On the right side at the bottom, click on `Run`, then `Choose Script` + +![xcode behaviors - ready to select open terminal script](img/xcode-add-behavior.png) + +* Navigate to your username (mine is `marion`) and find the `scripts` directory +* Highlight the file `open-terminal.sh` and then select `Save` + +![xcode behaviors - choose the open terminal script](img/choose-open-terminal-script.png) + +The Behavior `Open Terminal` is now ready for you to use, as shown in this graphic. + +![xcode behaviors - open terminal](img/xcode-behaviors.png) + +Return to [Open Terminal](#open-terminal). + +## Where is my Download + +If you have Xcode open, you can right-click on any file and select `Show in Finder`. Then at the bottom of the Finder window, right-click on the Trio folder and select `New Terminal at Folder`. + +If you do not have Xcode open, you can use *Finder* to locate the directory where the `BuildTrio` script saved the code. The directory is named after the branch with the date and time for the download: + +* Released (main) branch: Downloads/BuildTrio/Trio_main-[date-time]/Trio + * Example: `~/Downloads/BuildTrio/Trio_main-220122-1352/Trio` +* Development (dev) branch: Downloads/BuildTrio/Trio_dev-[date-time]/Trio + * Example: `~/Downloads/BuildTrio/Trio_dev-220108-1827/Trio` + +Use *Finder* to open a Terminal window at the `Trio` directory by right-clicking on it and selecting `New Terminal at Folder`.  + +To open Xcode, type `xed .` in the Terminal. + +Return to [Open Terminal](#open-terminal). + +## Special Section on Trio App Group + +* If you have never built Trio before - just follow the instructions on this page: return [Top of Page](#build-and-update) +* If you have already built Trio and have added the `Trio App Group`: return [Top of Page](#build-and-update) +* If you have already built Trio, but you did not add the `Trio App Group` (or are not sure), please read this section for hints and help + +Instructions for [GitHub](#browser-build-after-app-group-change) | [Mac-Xcode](#mac-build-after-app-group-change) + +### Browser Build after App Group Change + +In order to build the Trio app with Browser Build, you must assign the `Trio App Group` to 3 of the 4 identifiers for Trio. + +#### Step 1: Create Trio App Group + +* Check if you have a `Trio App Group`: [List your App Groups](https://developer.apple.com/account/resources/identifiers/list/applicationGroup) +* Create a `Trio App Group` if you don't have one: [Register an App Group](https://developer.apple.com/account/resources/identifiers/applicationGroup/add/) + +| NAME | Xcode version (NAME) | IDENTIFIER | +|:--|:--|:--| +| Trio App Group | group org nightscout TEAMID trio trio-app-group| group.org.nightscout.TEAMID.trio.trio-app-group | + +#### Step 2: Assign Trio App Group to Trio Identifiers + +Return to [Add Trio App Group to Identifiers](#add-trio-app-group-to-identifiers) + +### Mac Build after App Group Change + +The first time you build Trio after the change from `Loop App Group` to `Trio App Group`, you are likely to see the build error in the first graphic. + +![build error after switching to trio app group](img/trio-error-after-app-group-change.png) + +You must be connected to the internet and must allow Xcode to connect to Apple to update your app group. Tap in the four locations (in order): (1) Folder Icon, (2) FreeAPS folder, (3) Signing & Capabilities and (4) Target: FreeAPS, as indicated in the graphic below. The app group may momentarily appear in red font, then will update to black font for the trio-app-group. Continue until you have examined three targets `FreeAPS`, `FreeAPSWatch` and `FreeAPSWatch Watchkit Extension`. When those targets show the correct App Group, press the build symbol again. + +![add Trio App Group to identifiers](img/trio-allow-xcode-to-update.png) + +### Consequences of `Trio App Group` + +If you use xDrip4iOS as your CGM for Trio, it needs to support the same `App Group` as Trio. + +xDrip4iOS requires version 5.3.1 or newer to support the `Trio App Group` + diff --git a/docs/operate/customize.md b/docs/operate/customize.md new file mode 100644 index 00000000..910349d2 --- /dev/null +++ b/docs/operate/customize.md @@ -0,0 +1,116 @@ +# Add Customizations to Trio + +Here are a few ways to customize the Trio code to suit your needs better. Please be very careful when editing any code. + +## Bypass Authentication for Bolusing + +!!! warning + + - If you disable this, you remove an important safety feature. + - In addition to authenticating every manual bolus, this helps to protect against sleep bolusing and pocket bolusing. + +Depending on your iPhone settings and model, you may have Face ID or Touch ID enabled. Those security features will also be used to authenticate bolus delivery in Trio. You can disable authentication (i.e., not require Face ID, Touch ID, or passcode for bolusing) through the following code customization. + +**Steps:** + +Edit line 28 of the file `FreeAPS/Sources/Services/UnlockManager/UnlockManager.swift` + +Code before modification: +```swift +if context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) { +``` + +Code after modification: +```swift +if false, context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) { +``` + +## Omnipod: Add Extra Insulin on Insertion + +The default value is 0.0 U of extra insulin. If you use this customization, start with a small number and work your way up. If you come from manual podding and routinely gave yourself an extra bolus with your PDM at pod change time, you may not need nearly as much with Trio - be conservative. + +!!! tip "It is important to know" + + Trio does not include the amount of insulin in the prime or insertion steps in your IOB. + + - The pod reports every pulse that it delivers to Trio. If you look in the Pod Settings insulin delivered row, that is the total delivered by the pod minus the (prime plus insertion) amounts. + - The only way to know that you successfully made this change is to count the clicks. Normal insertion is 0.5 units or 10 clicks (0.05 units per click). If you add 0.25 units to the "extra" value, you will get 0.25 / 0.05 = 5 extra clicks. In other words, there are 15 total clicks after you slide to insert. + +[Eros Pods](#eros) and [Dash Pods](#dash) have different locations for this change. Some change both files just in case, but that is unnecessary if you're only using one type of pod. + +### Dash +Edit line 82 of the file `OmniBLE/OmniBLE/OmnipodCommon/Pod.swift` + +Code before modification: +```swift +public static let cannulaInsertionUnitsExtra = 0.0 +``` + +Code after modification adding 0.25U of insulin: +```swift +public static let cannulaInsertionUnitsExtra = 0.25 +``` +### Eros +Edit line 84 of the file `OmniKit/OmniKit/OmnipodCommon/Pod.swift` + +Code before modification: +```swift +public static let cannulaInsertionUnitsExtra = 0.0 +``` + +Code after modification adding 0.25U of insulin: +```swift +public static let cannulaInsertionUnitsExtra = 0.25 +``` + +## Add Custom Icon + +There are several different app icon options built into Trio, but you can still add your own if you'd like. You'll need to convert the image you want into a PNG file with a resolution of 1024x1024. For this guide, we'll use this icon and call it ivan. + +![Logo Alicorn](img/logo-alicorn.png){width=250} +{align=center} + +1. Go into the folder `FreeAPS/Resources/Assets.xcassets/` and create a new folder called `ivan.appiconset` + +2. Add two copies of the 1024x1024 PNG file into this folder, called `ivan.png` and `ivan 1.png` + +3. Add a file called `Contents.json` with the following contents: + ```json + { + "images" : [ + { + "filename" : "ivan.png", + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "filename" : "ivan 1.png", + "idiom" : "universal", + "platform" : "watchos", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } + } + ``` + +4. Insert a new line after line 14 in the file `FreeAPS/Sources/Models/Icons.swift` containing the following text: `case ivan = "ivan"` + - Code **before** modification: + ```swift + ... + case loop = "trioLoop" + var id: String { rawValue } + } + ``` + - Code **after** modification: + ```swift + ... + case loop = "trioLoop" + case ivan = "ivan" + var id: String { rawValue } + } + ``` diff --git a/docs/operate/img/Update Open-iAPS with Source Control-check version.png b/docs/operate/img/Update Open-iAPS with Source Control-check version.png new file mode 100644 index 00000000..47959ac4 Binary files /dev/null and b/docs/operate/img/Update Open-iAPS with Source Control-check version.png differ diff --git a/docs/operate/img/choose-open-terminal-script.png b/docs/operate/img/choose-open-terminal-script.png new file mode 100644 index 00000000..777ea0ca Binary files /dev/null and b/docs/operate/img/choose-open-terminal-script.png differ diff --git a/docs/operate/img/choose-trio-app-group.png b/docs/operate/img/choose-trio-app-group.png new file mode 100644 index 00000000..7d0cfb5a Binary files /dev/null and b/docs/operate/img/choose-trio-app-group.png differ diff --git a/docs/operate/img/diabeetus.png b/docs/operate/img/diabeetus.png new file mode 100644 index 00000000..275ce55f Binary files /dev/null and b/docs/operate/img/diabeetus.png differ diff --git a/docs/operate/img/iAPSIOB.png b/docs/operate/img/iAPSIOB.png new file mode 100644 index 00000000..b323a6d4 Binary files /dev/null and b/docs/operate/img/iAPSIOB.png differ diff --git a/docs/operate/img/info.jpg b/docs/operate/img/info.jpg new file mode 100644 index 00000000..6e576260 Binary files /dev/null and b/docs/operate/img/info.jpg differ diff --git a/docs/operate/img/logo-alicorn.png b/docs/operate/img/logo-alicorn.png new file mode 100644 index 00000000..3991628c Binary files /dev/null and b/docs/operate/img/logo-alicorn.png differ diff --git a/docs/operate/img/main.jpg b/docs/operate/img/main.jpg new file mode 100644 index 00000000..0df15743 Binary files /dev/null and b/docs/operate/img/main.jpg differ diff --git a/docs/operate/img/mealbolus.png b/docs/operate/img/mealbolus.png new file mode 100644 index 00000000..e302cc30 Binary files /dev/null and b/docs/operate/img/mealbolus.png differ diff --git a/docs/operate/img/negativeIOBafter.jpg b/docs/operate/img/negativeIOBafter.jpg new file mode 100644 index 00000000..e6446953 Binary files /dev/null and b/docs/operate/img/negativeIOBafter.jpg differ diff --git a/docs/operate/img/negativeIOBbefore.jpg b/docs/operate/img/negativeIOBbefore.jpg new file mode 100644 index 00000000..fed5580a Binary files /dev/null and b/docs/operate/img/negativeIOBbefore.jpg differ diff --git a/docs/operate/img/temptarget.png b/docs/operate/img/temptarget.png new file mode 100644 index 00000000..30d8f7f3 Binary files /dev/null and b/docs/operate/img/temptarget.png differ diff --git a/docs/operate/img/trio-allow-xcode-to-update.png b/docs/operate/img/trio-allow-xcode-to-update.png new file mode 100644 index 00000000..a0e7a3b3 Binary files /dev/null and b/docs/operate/img/trio-allow-xcode-to-update.png differ diff --git a/docs/operate/img/trio-error-after-app-group-change.png b/docs/operate/img/trio-error-after-app-group-change.png new file mode 100644 index 00000000..03d05c02 Binary files /dev/null and b/docs/operate/img/trio-error-after-app-group-change.png differ diff --git a/docs/operate/img/trio-ui-action_row.png b/docs/operate/img/trio-ui-action_row.png new file mode 100644 index 00000000..2d36313a Binary files /dev/null and b/docs/operate/img/trio-ui-action_row.png differ diff --git a/docs/operate/img/trio-ui-graphs_statistics.png b/docs/operate/img/trio-ui-graphs_statistics.png new file mode 100644 index 00000000..cb2f7334 Binary files /dev/null and b/docs/operate/img/trio-ui-graphs_statistics.png differ diff --git a/docs/operate/img/trio-ui-main_screen.png b/docs/operate/img/trio-ui-main_screen.png new file mode 100644 index 00000000..34dc9bc2 Binary files /dev/null and b/docs/operate/img/trio-ui-main_screen.png differ diff --git a/docs/operate/img/trio-ui-prediction_row_legend.png b/docs/operate/img/trio-ui-prediction_row_legend.png new file mode 100644 index 00000000..0d37d9f2 Binary files /dev/null and b/docs/operate/img/trio-ui-prediction_row_legend.png differ diff --git a/docs/operate/img/trio-ui-status_row.png b/docs/operate/img/trio-ui-status_row.png new file mode 100644 index 00000000..29321760 Binary files /dev/null and b/docs/operate/img/trio-ui-status_row.png differ diff --git a/docs/operate/img/update-xcode-source-control-welcome.png b/docs/operate/img/update-xcode-source-control-welcome.png new file mode 100644 index 00000000..81e7048f Binary files /dev/null and b/docs/operate/img/update-xcode-source-control-welcome.png differ diff --git a/docs/operate/img/xcode-add-behavior.png b/docs/operate/img/xcode-add-behavior.png new file mode 100644 index 00000000..006fad7a Binary files /dev/null and b/docs/operate/img/xcode-add-behavior.png differ diff --git a/docs/operate/img/xcode-behaviors.png b/docs/operate/img/xcode-behaviors.png new file mode 100644 index 00000000..54dd2a97 Binary files /dev/null and b/docs/operate/img/xcode-behaviors.png differ diff --git a/docs/operate/img/xcode-build-version.png b/docs/operate/img/xcode-build-version.png new file mode 100644 index 00000000..55fa0df9 Binary files /dev/null and b/docs/operate/img/xcode-build-version.png differ diff --git a/docs/operate/img/xcode-fetch-changes.png b/docs/operate/img/xcode-fetch-changes.png new file mode 100644 index 00000000..3c16fa62 Binary files /dev/null and b/docs/operate/img/xcode-fetch-changes.png differ diff --git a/docs/operate/img/xcode-pull-master.png b/docs/operate/img/xcode-pull-master.png new file mode 100644 index 00000000..d79c8a7c Binary files /dev/null and b/docs/operate/img/xcode-pull-master.png differ diff --git a/docs/operate/img/xcode-source-control-pull.png b/docs/operate/img/xcode-source-control-pull.png new file mode 100644 index 00000000..7b0ecf04 Binary files /dev/null and b/docs/operate/img/xcode-source-control-pull.png differ diff --git a/docs/operate/img/xcode-welcome.png b/docs/operate/img/xcode-welcome.png new file mode 100644 index 00000000..7d094082 Binary files /dev/null and b/docs/operate/img/xcode-welcome.png differ diff --git a/docs/operate/interface.md b/docs/operate/interface.md new file mode 100644 index 00000000..ccc22c77 --- /dev/null +++ b/docs/operate/interface.md @@ -0,0 +1,74 @@ +# User Interface + +## Main Screen + + The main screen of Trio can be divided into three sections: + +[Status](#status) | [Graphs & Statistics](#graphs-and-statistics) | [Actions](#actions) + +![Trio Main Screen](./img/trio-ui-main_screen.png){width="400"} +{align="center"} + +### Status + +The Status section shows your current insulin on board (IOB), carbs on board (COB), blood glucose, pump status, and looping status. +The looping indicator will be grey if no data is present. It will be green when it has been less than 5 minutes since a successful loop cycle. It will turn yellow if no loop cycle has been completed for over 5 minutes. If more than 10 minutes go by without a successful loop cycle, the loop circle will turn red. The section to the left of the loop circle shows you the approximate units of insulin left in your pump. If you're using Omnipod, 50+ U means more than 50 units of insulin are left. Below the insulin left, you will see your pump battery status if you're using a Medtronic pump and the days/hours left if you're using an Omnipod. + +![Trio Status Row](./img/trio-ui-status_row.png){width="400"} +{align="center"} + +Tapping the top of the screen will bring up a History screen with information on changes implemented by the most recent loop cycle. Tapping the pump status will bring you to pump settings. + + +### Graphs and Statistics + +The middle of the screen graphs your current blood sugar data and inputted carbs overlaid with Trio's insulin delivery and blood sugar predictions. + +![Trio Graphs and Statistics](img/trio-ui-graphs_statistics.png){width="400"} +{align="center"} + +Below the graph is the prediction line legend so you can determine the meaning of your prediction lines. + +![Trio Prediction Line Legend](img/trio-ui-prediction_row_legend.png){width="400"} +{align="center"} + +The zero temp (ZT) line predicts where your blood sugar would be if insulin delivery and carb absorption ceased. The IOB line predicts where blood sugar would be if insulin delivery was ceased and carb absorption was minimal. The unannounced meal (UAM) line predicts how long blood glucose will continue to rise, to dose insulin accordingly. The COB line predicts the effects of entered carbs on future blood glucose. For more information on prediction lines, see the [OpenAPS documentation.](https://openaps.readthedocs.io/en/latest/docs/While%20You%20Wait%20For%20Gear/Understand-determine-basal.html) + +If enabled, statistics detailing your time in range, coefficient of variance (CV), and average glucose are displayed underneath these graphs. Tapping in this area allows you to change the time interval used to calculate these statistics. + +### Actions + +At the bottom of the screen, you have five action icons: + +![Trio Action Row](img/trio-ui-action_row.png){width="400"} +{align="center"} + +
+ Meal Bolus + +The Meal Bolus option allows you to enter Carbs and bolus accordingly. If you have "Fat And Protein Conversion" enabled, you will also be provided the option to enter fat and protein content in grams. +
+ +
+ Temp Target + +The Temp Target icon allows you to set temporary blood glucose targets. The most common targets are a high target for exercise and a low target for meal preparation. +
+ +
+ Bolus + +The Bolus icon allows you to give manual correction boluses. Manually correcting is not recommended if you are using Trio's SMB and UAM features. +
+ +
+ Statistics + +The Statistics Icon shows your statistical data in the app. +
+ +
+ Settings + +The Settings icon allows you to access your Trio settings. The settings screen allows you to adjust your configuration. Please see [Configure](../settings/devices/pump.md) for more information on each configuration option. +
diff --git a/docs/operate/temptarget.md b/docs/operate/temptarget.md new file mode 100644 index 00000000..5091e403 --- /dev/null +++ b/docs/operate/temptarget.md @@ -0,0 +1,24 @@ +# Temporary Targets + +## Exercise + +!!! tip "Tips" + + - Set a high temp target 1-2 hours before your exercise + - Enable exercise-related settings in preferences to reduce insulin delivered while exercising + - Pack a snack when you plan to exercise + +Exercise can have immediate and long-term effects on glycemic control. Generally, individuals will find their blood sugar drops during intense exercise and continue to drop for 3-4 hours after. They may also experience increased insulin sensitivity for 24 hours after exercise. + +Consuming enough slow-acting carbohydrates before and after your exercise session is important. Pack a snack in case you need a source of simple carbohydrates during your routine. + +Trio has some quality-of-life features that make exercise easier while looping. When you plan to exercise, increase your target approximately 2 hours before your exercise. If you have SMB enabled, be sure that ["Allow SMB With High Temptarget"](../settings/configuration/preferences/smbsettings.md#allow-smb-with-high-temptarget) is disabled. Finally, you can enable ["High Temptarget Raises Sensitivity"](../settings/configuration/preferences/targetsettings.md#high-temptarget-raises-sensitivity) to prevent Trio from providing too much insulin during exercise. + +## Pre-Meal + +!!! tip "Tips" + + - Set a low temp target 1-2 hours before meals to help with spikes + - Enable "Low Temptarget Lowers Sensitivity" to allow for greater insulin delivery + +If you plan to eat soon, you may want Trio to provide you extra room to fill up on carbs. One way you can do this is by setting a temp target approximately 1 mmol/L or 18 mg/dL below your target, 1-2 hours prior to meals. You can also enable ["Low Temptarget Lowers Sensitivity"](../settings/configuration/preferences/targetsettings.md#low-temptarget-lowers-sensitivity) to give yourself more insulin for the upcoming meal and to bring your blood sugar down faster to the pre-meal range. diff --git a/docs/operate/troubleshoot.md b/docs/operate/troubleshoot.md new file mode 100644 index 00000000..9de8e8d9 --- /dev/null +++ b/docs/operate/troubleshoot.md @@ -0,0 +1,79 @@ +# Common Issues +[Adapted from looptips](https://loopkit.github.io/looptips/how-to/think-like-loop/) + +## Site Change and Site Failures + +!!! tip "Tips" + + - Pump site changes can temporarily impact control. + - Pump site failures can negatively impact control for hours. Turn off closed loop when failure is discovered, and only turn back on when a new pump is installed. + +### Site Change + +Pump site changes can negatively impact your immediate glycemic control. Different delivery sites' ability to absorb insulin varies, impacting your perceived insulin sensitivity. Trio should be able to accommodate this change by resetting its Autosens measurements [(assuming "Rewind Resets Autosens" is on)](../settings/configuration/preferences/othersettings.md) and adapting as needed. + +**For Omnipod** +If you think you need more insulin primed in the new pod, consider customizing that line of code with [these instructions](./customize.md#omnipod-add-extra-insulin-on-insertion). + +### Site Failure + +Pump failures can result from kinks or improper insertion of the cannula. As a result of a pump failure, Trio may assume that more insulin is on board the patient than what was delivered, leading to sustained highs even after the pump is replaced. + +When you find out your pump has failed, immediately open loop to prevent Trio from trying to deliver more insulin. Upon your next pump installation, you can then close loop and be patient. Trio will wait for the calculated insulin on board to drop before delivering insulin. + +## Low Treatment + +!!! tip "Tips" + + - Enter carbs for treatment into Trio, but do not bolus for it + - Consider reducing your profile ISF or Adjustment Factor if Dynamic ISF is enabled + +Low blood sugar events can happen from time to time, but you will typically not require as many carbs to treat your lows as opposed to MDI or using a pump. When you treat a low, you should enter the carbs consumed into the Trio system so its autotune functionality can make better choices on your ICR, ISF, and basal rates. + +If you experience a roller coaster pattern of highs and lows after treatment, your [insulin sensitivity factor (ISF)](../settings/configuration/insulinsensitivities.md) is most likely to blame. Consider making your insulin sensitivity less aggressive by 10% or reducing your adjustment factor by 0.1 increments. + +## Rebound Lows + +!!! tip "Tips" + + - Treating lows with fast carbs can give a fast BG rise + - Under certain circumstances, Trio might react to the fast BG rise by giving insulin, leading to another low + +To avoid a second low, you can instruct Trio not to give any SMBs for a while after a low, giving your BG time to stabilize. Set up a [Temporary Target](temptarget.md) preset that is a bit higher than your usual target (e.g., 7,5 mmol/L | 136 mg/dl). Ensure that [Allow SMB With High Temptarget](../settings/configuration/preferences/smbsettings.md) is disabled. Make the temporary target last for a while (e.g., 30-45 min). + +!!! warning + + **Setting a temporary target is not the same as disconnecting the pump.** Trio will still be able to give you insulin during the temporary target, but only by adjusting basal rates, resulting in a less aggressive treatment. + +## Highs after meals + +!!! tip + + **It is _normal_ for BG to rise after a meal. This happens to everyone, with or without diabetes. The key is to avoid very high BG levels and bring them back into range as soon as possible.** + +### Fast Rise + +**Scenario:** _Your BG rises fast when eating and ends up too high._ + +If your BG rises fast and ends up too high, it is usually because the carbs were absorbed before the insulin peaked. If we rule out site issues, illness, etc, the logical approach is to ensure you get enough insulin ahead of the carbs. You can achieve this by increasing your pre-bolus timing for the meal. This gives the insulin time to absorb before the carbs kick in. You can find more information on the [mealtime strategy](../Configuration/transition-qa.md#mealtime-strategy) page. + +### Persistent High After Meals + +**Scenario:** _Your BG gets high after a meal and stays high for a long time. Trio gives you some SMBs, but not enough to bring you back down._ + +Trio calculates the amount of insulin needed to bring blood glucose back into range. Additional insulin is needed when blood glucose remains high after a meal, but Trio needs the correct settings to make those adjustments. + +- The first adjustment should be to reduce your CR. Reducing your carb ratio will result in **more** insulin for the carbs entered. +- If you notice that your CR needs fluctuate based on your blood sugar level at the time, evaluate activating the [Dynamic CR](../settings/configuration/preferences/dynamicsettings.md#dynamic-cr) setting. + +### Fast Rise, Then Low + +**Scenario:** _Your BG rises and ends up too high after a meal, then falls and ends up too low._ + +In this scenario, you are not getting enough insulin upfront to deal with the carb absorption, but the total amount of insulin you're getting is too much - causing a low. If this is a repeating scenario, you should look into all of the following: + +1. If all the delivered insulin is from one bolus, you should consider adjusting your CR setting so that the bolus calculator gives you less insulin. You could also consider pre-bolusing, giving the insulin some time to absorb before you start eating. +2. If the delivered insulin is part bolus and part SMBs, you should consider adjusting your ISF setting so that the SMBs give you less insulin. It would help if you also considered pre-bolusing, giving the insulin more time to absorb before you start eating. +3. In both (1) and (2), if you use dynamic ISF and CR features, you should consider lowering the Adjustment Factor and adjusting the Autosens max/min settings. + +Please read through the chapters on [Autosens](../settings/configuration/concepts/autosens-dynamic.md) and [Dynamic settings](../settings/configuration/preferences/dynamicsettings.md). diff --git a/docs/resources/citations.md b/docs/resources/citations.md new file mode 100644 index 00000000..c6fde056 --- /dev/null +++ b/docs/resources/citations.md @@ -0,0 +1,41 @@ +# Resources + +## OpenAPS Documentation +The first place to start if you want to learn more about the underlying algorithm, is the extensive [OpenAPS documentation](https://openaps.readthedocs.io/). OpenAPS is the underlying algorithm that Trio implements to control blood sugar, with small modifications mostly pertaining to the Dynamic settings. + +## AndroidAPS Documentation +AndroidAPS implements the same OpenAPS algorithm with dynamic enhancements and maintains an [extensive documentation](https://androidaps.readthedocs.io/) for new users. Recommend if you have additional questions, you skim through its documentation for your answer. + +## Loop Documentation +Trio is not a fork of Loop. While their underlying algorithms are different, they share some parts of their code base. It is recommended that you take a quick glance in the [Loop Docs](https://loopkit.github.io/loopdocs/) for your issue, especially if it relates to pump usage and build errors. Many of these documents have been adapted from Loopdocs. + +## Community Support (Free Support) +There are many opportunities to find help with using Trio. + +- [**Discord**](https://discord.gg/FnwFEFUwXE) + In Discord, you can... + - search in the relevant channel to see if your issue has been answered + - post a question in a relevant channel + - expect answers from both Trio developers and fellow DIY community members +- [**Facebook**](https://www.facebook.com/groups/diytrio) + In Facebook, you can... + - use the search function in Facebook to locate posts where your issue may have already been addressed + - post a question to the Facebook group + - expect answers from fellow DIY community members + +## Healthcare Providers (Paid Support) +Many Healthcare Providers offer support in using DIY services. The following providers are not free and come with costs based on your needs and your insurance coverage. + +- [**Loop and Learn Provider List**](https://www.loopnlearn.org/hcp-recommendations/) + Loop and Learn has created a list of DIY-Supportive Healthcare providers. If you have a supportive provider that is not on this list, please submit their information [here](https://www.loopnlearn.org/hcp-recommendations/#recommend-an-hcp). +- [**Integrated Diabetes Services**](https://integrateddiabetes.com/diy-services-support/) + If you would prefer assistance with setting up your system from a team of diabetes educators, Gary Scheiner and his team are available. +- **BC Diabetes** (Canadian Residents Only) + If you are a BC Diabetes Looper, please request a link to their Slack group from your case manager. + +## Citations +- [Loop Documentation](https://loopkit.github.io/loopdocs/) +- [Loop Tips](https://loopkit.github.io/looptips/) +- [OpenAPS Documentation](https://openaps.readthedocs.io/) +- [AndroidAPS Documentation](https://androidaps.readthedocs.io/) +- Support groups on [Discord](https://discord.gg/FnwFEFUwXE) and [Facebook](https://www.facebook.com/groups/1351938092206709) diff --git a/docs/resources/img/Calculator_1_Add_Carbs.png b/docs/resources/img/Calculator_1_Add_Carbs.png new file mode 100644 index 00000000..ffaae5fb Binary files /dev/null and b/docs/resources/img/Calculator_1_Add_Carbs.png differ diff --git a/docs/resources/img/Calculator_2_Preview.png b/docs/resources/img/Calculator_2_Preview.png new file mode 100644 index 00000000..78811f1e Binary files /dev/null and b/docs/resources/img/Calculator_2_Preview.png differ diff --git a/docs/resources/img/Calculator_3_Fatty_Meal.png b/docs/resources/img/Calculator_3_Fatty_Meal.png new file mode 100644 index 00000000..b80c9ab7 Binary files /dev/null and b/docs/resources/img/Calculator_3_Fatty_Meal.png differ diff --git a/docs/resources/img/Calculator_4_Calculation.png b/docs/resources/img/Calculator_4_Calculation.png new file mode 100644 index 00000000..6e39044e Binary files /dev/null and b/docs/resources/img/Calculator_4_Calculation.png differ diff --git a/docs/resources/img/Calculator_5_Tap_Amount.png b/docs/resources/img/Calculator_5_Tap_Amount.png new file mode 100644 index 00000000..5f42464a Binary files /dev/null and b/docs/resources/img/Calculator_5_Tap_Amount.png differ diff --git a/docs/resources/img/Calculator_6_Amount_Selected.png b/docs/resources/img/Calculator_6_Amount_Selected.png new file mode 100644 index 00000000..8e55545b Binary files /dev/null and b/docs/resources/img/Calculator_6_Amount_Selected.png differ diff --git a/docs/resources/img/Calculator_7_Amount_Edited.png b/docs/resources/img/Calculator_7_Amount_Edited.png new file mode 100644 index 00000000..1afbb379 Binary files /dev/null and b/docs/resources/img/Calculator_7_Amount_Edited.png differ diff --git a/docs/resources/img/Calculator_Settings_1.png b/docs/resources/img/Calculator_Settings_1.png new file mode 100644 index 00000000..e2821c38 Binary files /dev/null and b/docs/resources/img/Calculator_Settings_1.png differ diff --git a/docs/resources/img/Calculator_Settings_2.png b/docs/resources/img/Calculator_Settings_2.png new file mode 100644 index 00000000..b307c480 Binary files /dev/null and b/docs/resources/img/Calculator_Settings_2.png differ diff --git a/docs/resources/img/google-xslate.svg b/docs/resources/img/google-xslate.svg new file mode 100644 index 00000000..ee92ba3e --- /dev/null +++ b/docs/resources/img/google-xslate.svg @@ -0,0 +1,1270 @@ + +image/svg+xmlWIDE: BrowserNARROW: Mobile diff --git a/docs/resources/img/iAPS_Dark.PNG b/docs/resources/img/iAPS_Dark.PNG new file mode 100644 index 00000000..8ab0030c Binary files /dev/null and b/docs/resources/img/iAPS_Dark.PNG differ diff --git a/docs/resources/img/iAPS_Light.PNG b/docs/resources/img/iAPS_Light.PNG new file mode 100644 index 00000000..f778fd66 Binary files /dev/null and b/docs/resources/img/iAPS_Light.PNG differ diff --git a/docs/resources/translate.md b/docs/resources/translate.md new file mode 100644 index 00000000..cb7d4705 --- /dev/null +++ b/docs/resources/translate.md @@ -0,0 +1,101 @@ +# Translation + +## Language List + +Click on a language on the links below to turn on Google's automatic translation. + + +[عربي](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=ar) + +[Български](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=bg) + +[Čeština](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=cs) + +[Deutsch](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=de) + +[Dansk](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=da) + +[Ελληνικά](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=el) + +[Español](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=es) + +[日本](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=ja) + +[Suomi](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=fi) + +[Français](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=fr) + +[עברית](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=iw) + +[Hrvatski](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=hr) + +[हिंदी](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=hi) + +[Italiano](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=it) + +[한국어](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=ko) + +[Norsk](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=no) + +[Nederlands](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=nl) + +[Polski](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=pl) + +[Português](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=pt) + +[Română](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=ro) + +[Русский](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=ru) + +[Slovenčina](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=sk) + +[Svenska](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=sv) + +[Turkish](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=tr) + +中文([简体](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=zh-CN)) + +中文([繁體](https://docs-diy--trio-org.translate.goog/?_x_tr_sl=auto&_x_tr_tl=zh-TW)) + + +## Change Language + +To modify the language choice for the whole site, copy the line below, paste it into the URL, and then choose the desired language from the list above. + +``` +https://docs.diy-trio.org/resources/translate.html +``` + +**OR** + +Use the Google Translation three-dot menu (`⠇`) and select `Go to original URL ↗` while on the Translation page. + +## More Information + +- Every website page gets automatically translated to the selected language as do links to other websites + +- The Google Translate Tool will appear at the top of each page + - Trio Docs how-to: [Google Translate Tool Instructions](#google-translate-tool-instructions) + - Google how-to: [Google Translate Help Link](https://support.google.com/translate/answer/2534559?hl=en&co=GENIE.Platform%3DDesktop) + +!!! danger "Automatic Translation" + + These links connect this site to the Google Translation service. + + - No human has reviewed the translated information for accuracy + - Please use the translation with care + - Not available in all regions + - Some links may not work as expected + - Any "code" not protected by blocks may not appear correctly - be sure to click on Original to make sure you are viewing code properly + +## Google Translate Tool Instructions + +Once Google Translate has been turned on, clicking the language link above shows a `Google Translate: Can't translate this page` error. + +- To modify the language for a single page, use the Google Translate tool +- To modify the language for the entire site, see [Change Language](#change-language) + +The graphic below shows the *Google Translate* Tool when maximized (default) for a browser and mobile display. The tool can be minimized by tapping on the up/down carets at the right of the tool. This is very useful if the tool obstructs part of the original screen. Additional options can be selected with the three-dot menu as shown in the graphic. + +![TODO](img/google-xslate.svg){ "width": "600px" } +{ align: center} diff --git a/docs/settings/configuration/autotune.md b/docs/settings/configuration/autotune.md new file mode 100644 index 00000000..8d9225c6 --- /dev/null +++ b/docs/settings/configuration/autotune.md @@ -0,0 +1,43 @@ +# Autotune + +!!! tip "Highlights" + + - Do not enable autotune unless you have full confidence in your current profile settings + - Autotune adjustments are limited by autosens max/min + +## What is Autotune? +Autotune makes iterative adjustments to your profile settings (basal rates, ISF, and carb ratio) based on your last 24 hours of data. The adjustments made by Autotune are small, with a maximum of 10% change to the current CR and ISF or 20% change to the current basal rates per run, but they add up over days. Autotune is run nightly by default unless it is manually run by the user. + +Autotune is designed to work over weeks to slowly improve the accuracy of your initially set ISF/CR/basal rates. The output of autotune formulas produces a ratio similar to that of autosens. The autosens max and min preferences also limit this ratio. + +## How does it work? +Autotune is not Machine Learning. It is not AI. It is a statistical regression attempting to compare what happened over the last 24 hours with what profile settings are and adjusting the profile settings accordingly. + +For basals, it divides the day into hour-long increments. It calculates the total deviations for that hour increment and what change in basal would be required to adjust those deviations to 0. Then, 20% of the change needed is applied to the three hours prior (because of insulin impact time). If increasing basal, it increases each of the 3-hour increments by the same amount. If the basal decreases proportionally, the biggest basal is reduced the most. + +For ISF, it calculates the 50th percentile (median) deviation for the entire day and determines how much ISF would need to change to get that deviation to 0. It applies 10% of that as an adjustment to ISF. + +For CR, it calculates the total deviations over all of the day's mealtimes, compares them to the deviations expected based on existing CR and the known amount of carbs entered, and applies 10% of that adjustment to CR. + +## Important note on Dynamic Settings + +!!! tip + Autotune results can be unreliable if dynamic settings are enabled. + +Because Autotune uses Deviations to calculate basal variation, it has to calculate Deviations. It does this using a profile-based ISF value. + +This means that if you enable Autotune but use dynamic functions within Trio, the algorithm will not use the ISF that was in operation when it ran in the past, and basal adjustments and ISF adjustments are likely to be incorrect. + +It can also only run with a single daily ISF and CR, so it doesn't work for most people. + +## How does it differ from Autosens? +Autosens is designed to rapidly change your profile settings every loop cycle based on the last 8 or 24 hours of data. It accounts for biological changes to insulin sensitivity that occur throughout the day and night and changes from pump placement. + +Autotune, by contrast, works on a longer time scale. It makes slow but sustained changes to your profile to improve the accuracy of your set baseline settings. It is run every 24 hours. + +## Should I enable Autotune? +If you believe your profile settings are accurate, you should keep autotune disabled; it may worsen control in specific scenarios, such as after extended periods of sickness. + +If you decide to enable it, you should note that autotune is limited by autosens max and min ratios. You can alter these values to give autotune more flexibility, but you will also affect autosens, dynamic ISF, dynamic CR, and adjust basal. + +Instead, it is best to review your settings in a few weeks, note the new autotune values, and change your profile settings to match them, giving autotune a new starting point. diff --git a/docs/settings/configuration/basalprofile.md b/docs/settings/configuration/basalprofile.md new file mode 100644 index 00000000..4c46a6fa --- /dev/null +++ b/docs/settings/configuration/basalprofile.md @@ -0,0 +1,21 @@ +# Basal Profile + +!!! tip "Highlights" + + - Basal profile can be transferred from a Medtronic pump or Nightscout account + - Adjust your basal profile by doing fasting experiments, reviewing your IOB at times of fasting, and observing autotune. + +Basal profile consists of your scheduled basal rates, which determine how much insulin is being delivered at each hour of the day. It is important to understand that these settings are not taken verbatim when looping with Trio. Based on your current blood sugar reading, they are adjusted every loop cycle and replaced with temporary basal rates. Your set values are altered by autosens or autotune (if enabled) based on your historical data. + +Your basal profile values should be near your true value. Protection limiters prevent Trio's autotune system from selecting the appropriate dose if the scheduled basal profile is wildly inaccurate. Basal profiles are also important for insulin on board (IOB) calculations. Trio treats your scheduled basal profile as the zero point when autotune is disabled. When autotune is enabled, it uses the autotuned basal rate instead of your scheduled basal rate. The calculated IOB increases if you receive additional insulin on top of your basal rates, either as boluses or high temporary basal rates. Likewise, if you receive low temporary basal rates for a set period, your IOB decreases, and can even become negative. + +## Settings +If you are coming from a pump, transferring basal profiles from your pump settings should be done with consideration and caution. They might not be entirely accurate for Trio. If you are going low or high while fasting, consider adjusting according to the instructions below. + +There are three main ways of identifying and improving your basal profile values. The standard method is to test your basal by having a relaxing 4-6 hours without eating at least two hours before you begin the test. Does your blood sugar stay steady? Or do you climb and need a correction? Or do you go low and need to eat? Setting accurate basal rates is crucial for Trio success. They determine how much of the insulin delivered (from basal and bolus) is counted as insulin on board (IOB). + +You can also monitor your IOB to determine if your basal profile is accurate. Consistently negative or positive IOB at certain times of day may suggest that these hours need to decrease or increase their basal rate, respectively. + +If you have autotune enabled, you can review the day-to-day trend of how autotune is changing your basal profile. If autotune remains steady, you can change your scheduled values to the autotune values. This has two main benefits: +1. Autotune can start to alter your values again if it is being stopped by a safety limiter (autosens max/min) +2. You can have your values hard-coded in case Autotune's data is reset. diff --git a/docs/settings/configuration/carbratios.md b/docs/settings/configuration/carbratios.md new file mode 100644 index 00000000..ba22fc90 --- /dev/null +++ b/docs/settings/configuration/carbratios.md @@ -0,0 +1,19 @@ +# Insulin Carbohydrate Ratio + +!!! tip "Highlights" + + - CR can be transferred from your pump + - Adjust your CR by performing a test meal experiment or observing autotune. + +CR refers to the amount of carbohydrates one unit of insulin is able to neutralize. + +Example: Bill has a 1:10 CR (aka a CR of 10). If Bill has 20 carbs with lunch, he will need 2 U of rapid insulin to neutralize it. + +CR is not changed as drastically as basal rates or ISF unless Dynamic CR is enabled. Your CR must be as accurate as possible for proper Trio function. + +## Settings +It is safe to transfer your CR from your pump settings. However, your settings may not be accurate if you are experiencing high peaks with meals or lows three hours afterward. If you have SMB/UAM on and are experiencing sharp drops, you may also need to optimize your ISF. + +There are two suggested methods of optimizing your CR. The standard way is a test meal experiment, which can be done while not looping. Have a meal with a known amount of carbohydrates and bolus according to your current CR. Monitor your blood sugar at the three-hour mark; did you go high, low, or end up where you started prior to the meal? If you end up high, you can make your CR more aggressive by _DECREASING_ the value. If you were low, make your CR less aggressive by _INCREASING_ the value. You may also look to increase or decrease your adjustment factor if you have dynamic CR on. + +If you have autotune enabled, monitor the general trend in CR adjustment. When the autotune value stabilizes, evaluate the suggestion and change your scheduled value to the autotune value, allowing the system to continue making changes if it was being limited by a safety limiter. diff --git a/docs/settings/configuration/concepts/autosens-dynamic.md b/docs/settings/configuration/concepts/autosens-dynamic.md new file mode 100644 index 00000000..b265e400 --- /dev/null +++ b/docs/settings/configuration/concepts/autosens-dynamic.md @@ -0,0 +1,130 @@ +# Autosens, Dynamic ISF/CR, and Adjust Basal + +!!! tip "Highlights" + + - Enable Dynamic ISF, Dynamic CR, and/or Adjust Basal for more rapid adjustments in response to physiological changes in insulin sensitivity + - Bias the calculated ISF/CR/Basal rates towards more or less aggressive values by increasing or decreasing the adjustment factor accordingly. + - Adjustments are limited by autosens max/min. + +!!! important + + The examples in this section employ the default logarithmic formula for calculations. For information on using Sigmoid, jump to [this section](./sigmoid.md). + +## Autosens +Auto-sensitivity (Autosens) reviews your last 8 hours and 24 hours of data every loop cycle (5 min) and determines whether you have been reacting more or less sensitively to insulin. It then makes conservative temporary adjustments to your basal rates, blood sugar target, and ISF. + +!!! example + + *Autosens* finds Bill has been running more sensitive to insulin lately. In the last 24 hours, he has been 2X more sensitive to insulin, whereas, in the last 8 hours, he has been 3X more sensitive to insulin. + +*Autosens* then takes the more conservative calculated sensitivity. In this example, the more conservative value is obtained from the 8-hour window because by assuming Bill is 3X more as opposed to 2X more sensitive to insulin, the system will be posed to give less insulin. + +If you are using Autotune, Autosens will use your calculated Autotune CR, ISF, and basal rates as its baseline rather than your set values. + +Note that Autosens does not examine meals or adjust your CR. It only assesses your sensitivity to insulin and adjusts ISF/basal rates/blood sugar targets accordingly. + +## Dynamic ISF +Some thought Autosens was too conservative and slow to make changes. `Dynamic ISF` is a drop-in replacement for Autosens's ISF calculation formula, with the goal of making it more aggressive. If you find that you have high ISF variability throughout the day and Autosens is not providing you with sufficient control, you can turn this feature on. + +Dynamic ISF takes into consideration a new variable called the `Adjustment Factor`, which affects its aggressiveness. If Dynamic ISF is too aggressive, you can decrease this number by 0.05-0.1 points to make it more meek. Likewise, increase this number if you still feel dynamic ISF is not aggressive enough. + +!!! note + + - Dynamic ISF is temporarily disabled, and the system reverts to Autosens if either `High Temptarget Raises Sensitivity` or `Exercise Mode` is enabled and a high temporary target has been set by the user. + While Dynamic ISF is inherently more aggressive, it also provides the user with greater control via the `Adjustment Factor` compared to Autosens. You can decrease the `Adjustment Factor` to make Dynamic ISF less aggressive than the calculated Autosens values. + +### Advanced information +Autosens determines a ratio (`autosens.ratio`) and alters your ISF in the following manner: + +$$ +Profile\ ISF\ ÷\ autosens.ratio\ =\ New\ ISF +$$ + +!!! example + + Bill has an ISF of 3 mmol/L/U (54 mg/dL/U) in his settings. The system finds Bill has been more resistant to insulin lately and needs to increase his insulin. It calculates Bill has an `autosens.ratio` of 1.1 (note that a larger `autosens.ratio` results in a lower, more aggressive ISF). + +When Autosens adjusts the ISF, it uses the following calculation: + +$$ +3\ mmol/L/U\ ÷\ 1.1\ =\ 2.73\ mmol/L/U +$$ + +$$ +54\ mg/dL/U\ ÷\ 1.1\ =\ 49\ mg/dL/U +$$ + +_Bill now temporarily has an ISF of 2.73 mmol/L/U (49 mg/dL/U)._ + +Dynamic ISF (using the default logarithmic algorithm in Trio) uses an alternative formula to calculate the autosens.ratio for ISF adjustments. **Note this formula uses mg/dL and not mmol/L:** + +$$ +autosens.ratio\ =\ profile.sens\ *\ AF\ *\ TDD\ *\ log((BG/peak)+1)\ /\ 1800 +$$ + +$$ +New ISF\ =\ (profile\ ISF)\ /\ (autosens.ratio) +$$ + +_This formula considers your profile ISF (profile.sens in mg/dL), current blood glucose (BG in mg/dL), total daily dose (TDD over the last 24 hours), insulin peak effect (peak activity normally is 120 min) and a new variable called adjustment factor (AF) that allows for user tuning of Dynamic ISF/CR._ + +[Click here to view a graph depicting the logarithmic formula in mg/dL](https://www.desmos.com/calculator/zrkugmdnob) + +[Click here to view a graph depicting the logarithmic formula in mmol/L](https://www.desmos.com/calculator/aoxzzrhpro) + +## Dynamic CR +This experimental feature alters the carb ratio (CR) based on current blood sugar and total daily dose (TDD). Unlike ISF, CR was not originally altered by autosens with respect to your detected sensitivity. Using Dynamic CR will lead to a dramatic change in how CR is calculated by Trio. Dynamic CR uses a similar formula as Dynamic ISF as described above: + +$$ +autosens.ratio\ =\ profile.sens\ *\ AF\ *\ TDD\ *\ log((BG/peak)+1)\ /\ 1800 +$$ + +$$ +New\ CR\ =\ (profile\ CR)\ /\ (autosens.ratio) +$$ + +If your CR changes dramatically daily and Trio is not providing adequate bolus recommendations, you can test this feature. Note that Trio already makes modifications to your recommended boluses without this feature enabled based on your blood glucose target, COB, and IOB. + +!!! note + + If the calculated autosens.ratio by Dynamic CR is greater than 1, the following formula is used to make the resulting CR less aggressive: + + $$ + new.autosens.ratio\ =\ (autosens.ratio\ -\ 1)\ /\ 2 + 1 + $$ + + +## Adjust Basal +Adjust Basal replaces Autosens's formula for adjusting basal rates, with a formula dependent on total daily dose (TDD) of insulin. Turn on this setting to give basal adjustments more agility. Keep this setting off if your basal needs are not highly variable. + +### Advanced Information +Normally, a new basal rate is set by autosens: + +- New basal profile = current basal profile * autosens.ratio + +Adjust basal replaces the autosens.ratio with its own autosens.ratio calculated as such: + +- autosens.ratio = (weighted average of TDD)/(2 week average of TDD) +- New basal profile = current basal profile * autosens.ratio + +See `Weighted Average of TDD` setting to understand how this variable is calculated. + +!!! example + + Bill's TDD has been 55 U over the last 24 hours, and his 10-day average is 48 U. He has set his `Weighted average of TDD` in preferences to 0.7. His current profile basal rate is 1 U/h. + + $$ + Weighted\ average\ of\ TDD\ =\ 0.7 * 55 U + 0.3 * 48 U = 52.9 U + $$ + + $$ + basal.autosens.ratio\ =\ 52.9 U\ / 48 U\ =\ 1.1U + $$ + + $$ + New\ basal\ profile\ =\ 1 U/h * 1.1\ =\ 1.1 U/h + $$ + +!!! tip "Final Thoughts" + + Remember that all Autosens ratios calculated in this section are being limited by Autosens Max and Autosens Min safety limiters. Additionally, Dynamic CR has a built-in safety limiter against highly aggressive ratios. diff --git a/docs/settings/configuration/concepts/img/sigmoid_chart.png b/docs/settings/configuration/concepts/img/sigmoid_chart.png new file mode 100644 index 00000000..f4b5b78f Binary files /dev/null and b/docs/settings/configuration/concepts/img/sigmoid_chart.png differ diff --git a/docs/settings/configuration/concepts/sigmoid.md b/docs/settings/configuration/concepts/sigmoid.md new file mode 100644 index 00000000..e2da6abf --- /dev/null +++ b/docs/settings/configuration/concepts/sigmoid.md @@ -0,0 +1,15 @@ +# Sigmoid Function + +## What is it? +The sigmoid function provides an alternative to the default logarithmic function. It is called **Sigmoid** because the math used to calculate adjustments forms a sigmoid shape. + +![Sigmoid Function](img/sigmoid_chart.png){width=865} +{align=center} + + +## How does it work? +Sigmoid relies upon how far your blood glucose is from your target BG to determine how much to adjust ISF. As blood sugars get farther away from your target BG, sigmoid adjustments get larger. The adjustments are limited by autosens max and autosens min settings. + +[Click here to view a graph depicting the sigmoid formula in mg/dL](https://www.desmos.com/calculator/s9jxdmqhh8) + +[Click here to view a graph depicting the sigmoid formula in mmol/L](https://www.desmos.com/calculator/nb5l47yx0h) diff --git a/docs/settings/configuration/concepts/smb-uam.md b/docs/settings/configuration/concepts/smb-uam.md new file mode 100644 index 00000000..044b1be8 --- /dev/null +++ b/docs/settings/configuration/concepts/smb-uam.md @@ -0,0 +1,27 @@ +# SMB and UAM +!!! tip "Highlights" + - Enable SMB and UAM after ensuring accurate basal rates and ISF. + - Adjust SMB/UAM minutes to allow the system to give greater amounts of insulin with one bolus. + - Max IOB must be greater than 0 for it to function. _Suggested: average meal bolus + 3x highest hourly basal rate._ + +## Super Micro Boluses +Super micro bolus (SMB) gives you small amounts of insulin upfront in the form of a bolus. Your temporary basal rates will be reduced accordingly before or after the SMB is delivered, so you will overall receive the same amount of insulin you would have received with temporary basal rates alone. SMB allows for faster control of blood sugars by providing more insulin upfront. + +There are limitations on the size of SMBs. [See the OpenAPS documentation for more information](https://openaps.readthedocs.io/en/latest/docs/Customize-Iterate/oref1.html#understanding-super-micro-bolus-smb). + +!!! important + - Please ensure your profile settings are accurate before enabling SMB and UAM. + - Do not perform manual correction boluses with SMB and UAM enabled. You will be at a high risk of having a low. + +There are numerous settings related to enabling SMBs in Trio. Below is the order of precedence of the settings Trio uses when deciding whether to enable or disable SMB: + +1. disable SMB when a high temp target is set (unless "allow SMB with High Temptarget" is enabled) +2. enable SMB/UAM if always-on (unless disabled for high temp target) +3. enable SMB/UAM (if enabled in preferences) while we have COB +4. enable SMB/UAM (if enabled in preferences) for a full 6 hours after any carb entry +5. enable SMB/UAM (if enabled in preferences) if a low temp target is set + +For a detailed look at when SMBs are delivered, see the chart in [Are SMBs Allowed?](../preferences/smbsettings.md#are-smbs-allowed) section. + +## Unannounced Meals +Unannounced Meal (UAM) provides an alternative method (in addition to or instead of carb entry) for detecting and safely dosing insulin via SMBs in response to significant BG rises, whether due to meals, stress/illness, or counterregulatory hormones (adrenaline, cortisol, glucagon, HGH). When enabled, it replaces Advanced Meal Assist (AMA). AMA is an older feature that depends on your carbohydrate entries and sets high temporary basal rates to counteract any remaining carbs on board. diff --git a/docs/settings/configuration/insulinsensitivities.md b/docs/settings/configuration/insulinsensitivities.md new file mode 100644 index 00000000..a15f58bd --- /dev/null +++ b/docs/settings/configuration/insulinsensitivities.md @@ -0,0 +1,24 @@ +# Insulin Sensitivity Factor + +!!! tip "Highlights" + + - ISF is the most problematic setting for new loopers. + - ISF can be transferred from your pump to start. + - Adjust ISF by performing a correction and seeing if you reached your glucose target, or by observing autotune. + +ISF, also called insulin correction factor (ICF), refers to the amount of blood glucose in mmol/L (or mg/dL, depending on your settings) one unit of insulin can neutralize. + +Example: Bill has a 1:4 ISF (this is also written in shorthand as an ISF of 4 mmol/L/U (72 mg/dL/U)). This means 1 U of rapid insulin will bring Bill's sugar down by 4 mmol/L (72 mg/dL). + +Like basal rates, ISF is not used verbatim by Trio but is modified over time as data on the patient is collected. Still, setting ISF as close to accurate as possible is important for Trio to function well. + +## Settings +It is safe to transfer your ISF from your pump settings. Note that almost all issues when starting with Trio are a result of an improperly set ISF. If you find you have lows with corrections, or you have SMB/UAM on and the application provides too much insulin at any time, resulting in a rollercoaster pattern, your ISF is likely to blame. + +There are a few ways you can work to adjust your ISF. The easiest method is simply bringing yourself to a higher glucose with a glucose tab or choosing a time when you are "stuck" higher than your target, then correcting based on your ISF. If you are higher than your target after 4 hours, make your ISF more aggressive by _DECREASING_ the value. If you are lower than your target after 4 hours, make your ISF less aggressive by _INCREASING_ the value. + +You may also find Autotune helpful in identifying when to adjust your ISF and determine whether it is too high or low based on the trend in its changes. Look to changing your profile value to the autotune value when Autotune stabilizes to ensure safety limiters aren't preventing any additional needed change. + +!!! warning + + When using Autotune, it is important to **turn OFF** DynamicISF prior to enabling or running Autotune diff --git a/docs/settings/configuration/preferences/dynamicsettings.md b/docs/settings/configuration/preferences/dynamicsettings.md new file mode 100644 index 00000000..570350e3 --- /dev/null +++ b/docs/settings/configuration/preferences/dynamicsettings.md @@ -0,0 +1,95 @@ +# Dynamic Settings + +!!! warning "Attention" + + Please read [Autosens and Dynamic ISF/CR](../concepts/autosens-dynamic.md) before continuing. + +!!! tip + + - _Dynamic ISF and Dynamic CR:_ Enable for more responsive changes to your current blood glucose and TDD. + - _Adjustment Factor:_ A higher adjustment factor will result in a lower ISF/CR (increase in insulin dosage), and a lower adjustment factor will give a higher ISF/CR (decrease in insulin dosage). Adjust by 0.1 steps as needed. + - _Adjust basal:_ Enable if your basal rates are otherwise not being adjusted adequately. + +## Dynamic ISF + +Dynamic ISF is a more aggressive alternative to Autosens's ISF adjustment algorithm. Many people find that ISF depends on BG level instead of solely time of day, making it hard to fix persistent highs by adjusting the scheduled ISF settings. + +## Dynamic CR + +Dynamic CR alters your carb ratio with every loop cycle based on your current blood glucose and TDD of insulin. Turn it on if you experience your CR changing day-to-day or at different blood glucose levels and Trio is not consistently suggesting appropriate boluses. You should first rule out other causes for this, including inadequate carb counting or inappropriate profile ICR. + +## Adjustment Factor + +Adjustment Factor (AF) allows one to bias the Dynamic ISF and Dynamic CR (if they are enabled) toward more or less aggressive results. Increasing AF will result in the Dynamic ISF/CR outputting more aggressive values while decreasing it will bias the output toward less aggressive values. It is recommended to start with an AF of 0.5-0.8 and increase as needed. + +!!! example + + Bill has Dynamic CR on. His Dynamic CR is calculated to be 1:4 by Trio based on his current blood glucose, TDD, and his set ISF. But Bill decides to set his AF to 1.2 because he has found recently that Dynamic CR has not been giving him aggressive enough numbers. Trio acts accordingly, increasing his CR to something above 1:4 instead (ex: 1:3.5). + + This is a simplified example. See the section on Dynamic CR for more information. + +!!! warning "Caution" + + ***Adjustment Factor (AF) is not a safety limiter*** + + - Increasing AF means you are telling the system that ALL dynamically calculated ISF/CR values have not been aggressive enough, and you want the system to make them more aggressive. + - Decreasing AF means you are telling the system that ALL dynamically calculated values are too aggressive, and to make them less so. + +## Sigmoid Function +Dynamic CR and ISF use a logarithmic function to perform calculations by default. + +This option replaces the logarithmic function with a sigmoid function for Dynamic ISF/CR calculations. + +Before enabling this setting, please read the dedicated section on [sigmoid](../concepts/sigmoid.md). + +!!! warning + + ***Before enabling Sigmoid*** + + - Reset Autosens Max to 1.2 + - Reset Autosens Min to 0.8 + - Set Adjustment Factor between 0.4-0.5 + +## Weighted Average of TDD. Weight of past 24 hours: + +This ratio is used by "Adjust basal" for its calculations. +It allows you to effectively control the variability of basal adjustments (if Adjust basal is enabled). +You can set this value to a decimal between 0 and 1. + +>- Set at **1.0** = uses 100% of the TDD from the past 24 hours +>- Set at **0.65** (default) = 65% of the TDD from the past 24 hours + 35% of the TDD from the past 2 weeks +>- Set at **0.0** = uses 100% of the TDD from the past 2 weeks + +!!! example + + Bill has a TDD of 55 U over the last 24 hours. He has had a TDD of 48 U over the last 10 days. His Weighted Average is set at 0.65: + + $$ + TDD Average = 55 * 0.65 + 48 * 0.35 = 52.55 + $$ + +As you increase the default 0.65 ratio to a higher number, the adjusted basal rates will be more influenced by your last 24-hour insulin usage, resulting in more variable changes. + +## Adjust Basal + +Adjust Basal replaces the sensitivity-based formula normally used by Autosens for adjusting your basal rates with a dynamic formula dependent on your TDD of insulin. Use this if the current Trio adjustments of basal rates are not adequate. + +## Threshold Setting (mg/dl) +The threshold setting is a safety limiter function. If blood sugar at any point is predicted to go below this value, Trio will suspend insulin delivery (SMBs are halted and Temp Basal of 0 U/hr set) and wait till its algorithms predict otherwise. This setting can be useful if you are experiencing a high number of hypoglycemia events. Please review the [OpenAPS documents](https://openaps.readthedocs.io/en/latest/docs/While%20You%20Wait%20For%20Gear/Understand-determine-basal.html?highlight=Safety%20Threshold) if you want a better understanding of how it is used. + +The threshold setting is, by default, determined by your blood glucose target setting: + +- Lower Target: 90 mg/dl = Threshold 65 mg/dl +- Lower Target: 100 mg/dl = Threshold 70 mg/dl +- Lower Target: 110 mg/dl = Threshold 75 mg/dl +- Lower Target: 130 mg/dl = Threshold 85 mg/dl + + +This setting allows you to choose a higher threshold setting than the default. Note that you cannot choose something lower than the default setting for a certain blood glucose target. + +!!! example + + Bill has set a BG target of 110 mg/dl. + In his Trio preferences, he has set his threshold to 65 mg/dl. + +Because Trio's default threshold setting is 75 mg/dl for a 110 mg/dl blood glucose target, Bill's preference will be ignored. diff --git a/docs/settings/configuration/preferences/img/smb_allowed_flowchart.jpeg b/docs/settings/configuration/preferences/img/smb_allowed_flowchart.jpeg new file mode 100644 index 00000000..2a49399b Binary files /dev/null and b/docs/settings/configuration/preferences/img/smb_allowed_flowchart.jpeg differ diff --git a/docs/settings/configuration/preferences/mainsettings.md b/docs/settings/configuration/preferences/mainsettings.md new file mode 100644 index 00000000..d165136f --- /dev/null +++ b/docs/settings/configuration/preferences/mainsettings.md @@ -0,0 +1,139 @@ +# OpenAPS Main Settings + +!!! important + + - **Insulin curve:** Choose the insulin used in your pump + - **Max IOB:** Use the formula "average meal bolus + 3x highest hourly basal" to determine your Max IOB. Increase slowly if more insulin is warranted + - **Autosens Max/Min:** Increase the autosens max and autosens min to allow the system to choose more or less aggressive autotune and autosens values regarding your scheduled value. + +## Insulin Curve +Select your insulin type for the appropriate response curve to be used by the algorithm: + +
+Bilinear: + This IOB curve is based on a bilinear activity curve that varies by the user’s duration of insulin action setting in their pump. +
+
+Rapid-acting: + This is the default setting for Novolog, Novorapid, Humalog, and Apidra insulins. Selecting this setting will cause OpenAPS to use an exponential activity curve with a peak activity set at 75 minutes and a duration of insulin action set at 300 minutes (5 hours). +
+
+Ultra-Rapid: + This is the default setting for Fiasp and Lyumjev. It uses an exponential activity curve with a peak activity set at 55 minutes and a duration of insulin action set at 300 minutes (5 hours). +
+ +!!! warning "Caution" + + Duration of insulin (DIA) action can be altered in the pump settings section of Trio. A minimum of 5 hours is required. **It is not advised to alter this setting from the default.** + +To understand why a higher duration of insulin action is used in Trio, click to see the [following documentation from Tim Street.](https://www.diabettech.com/insulin/why-we-are-regularly-wrong-in-the-duration-of-insulin-action-dia-times-we-use-and-why-it-matters/) + +## Max IOB +The maximum amount of insulin on board (i.e. in the body). This includes insulin from all sources (basal and bolus) that are automatically delivered by Trio. Manual boluses are not subjected to this limiter. + +The default is set to zero, meaning Trio can only set temporary basal rates lower than your profile basal rate. It cannot set temporary basal rates that exceed your profile basal rate in cases of high blood sugar, and it cannot use super micro boluses to control blood sugar. + +You can start by increasing this number to your average mealtime bolus and evaluating its effect. The default recommendation is “average meal bolus + 3x max hourly basal” when using super micro boluses. + +!!! example + + _Bill has an average mealtime bolus of 6U, and the following basal profile:_ + + - 12:00 am: 1.0 U/hr + - 6:00 pm: 2.0 U/hr (_Highest Hourly Basal_) + - 9:00 pm: 1.5 U/hr + + Using the **MaxIOB** formula + + $$ + Average\ Meal\ Bolus + 3 \times Highest\ Hourly\ Basal + $$ + + his recommended **Max IOB** setting should be **12** + + $$ + 6 + 3 \times 2.0 = 12 + $$ + +If you are insulin resistant and/or need help dealing with meal spikes, you can continue to increase this number further to allow for greater insulin delivery. + +## Max COB +The maximum amount of carbs that Trio is allowed to bolus or set high-temp targets for. This safety feature protects against erroneous carbohydrate entries that could lead to hypoglycemia episodes. + +!!! tip + + If you tend to eat more than 120 g of carbs in one sitting, choose the maximum amount of carbs you eat. + +## Max Daily Safety Multiplier +Limits the maximum temporary basal rate Trio is able to use at _any time_. The default setting of 3, which is unlikely to need adjustment, allows for a maximum basal rate of 3 times the maximum daily basal. + +!!! example + + Bill has Max Daily Safety Multiplier set to 3 and the following basal profile: + + - 12:00 am: 1.0 U/hr + - 6:00 pm: 2.0 U/hr (_Highest Hourly Basal_) + - 9:00 pm: 1.5 U/hr + + It is 7:00 am, so Trio has been scheduled to deliver 1 U/hr. But Bill is running high, so Trio wants to deliver more. + + Using the formula + + $$ + Highest\ Hourly\ Basal \times Max\ Daily\ Safety\ Multiplier = Maximum\ Temporary\ Basal\ Rate + $$ + + the maximum temporary basal rate that can be set is **6 units per hour** + + $$ + 2.0 \times 3 = 6 + $$ + +## Current Basal Safety Multiplier +Limits the maximum temporary basal rate Trio is able to use at the **current time**. The default setting of 4, which is unlikely to need adjustment, allows for a maximum basal rate of 4x the current basal rate. + +!!! example + + It is currently 9:00 am, and Bill has the following basal profile: + + - 12:00 am: 1.0 U/hr (_Current Basal Rate_) + - 6:00 pm: 2.0 U/hr + - 9:00 pm: 1.5 U/hr + + Using the formula + + $$ + Current\ Basal\ Rate \times Current\ Basal\ Safety\ Multiplier = Maximum\ Temporary\ Basal\ Rate + $$ + + the maximum temporary basal rate that can be set by Trio at 9:00 am is **4 units per hour** + + $$ + 1.0 \times 4 = 4 + $$ + +!!! important + + The algorithm compares the two results from **Current Basal Safety Multiplier** and **Max Daily Safety Multiplier**, then it limits calculations with the smaller of the two values + +## Autosens Max +Please read [Autosens and Dynamic ISF/CR](../concepts/autosens-dynamic.md) and [Autotune](../autotune.md) before adjusting this setting. + +This setting determines the maximum ratio autosens can use for its adjustments. Increasing this value allows autosens to increase insulin given through your basal profile, ISF, and target blood glucose. + +### Autosens Max with Dynamic ISF and/or Dynamic CR +This limits the ability of Dynamic ISF and Dynamic CR to make more aggressive adjustments. + +### Autosens Max with Autotune +This limits Autotune's ability to make more aggressive adjustments to your CR, basal profile, and ISF. + +## Autosens Min +Please read [Autosens and Dynamic ISF/CR](../concepts/autosens-dynamic.md) and [Autotune](../autotune.md) before adjusting this setting. + +This setting determines the minimum ratio autosens can use for its adjustments. Decreasing this value allows autosens to reduce insulin given through your basal profile, ISF, and target blood glucose. + +### Autosens Min with Dynamic ISF and/or Dynamic CR +This limits the ability of Dynamic ISF and Dynamic CR to reduce insulin needs. + +### Autosens Min with Autotune +This setting Autotune's ability to reduce insulin needs in your CR, basal profile, and ISF. diff --git a/docs/settings/configuration/preferences/othersettings.md b/docs/settings/configuration/preferences/othersettings.md new file mode 100644 index 00000000..a8459551 --- /dev/null +++ b/docs/settings/configuration/preferences/othersettings.md @@ -0,0 +1,145 @@ +# OpenAPS Other Settings + +!!! warning "Caution" + + **None of these settings likely require adjustment from their defaults** + +## Rewind Resets Autosens +"Rewind" in Medtronic lingo refers to the attachment of a new insulin reservoir and infusion set. For Omnipod users, this means replacing your pod with a new one. + +When you change the insulin injection site, you might find your insulin sensitivity is altered based on how well it's diffusing into your bloodstream. + +This setting resets autosens's calculated autosens.ratio and forces it to restart anew from the time of the site change to improve your calculated basal rates, sensitivity ratio, and target blood glucose. + +For more information, please read [Autosens and Dynamic ISF/ICR](../concepts/autosens-dynamic.md). + +## Use Custom Peak Time +Toggle this on to use the "Insulin Peak Time" setting. + +## Insulin Peak Time + +!!! note + + Requires "Use Custom Peak Time" to be enabled. + +Select a peak activity time point, based on your insulin type. + +## Skip Neutral Temps +This feature was introduced in the OpenAPS algorithm (Oref0) but does not play a major role in Trio. + +_Light sleepers using OpenAPS would find that the notifications delivered by OpenAPS upon making a temp basal adjustment would wake them up._ + +This setting attempts to reduce notifications produced by OpenAPS (and Trio). However, it could potentially impact control and make it harder for users to determine if the system is working. + +!!! warning "Caution" + + **It is recommended to keep this setting disabled** + +## Unsuspend if No Temp + +!!! important + + This setting only applies to Medtronic Pumps + +After manually suspending your pump, you will be provided with a reminder at a chosen time to resume it. Many people, however, neglect this reminder and forget to unsuspend, leading to highs. + +This feature allows you to use zero temp basals to unsuspend your pump automatically. Before suspending your pump, set a 0 U/hr temp basal for the period you want the pod to remain suspended. Then suspend the pod. Once the temp basal expires, the pod will be automatically reactivated. + +## Suspend Zeros IOB +This allows Trio to understand better that no insulin is being delivered to the patient when a pump suspension occurs. + +Trio will set a zero temp basal (0 U/hr) during pump suspensions, improving its insulin on board calculations and, therefore, its algorithm calculations. + +Recommended to keep this setting enabled. + +## Min 5m Carbimpact +This is a fallback setting used by Trio. If Trio is unable to tell if carbs are being absorbed from blood sugar readings, it will estimate how many carbs have been absorbed using this setting. + +The default value of 8 mg/dL/5min assumes carbohydrates will increase blood sugar by 8 mg/dL every 5 minutes. The actual amount of carbohydrates estimated to be absorbed depends on your calculated carbohydrate sensitivity ratio (CSF = ISF/CR). + +## Autotune ISF Adjustment Fraction +Autotune, by default, adjusts your ISF by 20% each nightly run. This value allows you to make your autotune adjustments less aggressive. + +Set this at 1 for the full 20% adjustment. + +!!! info "Maths" + + $$ + adjustedISF\ =\ adjustmentFraction\ *\ autotuneISF\ +\ (1-adjustmentFraction)\ *\ profileISF + $$ + + $$ + newISF\ =\ (\ 0.8\ *\ profileISF\ )\ +\ (\ 0.2\ *\ adjustedISF\ ) + $$ + +!!! example + + Bill has a profile ISF of 3. Autotune thinks his true ISF value is 4. His adjustment fraction is 1. + + $$ + adjustedISF = 1 * 4 + (1 - 1) * 3 = 4 + $$ + + $$ + newISF = (0.8 * 3) + (0.2 * 4) = 3.2 + $$ + + _Assuming autotune is not being limited by the autosens max and min, Bill's ISF will be set to 3.2 by autotune tonight. Autotune will then repeat the following night, starting with a profileISF = 3.2_ + + +## Remaining Carbs Fraction +This is the fraction of carbs that is assumed not to be absorbed yet after 4 hours if carb absorption has not been seen. + +When attempting to measure carbohydrates on board (COB) Trio may not be fully accurate. This setting is a safety feature that can prevent Trio from providing insulin for non-existent carbs. + +!!! example + + It has been 4 hours since Bill ate 20 carbs. Trio has been able to calculate that he's absorbed 15 carbs but cannot account for the 5 other carbs yet. Bill has a remaining carbs fraction of 0.75 + + $$ + Remaining COB = COB - absorbedCarbs - mealCarbs * (1 - carbsFraction) + $$ + + $$ + 20 - 15 - 20(1 - 0.75) = 0 + $$ + + Bill is assumed to have 0g carbs on board + +!!! tip + + Recommend to keep this value at the default of 1 meaning it will not impact Trio's calculations. + This feature is closely tied to "Remaining Carbs Cap." + +## Remaining Carbs Cap +This setting is a safety limiter that determines the maximum amount of carbs that are assumed to be absorbed after 4 hours of carb absorption. A minimum of 90 carbs is mandatory for this setting. + +!!! example + + Bill eats 150 carbs. After 4 hours, Trio calculates a COB of 110. + It will reduce that number to 90 carbs. + +!!! tip + + It is recommended to keep this value at default + +## Noisy CGM Target Multiplier +If Trio detects that CGM data has been noisy, it will increase your target blood sugar by a set fraction to avoid you getting low. Default is 30% higher (1.3) + +!!! example + + Bill's Trio has calculated a blood glucose target of 5 mmol/L (90 mg/dL). + But Bill has a noisy sensor. He has set his "Noisy CGM Target Multiplier" to 1.3. + Trio will thereby use a target bg of: + + $$ + 5 mmol/L * 1.3 = 6.5 mmol/L + $$ + + $$ + 90 mg/dL * 1.3 = 117 mg/dL + $$ + +!!! tip + + It is recommended to keep this value at the default of 1.3. diff --git a/docs/settings/configuration/preferences/smbsettings.md b/docs/settings/configuration/preferences/smbsettings.md new file mode 100644 index 00000000..78ca934c --- /dev/null +++ b/docs/settings/configuration/preferences/smbsettings.md @@ -0,0 +1,118 @@ +# SMB Settings + +!!! important + - Super micro boluses (SMB) deliver small doses of insulin. Your basal rate will be temporarily reduced after an SMB is delivered. + - SMBs reduce blood sugar more quickly than temporary basal rates. + - If you want Trio to make all SMB decisions, select Enable SMB Always and leave the other settings deselected. + - Follow the directions below if you want to configure SMBs only to run in certain conditions. + - For a detailed look at when SMBs are delivered, see the chart in [Are SMBs Allowed?](#are-smbs-allowed) section. + - For setup recommendations, see the [Start-Up Guide](http://diy-trio.org/start-up-guide). + +## Enable SMB Always +Enabling this setting allows SMBs to be delivered if your blood sugar is predicted to go above target. + +SMBs will remain on if you have a low temporary target set but will be fully disabled if a high temporary target is set (unless "[Allow SMB With High Temptarget](#allow-smb-with-high-temptarget)" is enabled). + +The size of SMBs is limited. For more information, see the [OpenAPS documentation](https://openaps.readthedocs.io/en/latest/docs/Customize-Iterate/oref1.html#understanding-super-micro-bolus-smb). + +## Max Delta-BG Threshold SMB +This safety limiter looks at the difference between your last two blood glucose readings. If the difference is large, Trio suspects them to be incorrect and will suspend SMB delivery accordingly. You can adjust the amount of change that should be allowed before SMBs are delivered. +A setting of 0.2 means it will only give SMBs if the difference between the current and previous blood glucose readings is no greater than 20%. + +!!! example + + Your last CGM reading was 90mg/dL. The very next reading is 115mg/dL, an increase of 27%. If Max Delta-BG Threshold SMB is set to 0.2 (20%), this change is larger than the threshold, and no SMBs will be given. + +!!! tip + + For a fully closed loop, 0.3 is advised. + +## Enable SMB With COB +SMBs will be enabled if you currently have carbs on board (COB) to help you deal with meal spikes. This feature should be enabled if you want to use UAM. + +!!! note + + If you already have "[Enable SMB Always](#enable-smb-always)" on, this feature is redundant and does not need to be configured. + +## Enable SMB with Temptarget +SMBs will be enabled if you have set a lower blood sugar target temporarily. This will allow you to reach your target faster. + +!!! note + + If you already have "[Enable SMB Always](#enable-smb-always)" on, this feature is redundant and does not need to be configured. + +## Enable SMB After Carbs +SMBs will be enabled if you had carbs within the last 6 hours to help with meal spikes. + +!!! note + + If you already have "[Enable SMB Always](#enable-smb-always)" on, this feature is redundent and does not need to be configured. + +## Allow SMB With High Temptarget +By default, Trio will not allow SMBs if you have a temporary blood glucose target set above 5.5 mmol/L (100 mg/dL), even if "[Enable SMB Always](#enable-smb-always)" is toggled on. Toggling this feature ON will disable that safety check and not prevent SMBs when a high temporary target is set, as long as SMBs are otherwise enabled. + +## Enable SMB With High BG +This allows SMBs to occur above the measure set below in "...When Blood Glucose is Over (mg/dl)". + +!!! note + + If you already have "[Enable SMB Always](#enable-smb-always)" on, this feature is redundant and does not need to be configured. + +## ... When Blood Glucose is Over (mg/dl) +See the above setting for more information. This allows you to configure the target at which SMBs will be enabled. + +## Enable UAM +With this option enabled, the SMB algorithm can recognize unannounced meals. This is helpful if you forget to tell Trio about your carbs or estimate your carbs wrong. It can also help if a meal with lots of fat and protein has a longer duration than expected. Without any carb entry, UAM can recognize fast glucose rises caused by carbs, illness, or counter-regulatory hormones, and tries to adjust it with SMBs. This also works the opposite way: if there is a fast glucose drop, it can stop SMBs earlier. + +## Max SMB Basal Minutes + +Max SMB Basal minutes is one of the major limits on how much insulin a single SMB delivers. + +The amount of insulin that can be delivered by an SMB is related to the amount of scheduled basal insulin in your "Basal Profile" settings. + +For example, if you are receiving a basal dose of 1 unit per hour and set "Max SMB Basal minutes" to 30, an SMB will deliver no more insulin than would be delivered by your basal in 30 minutes or half a unit (0.5U). + +If you see that Trio is giving very small — or the same — SMBs every 5 minutes, you may need to adjust the [Max IOB](./mainsettings.md#max-iob) or [Max SMB basal minutes](#max-smb-basal-minutes). First, you should confirm your basal rates are adequate. Then, you can experiment with increasing [Max SMB basal minutes](#max-smb-basal-minutes) so Trio can provide larger SMBs to better respond to BG rises and predicted rises. + +## Max UAM SMB Basal Minutes + +This setting limits the size of SMBs that Trio can deliver when it detects an unannounced meal (UAM). The maximum size of each SMB is set in relation to the scheduled basal insulin in your profile settings. + +You can configure this setting to make UAM more or less aggressive to correct meal spikes. Note that SMBs delivered in response to unannounced meals are also limited by your [Max IOB](./mainsettings.md#max-iob). See "[Max SMB Basal Minutes](#max-smb-basal-minutes)" above for information on other settings that limit SMBs. + +Tip: If you struggle with meals or hormonal highs, consider increasing maximum basal minutes (slowly and watching results over multiple days before changing again) to allow UAM to give more insulin in one bolus. + +## SMB DeliveryRatio +This is a safety limiter. Trio determines how much insulin is required to get you back to your target glucose. If SMB is enabled, Trio then delivers an SMB, that defaults to half the required insulin. + +This setting allows you to boost or reduce what fraction of the required insulin is delivered in a single SMB. It is recommended you look at your basal profile, [Max SMB basal minutes](#max-smb-basal-minutes), [Max UAM SMB Basal Minutes](#max-uam-smb-basal-minutes), and [Max IOB](./mainsettings.md#max-iob) before you adjust this setting. + +## SMB Interval +The minimum interval between SMB boluses. SMBs will be delivered at this rate or less as needed. + +## Bolus Increment +The minimum amount of insulin that can be bolused by Trio via an SMB. This is determined by your pump hardware. + +## Are SMBs Allowed? + +![SMB-flow-chart](img/smb_allowed_flowchart.jpeg) +{align=center} + +### By following the flow chart above, you can see which combination of settings will allow SMBs. + +- If a setting in the top row is toggled off, look at the next box to the right. If no box in the top row is toggled on, then SMBs will not be allowed. +- If any of the settings in the top row are toggled on and their condition is true, follow the green line down to the "Allow SMB with High Temptarget" box. +- If "Allow SMB with High Temptarget" is toggled on (NOT the default), then continue to follow the green line to the bottom conditions. +- If "Allow SMB with High Temptarget" is toggled off (which IS the default), it will then check if you've set a Temp Target (not a custom profile) above 100 mg/dL (5.5 mmol/L). If you have a Temp Target set above 100 mg/dL, then SMBs are DISABLED and not allowed. + +If you've made it to the bottom row, it checks all those conditions, and if none of them are true, then SMBs are allowed. + +### Here is the order of settings Trio uses when deciding whether to enable or disable SMBs: + +- Disable when a High Temptarget is set (unless "Allow SMB with High Temptarget" is enabled) +- Enable if "Enable SMB Always" is set (unless disabled for "High Temptarget)" +- Enable while there are COB +- Enable for a full 6 hours after any carb entry +- Enable if a Low Temptargt is set + + diff --git a/docs/settings/configuration/preferences/statistics.md b/docs/settings/configuration/preferences/statistics.md new file mode 100644 index 00000000..7b0106fa --- /dev/null +++ b/docs/settings/configuration/preferences/statistics.md @@ -0,0 +1,20 @@ +# Statistics + +!!! important + + This section is entirely visual and does not impact insulin dosage calculations + +### Low Glucose Limit +Sets the lower blood sugar limit for statistical determination of *time below range* (TBR). + +### High Glucose Limit +Sets the higher blood sugar limit for statistical determination of time above range (TAR) + +### Update every number of minutes +This setting determines how often the statistics are updated on the home screen and, for advanced users, controls how often statistics are uploaded to Nightscout. + +### Display Loop Cycle statistics +This shows the average number of loops performed over the last 24 hours. Ideally, the number should be near 288, the maximum number of loops performed per day. Negative impacters include CPU speed, pump, and pod changes, connection issues, etc. + +### Override HbA1c unit +By default, the estimated HbA1c statistic is given in percentage units. Enabling this toggle converts it to mmol/mol units. diff --git a/docs/settings/configuration/preferences/targetsettings.md b/docs/settings/configuration/preferences/targetsettings.md new file mode 100644 index 00000000..d0101645 --- /dev/null +++ b/docs/settings/configuration/preferences/targetsettings.md @@ -0,0 +1,64 @@ +# OpenAPS Targets Settings + +!!! tip "High Temptarget Raises Sensitivity" + + Enable `High Temptarget Raises Sensitivity` if you exercise frequently with high temp targets and are going low. + +## High Temptarget Raises Sensitivity +For more information, please read [Autosens and Dynamic ISF/CR](../concepts/autosens-dynamic.md). + +Normally, Trio assumes your sensitivity will be lower with higher blood sugar levels (resulting in greater amounts of insulin being delivered). During periods of exercise, some people may instead experience increased sensitivity to insulin. With this feature enabled, setting a high temporary target will decrease the autosens ratio utilized for ISF and basal adjustments, resulting in less insulin delivered overall. This scales with the temporary target set; higher and higher temp targets lead to lower and lower insulin delivery in the form of basal rates and corrections. + +Note that this setting also disables Dynamic ISF when high temp targets are set. + +## Low Temptarget Lowers Sensitivity +For more information, please read [Autosens and Dynamic ISF/CR](../concepts/autosens-dynamic.md). + +When planning to have a heavy meal, you may want to set a low temporary target to avoid high blood sugar spikes. You may also want Trio to deliver more insulin during this time to prevent meals from spiking too high. Enabling this feature will increase your autosens.ratio, which is utilized for ISF and basal adjustments, resulting in greater insulin delivery. This will allow Trio to better deal with post-prandial spiking. + +## Sensitivity Raises Target +When performing autosens and insulin dosing calculations, Trio uses a target blood glucose that is by default the lower value in your target range. + +Example: Bill has a target range of 5.5 to 6.0. His target blood glucose is thus 5.5. (Note that Bill's target is not exactly this value; Trio alters the target via autosens to improve its dosing) + +When "Sensitivity Raises Target" is enabled, Trio will set a higher blood glucose target to base its insulin dosage calculations on if it detects sensitivity. This can be useful if you find Trio is too aggressive. + +Advanced information: +For more information, please read [Autosens and Dynamic ISF/CR](../concepts/autosens-dynamic.md). + +If the autosens.ratio is determined to be <1.0, this setting comes into effect and increases the blood glucose target by a small amount. See the OpenAPS code base for the exact formulas used. + +## Resistance Lowers Target +See "Sensitivity Raises Target" for more information. When Trio detects high insulin resistance, it will set a lower blood glucose target for insulin dosage calculations, providing more insulin overall. This is useful for patients who experience uncontrollable highs. + +Advanced information: +For more information, please read [Autosens and Dynamic ISF/CR](../concepts/autosens-dynamic.md). + +If the autosens.ratio is determined to be >1.0, this setting comes into effect and decreases the blood glucose target by a small amount. See the OpenAPS code base for the exact formulas used. + +## Advanced Target Adjustments +Deprecated; Autosens has alternative functions for determining if insulin can be safely added when high. + +## Exercise Mode +Redundant; same as "High Temptarget Raises Sensitivity". Enabling either feature will provide the desired change to sensitivity with high temp targets. + +## Half Basal Exercise Target +This setting allows you to control the reduction in basal when using either "Exercise Mode" or "High Temptarget Raises Sensitivity." The default is 160 mg/dL, meaning basal will be at 50% of your scheduled with a temporary target at 160, 60% at 140, and 75% at 120. + +Advanced information: +See openAPS code for more information. + +The **formula** used is: + +$$ +(halfBasalTarget - 100)/((halfBasalTarget - 100)+(targetBG-100)) +$$ + +!!! example + + Bill has a halfBasalTarget of 160 and has set a temporary target of 120 for his upcoming exercise. + Therefore, only 75% of his scheduled basal rate will be provided: + + $$ + (160 - 100)/((160 - 100) + (120 - 100)) = 0.75 + $$ \ No newline at end of file diff --git a/docs/settings/configuration/preferences/trio.md b/docs/settings/configuration/preferences/trio.md new file mode 100644 index 00000000..4349ebb6 --- /dev/null +++ b/docs/settings/configuration/preferences/trio.md @@ -0,0 +1,58 @@ +# Trio + +## Glucose Units +Allows you to toggle between mmol/L and mg/dL blood glucose units. + +## Remote Control +Allows for remote control of Trio using Nightscout. + +!!! warning "Caution" + + **Duplicate Delivery Risk** + +***Please read before using Remote Features*** + +We want to highlight a very important risk before you get started. + +For safety, always assume a previous remote carb/bolus was delivered, whether it shows in Nightscout or not. + +**For Example:** + 1. You send a 5-unit remote bolus. + 2. The bolus is delivered to the Looper. + 3. Nightscout has a temporary technical issue and doesn't show the bolus was received. + 4. You are watching Nightscout and don’t see a delivery, so you assume it failed. + 5. You send another remote 5-unit bolus. + 6. The second 5-unit bolus is delivered to the Looper (10 Units total). + +You can see the danger of sending duplicate bolus/carbs, so be careful. If a remote bolus/carb entry doesn’t show in Nightscout/Caregiver, judge whether enough time has passed to try again. + +To use, navigate to your connected Nightscout instance. Click the lock icon at the top right and enter your API secret. Next, click the now visible "+" sign at the top right. A "Log a Treatment" menu will open up. + +To enter carbs, select the "carb correction" event type. Fill in the required blanks and click "Submit Form". Trio will read any carb entries in Nightscout and adjust insulin delivery as configured. + +To configure loop status, pump, or to bolus: + +1. Select the "announcement" event type. +2. For "entered by" enter `remote` (Before Trio-main v0.1.0 it was `freeaps-x-remote` instead) +3. In additional notes, state one of the following options: + +* To bolus, enter `bolus:(amount)` (ex: `bolus:0.5`). +* To control pump, enter either `pump:suspend` or `pump:resume`. +* To control looping, enter either `looping:true` or `looping:false` +* To control temporary basal rate, enter `tempbasal:(rate),(minutes)` (ex: `tempbasal:0,60` to set temporary basal rate at 0 U/hr for 60 minutes) + +!!! note + + Remote configurations with announcement-type events can only be performed every **10** minutes. + +## Recommended Bolus Percentage +Recommended bolus percentage is a safety feature built into Trio. By default, Trio first calculates an "insulin recommended" value when bolusing for carbs, which is the full dosage. That dosage is multiplied by your `Recommended Bolus Percentage` to display your suggested insulin dose. Trio then delivers the remaining insulin via SMBs as the blood sugar starts to rise. + +`Recommended Bolus Percentage` allows you to alter the amount initially delivered. By default (70), 70% of the required meal bolus is delivered before the meal. You can increase or decrease this to alter the insulin delivered prior to the meal. + +!!! note + + A manual bolus uses the `Eventual BG` for glucose prediction, whereas the `insulinReg` for SMBs uses the `minPredBG` (typically lower than Eventual BG). + +## Skip Bolus screen after carbs +After entering carbs, a mealtime bolus will not be suggested or delivered. diff --git a/docs/settings/configuration/pumpsettings.md b/docs/settings/configuration/pumpsettings.md new file mode 100644 index 00000000..8d8d497c --- /dev/null +++ b/docs/settings/configuration/pumpsettings.md @@ -0,0 +1,36 @@ +# Pump Settings + +!!! tip "Highlights" + + - Max Basal = 4x highest hourly basal + - Max Bolus = Max bolus you give for a meal + - Max Carbs = Maximum carbs allowed by a single entry + - DIA = Duration of Insulin Action (typically 7 hours) + +## Delivery Limits +These are safety limiters for Trio. Note that Trio will prevent you from entering anything higher than these limits, but it won't alert or notify you about it. + +### Max Basal +This is the highest temp basal allowed to be set. 4 times your highest scheduled basal rate is generally adequate. + +If Trio predicts you need a temp basal set higher than this value, it will instead set the basal to this maximum value. If you try to manually set a temp basal higher than this value, nothing will happen, and your current basal rate will not change. + +### Max Bolus +Choose the maximum amount of insulin you generally bolus for meals. This can also help if you regularly have leaking or tunneling issues for large boluses. + +If you enter a bolus higher than this value, it will only deliver this maximum value. So if your max bolus is set to 5U but you enter a 6U bolus, only 5U will be delivered. + +### Max Carbs +This is the maximum amount of carbs allowed in a single entry by Trio. If you enter more than this amount, your entry will be reduced to the maximum value. + +>If your Max Carbs setting is 125g and you enter 150g, only 125g will be recorded. You could then enter a second entry for 25g to make up the difference. + +Note that, for now, this setting does not limit the maximum number of carbs that can be added via Nightscout or the watch app. + +## Duration of Insulin Action + +!!! warning + + It is not advised to decrease this setting + +Duration of insulin action (DIA) affects Trio calculations through its impact on insulin on board (IOB). The default DIA of 5 hours is likely too low and can cause insulin stacking. Increasing to 7 hours should suit most users. For more information on DIA in loop systems, read [this](https://www.diabettech.com/insulin/why-we-are-regularly-wrong-in-the-duration-of-insulin-action-dia-times-we-use-and-why-it-matters/) from Tim Street. diff --git a/docs/settings/configuration/targetglucose.md b/docs/settings/configuration/targetglucose.md new file mode 100644 index 00000000..541ce3b8 --- /dev/null +++ b/docs/settings/configuration/targetglucose.md @@ -0,0 +1,7 @@ +# Target Glucose + +Trio will target this value when calculating insulin needs. It should be set to the blood glucose you would like to reach when corrections are made. A recommended value is between 90-110mg/dL or 5-6mmol/L + +!!! tip + + You can set different targets at different times. Some users only have one target. Others have a lower target during the day and a higher target during the night to avoid lows. diff --git a/docs/settings/devices/cgm.md b/docs/settings/devices/cgm.md new file mode 100644 index 00000000..6810046b --- /dev/null +++ b/docs/settings/devices/cgm.md @@ -0,0 +1,52 @@ +# Compatible CGM + +CGM selection includes the following: + +* Nightscout +* xDrip4iOS +* Dexcom G5 +* Dexcom G6 / ONE +* Dexcom G7 / ONE+ +* Glucose Simulator +* Libre Transmitter +* Medtronic Enlite + +## Nightscout +While using Nightscout as a CGM is an option, it should be avoided if possible because it will not keep Trio running in the background like other CGM options. You will have to open Trio manually to make it run loop cycles. + +## xDrip4iOS +To use xDrip4iOS as a CGM source, you must build it yourself with the same Apple Developer account you used to build your Trio app. You cannot use Shuggah or a version distributed by someone else's TestFlight. Please see the following for instructions on how to build xDrip4iOS yourself: [link](../../operate/build.md#xdrip4ios-as-cgm-source) + +However, if you are using Dexcom G6 or ONE with xDrip4iOS, you can choose the Dexcom G6 option in Trio rather than xDrip4iOS, and Trio will intercept the glucose readings even if you're using Shuggah or someone else's TestFlight of xDrip4iOS. + +## Dexcom G5 / G6 / ONE +Trio can intercept glucose readings between the transmitter and the Dexcom app. If you are using a Dexcom G5, G6, or ONE sensor, tap Configuration CGM to enter your transmitter's 6-digit ID. Dexcom Share Credentials are not necessary. When switching transmitters, you must delete your current transmitter from Trio by tapping Configuration CGM, scrolling down, and Delete CGM. Once you do this, you can add the new transmitter with its Transmitter ID. + +## Dexcom G7 / ONE+ +Trio can intercept its glucose readings as long as the Dexcom G7 or ONE app is installed on the same phone. When a new G7 sensor is paired to the Dexcom G7 app, or a new ONE+ sensor is paired to the Dexcom ONE+ app, Trio will automatically start reading it. + +## Glucose Simulator +The Glucose Simulator adds artificial CGM readings to the screen so you can see how your readings might look in the app. When using this CGM option, you cannot manually influence the readings shown to reflect a desired glucose response. Actions taken by the Trio algorithm also do not affect the cgm readings in the Glucose Simulator. They are for visual purposes only. For this reason, using the Glucose Simulator will not help you understand how the algorithm influences blood sugars. + +!!! warning + + ***The Glucose Simulator should never be used in conjunction with a live pump connected to a person (or animal).*** + +## Libre Transmitter +This option pairs a compatible Libre CGM directly with Trio without using a separate app like xDrip4iOS. + +### Supported Sensors +* US Libre 1 10-day *via Transmitters* +* US Libre 1 14-day *via Transmitters* +* International Libre 1 *via Transmitters* +* European Libre 2 / 2 Plus *via Transmitters* +* European Libre 2 / 2 Plus *directly via Bluetooth* + +### Unsupported Sensors +* Non-European Libre 2 +* Libre Pro +* Libre H +* Libre 3 + +## Medtronic Enlite +The Minimed Enlite CGM, available with the Medtronic 522/722, 523/723, and 554/754, wirelessly sends glucose readings to the pump. Trio can read the Medtronic CGM data directly from the pump using a RileyLink-compatible device. diff --git a/docs/settings/devices/pump.md b/docs/settings/devices/pump.md new file mode 100644 index 00000000..1d963309 --- /dev/null +++ b/docs/settings/devices/pump.md @@ -0,0 +1,5 @@ +# Pump + +This section allows you to select your insulin delivery system. For more information on supported pumps, see the following: [link](../../Getting-Started/pump.md). Older *Omnipod* and *Medtronic* devices require a *Rileylink* to translate communication between your phone's Bluetooth signals and the pump's radiocommunication. + +During the setup, you will also be asked to choose your insulin type, which will determine your *duration of insulin action* (DIA) and peak activity time. diff --git a/docs/settings/loop.md b/docs/settings/loop.md new file mode 100644 index 00000000..a6a2e168 --- /dev/null +++ b/docs/settings/loop.md @@ -0,0 +1,12 @@ +# Closed Loop + +Closed Loop is disabled by default. This means Trio cannot make adjustments autonomously. The system relies on your approval of its actions. + +## Should I Enable It? + +Closed Loop allows the system to make insulin adjustments automatically. Your end goal for looping is to enable this setting to reduce the time spent managing your diabetes. However, closing loop too early can make it difficult for new loopers wanting to optimize their ISF, CR, and basal settings. If this is your first time looping, it is recommended you keep this setting disabled initially and ensure your profile settings (CR, ISF, basal rates) are properly set. You should monitor Trio's predictions and suggestions and see if they are appropriate for you. See the corresponding sections on CR, ISF, and basal rates for more information on their adjustment. + +!!! important + + Remember that everyone's diabetes is different, and there is no one-size-fits-all, so take your time optimizing your settings. + diff --git a/docs/settings/services/applehealth.md b/docs/settings/services/applehealth.md new file mode 100644 index 00000000..be0b3f48 --- /dev/null +++ b/docs/settings/services/applehealth.md @@ -0,0 +1,6 @@ +# Apple Health + +!!! info + Apple Health is optional + +Enabling Apple Health allows Trio to write information on your blood sugar readings, insulin, and carbohydrates to Apple Health and read blood sugar readings in Apple Health. You will also need to give permission in iPhone Settings, Health, Data Access & Devices to write data to Apple Health. This is useful for those who like to analyze their data with TidePool, Cockpit, or Glooko. diff --git a/docs/settings/services/fatprotein.md b/docs/settings/services/fatprotein.md new file mode 100644 index 00000000..30083edd --- /dev/null +++ b/docs/settings/services/fatprotein.md @@ -0,0 +1,25 @@ +# Fat and Protein Conversion +!!! tip "Highlights" + - Turn on to bolus for fat and protein + - Adjust your CR if you have lows + - Decrease your Interval in Minutes to make insulin delivery smoother + - Increase your "Override With A Factor Of" by 0.1 increments if you continue to have fat and protein spikes + +## Convert Fat and Protein +Many individuals may experience slow blood sugar rise after fatty or high-protein meals. Enabling "Convert Fat and Protein" allows you to provide a bolus for fat and protein units (FPU). The bolus is delivered in segments over a selected period to avoid the gradual rise in blood sugar. This is similar to setting absorption time or eCarbs if coming from Loop or AndroidAPS, respectively. [For more information, click to see the Omnicalculator.](https://www.omnicalculator.com/health/warsaw-method#what-is-warsaw-method-and-how-does-it-work) + +Your current CR was likely compensating for some of the effects of protein and fat on blood sugar. If you choose to enable this setting, you will need to make your ICR less aggressive to prevent lows. + +## Conversion Settings + +### Delay In Minutes +This controls how long before the system starts to bolus for the fat and protein spike. The default setting is 60 minutes. + +### Maximum Duration in Hours +Limits how long the system can bolus for FPU. A default of 8 is recommended. + +### Interval in Minutes +The interval between each microbolus provided for fat and protein. + +### Override With A Factor Of +Controls the fraction of insulin required for the fat and protein entered. A default of 0.5 allows only half the insulin the system thinks you require, to be delivered. You can experiment with raising this number to one if you continue to see rises in your blood sugar. diff --git a/docs/settings/services/img/badge.png b/docs/settings/services/img/badge.png new file mode 100644 index 00000000..95802bf0 Binary files /dev/null and b/docs/settings/services/img/badge.png differ diff --git a/docs/settings/services/nightscout.md b/docs/settings/services/nightscout.md new file mode 100644 index 00000000..765187f6 --- /dev/null +++ b/docs/settings/services/nightscout.md @@ -0,0 +1,19 @@ +# Visualization and Monitoring +!!! tip "Highlights" + - Nightscout is optional but encouraged + - Nightscout is a useful tool for data analysis and followers + - Create a Nightscout server and input your URL and API_SECRET in Trio. Test the connection and enable "Allow Uploads." + +## Nightscout Introduction + +[Nightscout](http://nightscout.info) (NS) is an open-source, DIY project that allows real-time access to CGM data via a personal website, smartwatch viewers, or apps and widgets available for smartphones. Setting up a Nightscout web app is recommended to visualize your Trio closed loop. + +Nightscout allows a user to upload CGM data from various sources to an online database and cloud computing service. The information is then processed and displayed visually as a graph. Plugins also allow more information to be shown about Trio. + +Even if you don't choose to share your Nightscout site +with another person, it will be helpful for you to visualize what the loop is doing and what it's been doing, plus generate helpful reports for understanding your data. + +[For help making a Nightscout account, please see the OpenAPS documentation.](https://openaps.readthedocs.io/en/latest/docs/While%20You%20Wait%20For%20Gear/nightscout-setup.html) + +## Trio Setup +To enable your nightscout connection, input your Nightscout URL, including the `https://` and your `API_SECRET`. Select `Allow uploads` so Trio can share its predictions and settings with Nightscout. diff --git a/docs/settings/services/notifications.md b/docs/settings/services/notifications.md new file mode 100644 index 00000000..c09e3e48 --- /dev/null +++ b/docs/settings/services/notifications.md @@ -0,0 +1,27 @@ +# Notifications +Allows configuration of Trio notifications. Adjust based on your preferences. + +Notifications can be enabled/disabled by toggling `Allow Notifications` on/off in `iPhone Settings > Notifications > Trio`. + +## Glucose + +### Show glucose on the app badge +This will add your current glucose on top of your Trio icon. + +### Always Notify Glucose +A notification will be triggered every time your glucose is updated in Trio. + +### Always play alert sound +This will cause a sound to be triggered by every Trio notification. + +### Also add source info +The source of the glucose reading will be added to the notification. + +### Low +Set this to the highest value you want a low glucose notification to be triggered at. + +### High +Set this to the lowest value you want a high glucose notification to be triggered at. + +## Carbs Required Threshold +Trio may predict a low blood sugar event and recommend consuming a suggested amount of carbs. `Carbs Required Threshold` determines the minimum amount of carbs required before Trio sends a notification. diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 00000000..b86929f9 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,211 @@ +# Project information +site_name: TrioDocs +site_description: Documentation of Trio, an Automated Insulin Delivery system for iOS. +site_url: https://docs.diy-trio.org/ +site_author: Trio Community +use_directory_urls: true + +# GitHub Repository +repo_name: nightscout/trio-docs +repo_url: https://github.com/nightscout/trio-docs/ +edit_uri: edit/dev/docs/ + +copyright: Trio Community + +theme: + name: material + language: en + custom_dir: overrides + logo: assets/images/trio-logo.png + favicon: assets/images/favicon.ico + icon: + repo: fontawesome/brands/github + palette: + # Palette toggle for automatic mode + - media: "(prefers-color-scheme)" + primary: deep purple + accent: light blue + toggle: + icon: material/weather-sunny + name: Switch to light mode + # Palette toggle for light mode + - media: "(prefers-color-scheme: light)" + scheme: default + primary: deep purple + accent: light blue + toggle: + icon: material/weather-night + name: Switch to dark mode + # Palette toggle for dark mode + - media: "(prefers-color-scheme: dark)" + scheme: slate + primary: deep purple + accent: light blue + toggle: + icon: material/brightness-auto + name: Switch to auto (use System Preferences) + + features: + - announce.dismiss + - content.action.edit + - content.code.copy + - content.tabs.link + - navigation.footer + - navigation.instant + - navigation.instant.progress + - navigation.prune + - navigation.sections + - navigation.tabs + - navigation.tabs.sticky + - navigation.top + - navigation.tracking + - search.suggest + - search.highlight + - toc.follow + +plugins: + - open-in-new-tab + - macros: + include_dir: . + - exporter: + formats: + pdf: + enabled: !ENV [MKDOCS_EXPORTER_PDF, false] + concurrency: 16 + stylesheets: + - docs/assets/stylesheets/pdf.scss + covers: + front: docs/assets/templates/covers/front.html.j2 + # back: docs/assets/templates/covers/back.html.j2 + aggregator: + enabled: true + output: trio-docs.pdf + covers: limits + buttons: + - title: Download Page as PDF + icon: material-file-download-outline + enabled: !!python/name:mkdocs_exporter.formats.pdf.buttons.download.enabled + attributes: !!python/name:mkdocs_exporter.formats.pdf.buttons.download.attributes + - search + +extra_css: + - assets/stylesheets/primary_color.css + - assets/stylesheets/extra.css + +extra_javascript: + - assets/javascripts/mathjax.js + - assets/javascripts/mkdocs-exporter.js + - https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js + - https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.9.1/mermaid.min.js + +# Customizations +extra: + social: + - icon: fontawesome/brands/github + link: https://github.com/nightscout/trio-docs + name: Trio on GitHub + - icon: fontawesome/brands/discord + link: https://discord.gg/FnwFEFUwXE + name: Trio on Discord + - icon: fontawesome/brands/facebook + link: https://www.facebook.com/groups/diytrio + name: Trio on Facebook + version: 0.2.1 + +markdown_extensions: + - admonition + - attr_list + - def_list + - pymdownx.arithmatex: + generic: true + - pymdownx.details + - pymdownx.emoji: + emoji_index: !!python/name:material.extensions.emoji.twemoji + emoji_generator: !!python/name:material.extensions.emoji.to_svg + options: + custom_icons: + - overrides/.icons + - pymdownx.highlight: + anchor_linenums: true + line_spans: __span + pygments_lang_class: true + - pymdownx.inlinehilite + - pymdownx.keys + - pymdownx.smartsymbols + - pymdownx.superfences: + custom_fences: + - name: mermaid + class: mermaid + format: !!python/name:pymdownx.superfences.fence_code_format + - pymdownx.tabbed: + alternate_style: true + - tables + - toc: + permalink: true + permalink_title: Link to this section for reference + title: On this Page + toc_depth: 3 + +validation: + nav: + omitted_files: info + not_found: warn + absolute_links: info + links: + not_found: warn + absolute_links: info + unrecognized_links: info + +not_in_nav: | + Analyze/EvaluateBasal.md + Analyze/EvaluateCR.md + Getting-Started/cgm.md + settings/loop.md + settings/configuration/preferences/statistics.md + settings/devices/pump.md + +# Navigation (Page tree) +nav: + - Home: ./index.md + - Overview: + - Introduction: ./Getting-Started/Overview.md + - App Overview: ./operate/interface.md + - New User Guide: ./Setup/New-User-Setup.md + - Coming from Other AID Systems: ./Configuration/transition-qa.md + - Common Issues: ./operate/troubleshoot.md + - Device Compatibility: + - iPhones & Watches: ./Getting-Started/iphone.md + - Pumps: ./Getting-Started/pump.md + - CGMs: ./settings/devices/cgm.md + - Build/Update Trio: + - Build Instructions: ./operate/build.md + - Customizations: ./operate/customize.md + - User Settings: + - Trio Main Preferences: ./settings/configuration/preferences/trio.md + - Pump, CGM, Watch: ./Configuration/Devices.md + - Additional Pump Settings: ./settings/configuration/pumpsettings.md + - Basal: ./settings/configuration/basalprofile.md + - ISF: ./settings/configuration/insulinsensitivities.md + - CR: ./settings/configuration/carbratios.md + - Target Glucose: ./settings/configuration/targetglucose.md + - Main Settings: ./settings/configuration/preferences/mainsettings.md + - SMB & UAM: ./settings/configuration/concepts/smb-uam.md + - Close the Loop: ./Configuration/Configure.md + - Optional Settings: + - Apple Health: ./settings/services/applehealth.md + - FPU: ./settings/services/fatprotein.md + - Nightscout: ./settings/services/nightscout.md + - Notifications: ./settings/services/notifications.md + - SMB Settings: ./settings/configuration/preferences/smbsettings.md + - Temp Targets: ./operate/temptarget.md + - Advanced Settings: + - Autotune: ./settings/configuration/autotune.md + - Dynamic Settings: ./settings/configuration/concepts/autosens-dynamic.md + - Sigmoid: ./settings/configuration/concepts/sigmoid.md + - Dynamic Settings Explained: ./settings/configuration/preferences/dynamicsettings.md + - Other Settings: ./settings/configuration/preferences/othersettings.md + - Sensitivity Settings: ./settings/configuration/preferences/targetsettings.md + - Resources: + - Citations: ./resources/citations.md + - Translation: ./resources/translate.md + - TrioDocs PDF: ./trio-docs.pdf diff --git a/overrides/404.html b/overrides/404.html new file mode 100644 index 00000000..bf3b122a --- /dev/null +++ b/overrides/404.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} + +{% block content %} + +
+
+

404

+

{% trans %}Page not found{% endtrans %}

+

{% trans %}You can use the navigation menu (☰), or the search box (🔍) to find what you are looking for.{% endtrans %}

+
+
+ +{% endblock %} diff --git a/requirements.in b/requirements.in new file mode 100644 index 00000000..b412d4b0 --- /dev/null +++ b/requirements.in @@ -0,0 +1,7 @@ +mkdocs>=1.6.1 +mkdocs-exporter==6.1.1 +mkdocs-material>=9.5.9 +mkdocs-include-markdown-plugin>=6.0.4 +mkdocs-exclude>=1.0.2 +mkdocs-open-in-new-tab==1.0.6 +mkdocs-macros-plugin>=1.0.4 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..36cc9c6d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,48 @@ +babel==2.16.0 +beautifulsoup4==4.12.3 +bracex==2.5.post1 +certifi==2024.8.30 +charset-normalizer==3.4.0 +click==8.1.7 +colorama==0.4.6 +ghp-import==2.1.0 +greenlet==3.0.3 +hjson==3.1.0 +idna==3.10 +Jinja2==3.1.4 +libsass==0.23.0 +lxml==5.3.0 +Markdown==3.7 +MarkupSafe==3.0.1 +mergedeep==1.3.4 +mkdocs==1.6.1 +mkdocs-exclude==1.0.2 +mkdocs-exporter==6.1.1 +mkdocs-get-deps==0.2.0 +mkdocs-include-markdown-plugin==6.2.2 +mkdocs-macros-plugin==1.3.5 +mkdocs-material==9.5.40 +mkdocs-material-extensions==1.3.1 +mkdocs-open-in-new-tab==1.0.6 +packaging==24.1 +paginate==0.5.7 +pathspec==0.12.1 +platformdirs==4.3.6 +playwright==1.47.0 +pyee==12.0.0 +Pygments==2.18.0 +pymdown-extensions==10.11.2 +pypdf==5.0.1 +python-dateutil==2.9.0.post0 +PyYAML==6.0.2 +pyyaml_env_tag==0.1 +regex==2024.9.11 +requests==2.32.3 +six==1.16.0 +soupsieve==2.6 +super_collections==0.5.3 +termcolor==2.5.0 +typing_extensions==4.12.2 +urllib3==2.2.3 +watchdog==5.0.3 +wcmatch==10.0 diff --git a/utils/deleteAllRedirects.py b/utils/deleteAllRedirects.py new file mode 100644 index 00000000..c141d8f8 --- /dev/null +++ b/utils/deleteAllRedirects.py @@ -0,0 +1,58 @@ +import requests +import json +import time +import sys +import re + +PROJECT = 'androidaps' +URL = 'https://readthedocs.org/api/v3/projects/' + PROJECT + '/redirects/' +TOKEN = len(sys.argv) == 2 and sys.argv[1] +HEADERS = {'Authorization': f'token {TOKEN}'} + +def delItem (url) : + delResponse = requests.delete(url, headers=HEADERS) + if delResponse.status_code == 204 : + print('removed ' + url) + elif delResponse.status_code == 429: + detail = delResponse.json()['detail'] + wait = int(re.search(r'\d+', detail).group()) + print('Throttled, wait for ' + str(wait + 1) + ' seconds') + time.sleep(wait + 1) + delItem(url) + else : + results = delResponse.json() + print(results) + +def deleteList() : + response = requests.get(URL, headers=HEADERS) + listResult = response.json() + + if response.status_code == 200: + redirects = listResult['results'] + for redirect in redirects : + url = redirect['_links']['_self'] + delItem(url) + return listResult['count'] + elif response.status_code == 429: + detail = response.json()['detail'] + wait = int(re.search(r'\d+', detail).group()) + print('Throttled, wait for ' + str(wait + 1) + ' seconds') + time.sleep(wait + 1) + deleteList() + else : + print('ERROR code:', response.status_code, listResult) + return 0 + +def main() : + while True: + count = deleteList() + print('Removed, still counting: ' + str(count)) + if count == 0 : + break + print('done') + +if not TOKEN : + print('Please provide a API token as parameter') + print('useage: $ python deleteAllRedirects.py ') +else : + main() diff --git a/utils/generateRedirects.py b/utils/generateRedirects.py new file mode 100644 index 00000000..dbe05d11 --- /dev/null +++ b/utils/generateRedirects.py @@ -0,0 +1,38 @@ +import os +import json + +FILE = 'redirect.json' + +dir_path = os.path.dirname(os.path.realpath(__file__)) +language_path = os.path.join(dir_path, '..\\', 'docs', 'CROWDIN') + '\\' +print('Generate redirect for al .md and .rst files in path ' + language_path) + +redirects = [] + +class Object: + def toJSON(self): + return json.dumps(self, default=lambda o: o.__dict__, + sort_keys=True, indent=4) + +for path, subdirs, files in os.walk(language_path): + for filename in files: + if filename.endswith(('.md', '.rst')): + file = os.path.splitext(os.path.join(path, filename))[0] + '.html' + relative_file = file[len(language_path):] + original = '\\' + os.path.join('en', 'latest', 'CROWDIN', relative_file) + to = '\\' + os.path.join(relative_file[:2], 'latest', relative_file[3:]) + r = Object() + r.from_url = original.replace('\\', '/') + r.to_url = to.replace('\\', '/') + r.type = 'exact' + redirects.append(r) + +def obj_dict(obj): + return obj.__dict__ + +json_object = json.dumps(redirects, indent=4, default=obj_dict) + +with open(FILE, 'w') as outfile: + outfile.write(json_object) + +print('Done, ' + str(len(redirects)) + ' results are stored in ' + FILE) diff --git a/utils/importRedirects.py b/utils/importRedirects.py new file mode 100644 index 00000000..fc89dff0 --- /dev/null +++ b/utils/importRedirects.py @@ -0,0 +1,46 @@ +import requests +import json +import time +import sys +import re + +PROJECT = 'androidaps' +URL = 'https://readthedocs.org/api/v3/projects/' + PROJECT + '/redirects/' +TOKEN = len(sys.argv) == 2 and sys.argv[1] +HEADERS = {'Authorization': f'token {TOKEN}'} +FILE = 'redirect.json' + +def create(redirect, index) : + response = requests.post( + URL, + json=redirect, + headers=HEADERS, + ) + if response.status_code == 201 : + print ('create redirect (' + str(index) + ') ' + redirect['from_url']) + elif response.status_code == 429: + detail = response.json()['detail'] + wait = int(re.search(r'\d+', detail).group()) + print('Throttled, wait for ' + str(wait + 1) + ' seconds ') + time.sleep(wait + 1) + create(redirect, index) + else : + print(response.status_code , response.json()) + +def main(): + try: + with open(FILE) as json_file: + redirects = json.load(json_file) + print('Creating ' + str(len(redirects)) + ' redirects ') + for index, redirect in enumerate(redirects): + create(redirect, index) + print ('done') + except IOError: + print('File ' + FILE + ' is not accessible, please make sure you run the "generateRedirect" script') + + +if not TOKEN : + print('Please provide a API token as parameter') + print('useage: $ python importRedirects.py ') +else : + main() diff --git a/utils/readme.md b/utils/readme.md new file mode 100644 index 00000000..468aca1c --- /dev/null +++ b/utils/readme.md @@ -0,0 +1,48 @@ +# Redirect +These redirect scripts are created to facilitate language split of the projects. + +The standard user defined redirects are not capable to redirect into another language or project. +https://docs.readthedocs.io/en/stable/user-defined-redirects.html + +We can use the public API to create the redirects. + +## Redirects + +`/en/latest/CROWDIN//*` will be redirected `/cs/latest/*` + +Example: + +`/en/latest/CROWDIN/cs/index.html` => `/cs/latest/index.html` + +## Scripts + +### Generate Redirects + +Generate a list of redirects. For each page in the CROWDIN folder a redirect is generated and stored in a `redirect.json` file. + +``` console +$ python generateRedirects.py +``` + +### Import Redirects + +This script loads the `redirect.json` and calls for each record the readthedocs API +https://docs.readthedocs.io/en/stable/api/v3.html#redirects + +Note that the API is limited in throughput and will be throttled, and the script will take some time to complete. + +The API token can be generated in the GUI and should be passed as a parameter. +https://docs.readthedocs.io/en/stable/api/v3.html#token + +``` console +$ python importRedirects.py +``` + +### Import Redirects + +This script removes all redirect from the project. The script could be used for testing or maintenance. +**NOTE: this script will remove all redirects, including the ones that are manual added trough the GUI. + +``` console +$ python deleteAllRedirects.py +```