Commit Graph

1418 Commits

Author SHA1 Message Date
Johan Degraeve e54bfa3082 suppress treatments sync if nightscout schedule says off
If nightscout schedule is currently set to off, then don't sync treatments (to save battery)
except if app is in foreground
2022-07-21 13:35:26 +02:00
Johan Degraeve e9f6f08fc1 call cgmTransmitterInfoChanged only if blePeripheral is the active cgm transmitter
it's possible to create multiple cgm transmitters (eg a Libre 2 and a dexcom) but only one can be active, ie connected.
But one could go to the settings for the non-active CGM, and change the setting 'Use Transmitter algorithm'.
In that case, the setting was changed also for the active CGM, causing incorrect status.

this is fixed now
haha
2022-07-13 00:01:38 +02:00
Johan Degraeve 10cfcdb929 cleanup blePeripherals that have no type assigned, at startuyp
seems some blePeripherals remain in coredata without a type being assigned. Probably happens while scanning for a new device.

those are now cleaned up at app start
2022-07-12 22:58:47 +02:00
Johan Degraeve f04a9284a8 minor trace clean up 2022-07-12 16:54:16 +02:00
Johan Degraeve 3f2a021a51 Option to define loopDelay dependent on the time of day
loopDelay means that readings shared with Loop will be shifted forward with a predefined amount of minutes. Example : a reading that is for instance created at 15:00, to which a delay is applied of 5 minutes, then Loop will receive that reading at 15:05, while at 15:00, Loop will receive the reading that was created at 14:55.
This is only useful when used in combination with smoothing. Advantage is that readings that Loop will receive are more efficiently smoothed

- new setting is available in the Developer settings
- used SwiftUI to define a new View that allows to create loopDelays
- colors used in SwiftUI code are defined in Constants/ConstantsUI.swift

- deployment target increased from 12.0 to 13.0
- String extension getSchedule renamed to splitToInt
2022-07-11 18:15:28 +02:00
Johan Degraeve d764760e52 small fix in translations 2022-06-24 21:35:03 +02:00
Johan Degraeve aaabd04bdf Merge branch 'fixiOSVolumeTest' into develop 2022-06-23 19:21:22 +02:00
Paul Plant 87a36da32d prevent future BG checks being added
- if the user tries to add a new (or modify an existing) BG check and set it's date in the future, warn them that it is not allowed and set the date to now.
- this is a safety feature for APS system that can use BG checks as part of their prediction as well as CGM values
2022-06-23 17:33:07 +02:00
Paul Plant c816e307db Merge branch 'develop' into treatments-filters 2022-06-23 16:26:00 +02:00
Paul Plant 327a609aa5 implement treatment filtering in list
- the different treatment types (insulin, carbs, BG checks) can be filtered if required to show/hide them in the treatment table
- if boluses are shown, an option to filter micro-boluses is also enabled.
- button icon images are set individually as filled/unfilled to more clearly show if they are selected
- .getTreatments call reduced from 100 days to 21 days to save overhead
- previous settings options to show micro-boluses in the treatments table (and associated translations) removed as no longer needed
2022-06-23 16:21:59 +02:00
Johan Degraeve c02a4e117e suppress unlockPayload and suppress share readings
fix #362

- suppress sending unlockPayload : only for Libre 2. This allows to run/connect several apps to Libre 2
- suppress share readings with Loop : useful if more than one app (eg more than one instance of xDrip4iOS) run in parallel, to ensure only one instance stores readings in shared user defaults
- additonally, minor change in comments
- minor change in comments for LoopDelay
2022-06-23 07:23:25 +02:00
Johan Degraeve 498c454522
Merge pull request #363 from paulplant/mini-chart
Mini chart implementation
2022-06-21 20:18:33 +02:00
Paul Plant 3aa66d3ea6 Clean up GlucoseMiniChartManager
clean up old code that was commented out
2022-06-21 17:01:59 +02:00
Paul Plant 6e12461334 use unfilled lock icon if locked with value long press 2022-06-21 17:00:53 +02:00
Paul Plant e6d0861b08 fix speech "trending flat" bug 2022-06-21 16:20:56 +02:00
Paul Plant d247859716 mini-chart midnight marker(s) added for context
- any date range over 24 hours is now always displayed in days
2022-06-19 10:47:27 +02:00
Paul Plant 53432ced58 show/hide mini-chart with lock screen 2022-06-19 09:51:37 +02:00
Paul Plant 7cd23589e4 extra ranges for mini-chart
- added extra ranges to allow 24hr/48hr/3d and 7d options
- time period selected is now always shown but faded out
- when double tapped, the range changes to the next one and the label is turned white and then faded back out
2022-06-18 14:17:16 +02:00
Johan Degraeve a80a128b63 fix bug : Volume test iOS sound
wasn't working anymore, seems since iOS 14, see https://stackoverflow.com/questions/69023854/ios-15-notification-sounds-are-not-playing-for-foreground-notifications and https://developer.apple.com/forums/thread/700884 ("Displaying" sound only notifications is no longer possible.)

The solution is
- to add a dummy text and body in the test notification
- to add .list if iOS 14 or higher
2022-06-18 00:12:09 +02:00
Paul Plant 34bae76168 mini-chart initial implementation
This uses a new glucoseMiniGlucoseChart object to display a static 24hr or 48hr mini-chart beneath the main chart.
- simplified to display only glucose chart points with all axiis, guidelines and labels hidden.
- it will update every time new glucose readings are processed
- a double tap will toggle between 24hr and 48hr modes (default 24hrs)
- by default the mini-chart will be hidden (upon first ever launch) for users with "Zoomed Display" enabled. Otherwise, the mini-chart will be shown by default.
- as above but same logic also applied to the statistics view for first launch
- home screen settings menu edited to add option
- observer added to hide/show the chart after settings change and also to redraw the chart after hours are toggled by double tap
2022-06-17 17:48:06 +02:00
Johan Degraeve 48ee34a9bd version 4.10.3 build 4179 2022-06-15 22:30:44 +02:00
Johan Degraeve aac17aae0d fix bug : avoid crash in TreatmentsViewController when iOS 13 is not available 2022-06-12 23:37:19 +02:00
Johan Degraeve c580416e62 fix bug, no upload new readings after Internet failure
The bug was that after restore of failed Internet connection, new readings are not uploaded to NS.

- as mentioned in the comments of func uploadData(dataToUpload: Any, httpMethod: String?, path: String, completionHandler: (() -> ())?)
completionhandler should be called only when upload was successful.
But the result of the upload was never checked. So probably, in some error cases, completionhandler was called with success. As a result, the upload was considered as successful and not redone when internet comes back

- also some updates in func uploadDataAndGetResponse. Set nightScoutResult to .failed when there was an error.
2022-06-12 23:31:50 +02:00
eduardopietre 7a263e8326 Optimized GlucoseChartManager getTreatmentEntryChartPoints.
Optimized getTreatmentEntryChartPoints to run faster.

- Previously, getTreatmentEntryChartPoints was generating lag and spikes of CPU usage.
- The code was optimized by reducing the amount of calls to getBgReadings.
- Now getBgReadings is only called once inside getTreatmentEntryChartPoints.
- Now calculateClosestYAxisValues interpolates the SGV value from the two closest bgReadings, if there are. 
- Profiling registered a speed up of 500%.
2022-06-12 17:46:25 -03:00
Paul Plant 7a801a484e Update TreatmentsViewController.swift
add a disclosure indicator to each cell row to indicate to the user that they can click to edit the treatment
2022-06-05 20:57:47 +02:00
Paul Plant a4b8e67ff1 user locale implemented for all UI date and time displays
- chart hour axis label and scroll back timestamp will be shown in user locale
- treatment list time will be shown in user locale
- snooze screen times and dates will be shown in user locale
- BLE peripherals dates and times will be shown in user locale
- alarm dates and times will be shown in user locale
- landscape view date will be shown in user locale
- small improvements to layout of alarms screen
- schema updated to include location and allow region changes in simulator/debug
2022-06-05 20:54:24 +02:00
Johan Degraeve f27b691c1d
Merge pull request #359 from eduardopietre/develop
DataExporter improvements and progress bar.
2022-06-04 21:12:59 +02:00
eduardopietre 21788ac058 Improved DataExportation speed and added a loading bar.
- Date.fromISOString and Date.ISOStringFromDate now have an overload that accepts an optional reusableDateFormatter.

- ISODateFormatter unified between Date.fromISOString and Date.ISOStringFromDate and extracted to another func, Date.ISODateFormatter.

- BgReading dictionaryRepresentationForNightScoutUpload was a variable while the thing with same name at TreatmentEntry was a func. Now both are functions and accept an optional reuseDateFormatter as argument.

- Deleted dictionaryRepresentationForNightScoutUpload.swift.

- Implemented a progress bar named ProgressBarViewController and a struct used for updating it: ProgressBarStatus.

- SettingsSelectedRowAction callFunctionAndShareFile now updates the progress bar with each callback.

- DataExporter now reuses the same DateFormatter, speeding up the calls to dictionaryRepresentationForNightScoutUpload.

- DataExporter now receives the callback as argument at instantiation.

- DataExporter calls the callback to report progress during readingsAsDicts().
2022-06-01 20:54:20 -03:00
Johan Degraeve 0f71c6addd add strings to be translated, for all languages 2022-05-31 23:49:54 +02:00
Johan Degraeve 5d76d3c6a8 Add Ukranian language, needs translation 2022-05-31 23:42:51 +02:00
Johan Degraeve cb9e0b24dd LoopManager : allow Loop to fill up gaps of max 30 minutes
reduce timeStampLatestLoopSharedBgReading with 30 minutes. Because maybe Loop wasn't running for a while and so missed one or more readings. By adding 30 minutes of readings, we fill up a gap of maximum 30 minutes in Loop
2022-05-31 23:01:36 +02:00
Johan Degraeve ff780b482b
Merge pull request #358 from paulplant/data-export-changes
data export filename changes + text stings + settings menu + ES trans…
2022-05-31 22:33:17 +02:00
Paul Plant b67c212d8a data export filename changes + text stings + settings menu + ES translation 2022-05-31 15:51:37 +02:00
Johan Degraeve 45c189a87c
Merge pull request #353 from paulplant/additional_treatments
implement BG Check treatments + layout improvements
2022-05-30 22:22:36 +02:00
Johan Degraeve e2dd0f7f3f LoopManager : timeStampLatestLoopSharedBgReading is now assigned correct value in case Loopdelay is used
- also small improvement in case loopdelay = 0, add 5 seconds to timeStampLatestLoopSharedBgReading to avoid storing values that were already stored previously
2022-05-30 22:15:49 +02:00
Johan Degraeve 71f5831cc6 fix #357 - 12 hour snooze 2022-05-30 21:16:06 +02:00
Paul Plant 546408f854 housekeeping - remove redundant code
these public constants are not needed any more as BG Check values are now always stored in NS as mg/dl to prevent upload/download sync issues
2022-05-30 11:43:52 +02:00
Paul Plant dc43dacaee moved UIKit-dependant functions out of TreatmentEntry+CoreDataClass and into TreatmentTableViewCell 2022-05-30 11:41:40 +02:00
Paul Plant 1ef321fce4 treatment text corrections + auto text size 2022-05-30 10:01:40 +02:00
Paul Plant 39d2889604 treatment table + entry auto-layout corrections 2022-05-29 14:19:29 +02:00
Johan Degraeve aa2c1e7edf Loop delay : small fix
"from" field is used in freeaps. This is fix is only applicable to dev setting called "loopdelay"
2022-05-28 23:13:05 +02:00
Paul Plant f0d65ae0db update to mmol NS handling of BG Checks (clarification) 2022-05-23 18:23:53 +02:00
Paul Plant 57db5cd0fd correction to BG Check mmol unit handling during NS sync 2022-05-23 16:38:32 +02:00
Paul Plant 18bfd57f91 observer added to refresh treatments table when the micro-bolus threshold is changed 2022-05-23 11:02:01 +02:00
Paul Plant efe40c5872 Micro-bolus text EN string correction 2022-05-20 20:45:05 +02:00
Paul Plant 917a4432be improve handling of micro-bolus treatments
- micro-boluses can be hidden from the main chart
- micro-boluses can be excluded/hidden from the main treatment screen/list
2022-05-20 19:51:19 +02:00
Paul Plant 3d969db6fa improvements to treatments table layout 2022-05-20 19:13:42 +02:00
Paul Plant dd55733c0d BG Check treatments - initial translations 2022-05-20 14:52:38 +02:00
Paul Plant 87d2ae296f implement BG Check treatments
- BG Checks (finger prick) can be entered as a treatment
- will be converted and stored in coredata as mg/dl (to avoid having to add units to the treatment coredata model)
- will be converted and shown locally in the correct unit
- will be synced with Nightscout in the original unit
- Nightscout uploads will add the "GlucoseType"="Finger" and "units" attributes to align with BG checks entered via Care Portal.
- BG checks displayed on the main chart as a red circle with gray border as per Nightscout style
- observer added to refresh treatment table (values/units) if the bg unit is changed by the user
2022-05-20 13:22:33 +02:00
Johan Degraeve 22cfd4f850 DataExport : run on background thread
this change runs the generation of export file on a background thread, which ensures that readings are still received while exporting
2022-05-19 23:54:26 +02:00
Johan Degraeve 5fdf6b5117 LoopManager : add 5 seconds to timestamp last reading + tracing
- add 5 seconds to last Readings timestamp, because due to the way timestamp for libre readings is calculated, it may happen that the same reading shifts 1 or 2 seconds in next reading cycle
- add tracing, can be deleted later on
2022-05-19 23:54:20 +02:00
eduardopietre 75ec8e89da CallFunctionAndShareFile now displays a loading icon (ActivityIndicatorViewController). 2022-05-13 14:39:39 -03:00
eduardopietre c9d63fd399 DataExporter now correctly uses privateManagedObjectContext. 2022-05-13 14:39:07 -03:00
eduardopietre a634d08e5a Data exportation now sorts the JSON keys. 2022-05-11 15:47:14 -03:00
eduardopietre 9817210d66 Merge remote-tracking branch 'origin/develop' into develop 2022-05-11 15:26:56 -03:00
Johan Degraeve 08f827d1e3 Artificial delay in readings when sending to Loop
Libre transmitteris tend to show erratic values. Smoothing improves those values a lot but only for historic values, not for the most recent values.
To avoid that Loop takes actions based on those wrong values, this new option allows to introduce a delay. Most recent values will not be shown. Older values will shift in timestamp. To Loop it will look as if this is the most recent value. Advantage is that values used by Loop will be more reliable, but running a number of minutes behind the real values.

New setting in development section. Only to be used for developers.
2022-05-10 23:08:54 +02:00
eduardopietre 31c9d942ff Added traces to DataExporter. 2022-05-08 19:31:51 -03:00
eduardopietre f3ce6d7c57 Merge remote-tracking branch 'origin/develop' into develop 2022-05-08 19:24:03 -03:00
eduardopietre 1ff963799c Added comments to SettingsViewHousekeeperSettingsViewModel. 2022-05-08 19:22:32 -03:00
eduardopietre 3184affe76 Initial implementation of export data as JSON. 2022-05-08 19:16:42 -03:00
eduardopietre 7c1a4efa84 Created callFunctionAndShareFile at SettingsSelectedRowAction.
Created and implemented a new SettingsSelectedRowAction: callFunctionAndShareFile.
2022-05-08 12:48:11 -03:00
Paul Plant 5530948fa5
Merge branch 'JohanDegraeve:develop' into develop 2022-05-08 13:14:46 +02:00
Paul Plant a7d374df50 housekeeping - G5 transmitter check correction 2022-05-08 13:12:55 +02:00
eduardopietre 22bba1c37e Implemented data exporting. 2022-05-07 21:15:40 -03:00
eduardopietre 0defd2d6ce Housekeeping retention period can now be set in settings. 2022-05-07 20:20:39 -03:00
Johan Degraeve 64178a9a8a version 4.10.2 - build 4178 2022-05-06 13:41:09 +02:00
Paul Plant 342e9d63b1
Merge branch 'JohanDegraeve:develop' into develop 2022-05-06 10:41:09 +02:00
Paul Plant 110c0b69ae fix timezone error when working in 12hr clock mode (am/pm) 2022-05-06 10:40:48 +02:00
Johan Degraeve 9cbbe35221 Fix for deletion of treatments at NS
Bug was introduced by a previous commit
2022-05-04 16:53:33 +02:00
Johan Degraeve 287dcb97a1 Follower should be able to download treatments, even if token or api-secret is not set
- this was changed previous commit while fixing a crash issue, but change was not necessary
2022-05-03 22:55:59 +02:00
Johan Degraeve 64687d96ab version 4.10.1 - build 4177 2022-05-02 23:46:02 +02:00
Johan Degraeve 37111da537 Merge branch 'develop' of https://github.com/JohanDegraeve/xdripswift into develop 2022-05-02 23:36:45 +02:00
Johan Degraeve 3109a2f555 Fix crash in treatment when NS is not enabled, or treatment is not yet uploaded
- in function syncTreatmentsWithNightScout, first check that nightscout is enabled and nightscout url != nil
- before splitting id by '-', check first that id is not an empty string
2022-05-02 23:36:38 +02:00
Samuli Tamminen 84e529587c Add a Quick Action for toggling Speak Readings
Speak Readings setting can now be quickly accessed from home screen by long-pressing the app icon.
2022-05-01 13:59:27 +03:00
Johan Degraeve f487db5712 version 4.10.0 build 4176 2022-04-30 21:49:07 +02:00
Paul Plant 131fdc10f6 Treatment table UI update 2022-04-30 17:20:30 +02:00
Paul Plant e946889aaa Ignore invalid inputs to the treatments textfields to ensure that the original treatment isn't just deleted 2022-04-30 17:00:56 +02:00
Johan Degraeve e7f0b9e91a
Merge pull request #344 from paulplant/develop
prevent insulin unit fractions from being deleted in some locales
2022-04-30 13:28:56 +02:00
Paul Plant bba7d7aae5 prevent insulin unit fractions from being deleted in some locales 2022-04-30 11:55:49 +02:00
Johan Degraeve 7c5f20af5d treatments : delete treatments older than 90 days
deletion is done at app start up.
If user would go to treatments screen very fastly, after starting the app, then it may crash (only once). But that's probably not going to happen frequently
2022-04-30 11:36:33 +02:00
Paul Plant 233d0ff710 remove unwrapping of created_at as not needed 2022-04-29 23:57:56 +02:00
Paul Plant 9b4ffd8431 Adjust bolus triangle height scale to make them less "pointy"
Yes... I really did just write the work "pointy" in a commit message. :)
2022-04-29 21:26:49 +02:00
Paul Plant c6d4ac5c14 treatment label background and spacing to improve visibility 2022-04-29 21:14:59 +02:00
Paul Plant d62ef7ef52 Compatibility for AndroidAPS-populated Nightscout sites
AndroidAPS uploads "created_at" key pairs without milliseconds. We need to check if this is the case in order to convert correctly the date string.
2022-04-29 21:03:32 +02:00
Johan Degraeve f9e5d7a7e8 treatments : download 24 hours of treatments 2022-04-28 23:43:09 +02:00
Paul Plant dd25cd78e2 Nightscout follower now syncs every 15s and sync button removed from treatments screen 2022-04-28 20:09:23 +02:00
Johan Degraeve 9b9fcef5ba initiate treatments sync, every 15 seconds, if app is in foreground 2022-04-27 23:23:46 +02:00
Johan Degraeve ec58fd4787 treatment values with decimal : replace , by .
to support keyboards with , in stead of . as decimal
2022-04-26 21:40:21 +02:00
Johan Degraeve 4c4a39904c Merge branch 'libreproh' into develop 2022-04-26 20:46:26 +02:00
Johan Degraeve eb1e2d5056 trigger treatments sync each time there's a new reading
by setting UserDefaults.standard.nightScoutSyncTreatmentsRequired = true, a treatments sync is triggered
This is now done when initiating readings upload
In case of Libre 2, this is every minute, even though there's an upload only once every minute
Upload of new readings and sync of treatments is done simultaneously
2022-04-25 23:18:23 +02:00
Johan Degraeve 8f56397159 Merge branch 'develop' of https://github.com/JohanDegraeve/xdripswift into develop 2022-04-25 21:47:46 +02:00
Johan Degraeve 648dcfa28e trigger treatments sync every 5 minutes in follower mode
by setting UserDefaults.standard.nightScoutSyncTreatmentsRequired = true a treatments sync is triggered
This is now done when initiating download of readings.
Download of new readings and sync of treatments is done simultaneously
2022-04-25 21:47:40 +02:00
Johan Degraeve e917ac4bb4
Merge pull request #341 from paulplant/treatments_add_new_improvements
add treatments screen improvements
2022-04-25 21:00:57 +02:00
Paul Plant c3aba81cb2 add treatments screen improvements
- use .decimalPad keyboard for insulin entries
- change "New Entry" to "New Treatment" as the idea of a Treatment "Entry" is not intuitive to most users
- minor IB layout changes to enable future new treatment types to fit easily
2022-04-25 18:45:56 +02:00
Johan Degraeve 2cfdd9a40f libreproh support 2022-04-24 23:37:22 +02:00
Johan Degraeve 43cb5fa019
Merge pull request #340 from diabetlum/develop
Develop
2022-04-23 23:53:18 +02:00
Johan Degraeve 4f22c118dd added missing strings to translate (done with script findMissingStrings) 2022-04-12 21:28:55 +02:00
Johan Degraeve 622fcb30f1 Danish : folders added. Still need translation 2022-04-12 20:18:25 +02:00
Johan Degraeve 1c1c36e54f Merge branch 'loopheartbeat' into develop 2022-04-12 15:17:44 +02:00
Johan Degraeve d85d5235c3 treatments: udpate chart in home screen if there's an update done in NightScout sync 2022-04-11 20:50:50 +02:00