Skip to content

Commit

Permalink
Release 4.6.0 Artificial-Pancreas#764
Browse files Browse the repository at this point in the history
**UI finishes**
1. Resolves issues with not displaying rounding corners of the TIR and Loop BarMark Charts. These charts are now looking prettier.
2. Remove the history button (less crowded now), as this is no longer needed in current UI/UX implementation. You can access the history by tapping the main Chart, as before.
Increase the Apple symbol image size.

**New UI updates**
1. New Mini glucose chart added to the Home View. Displayed when scrolling down to always see both the status header View and the glucose past 24 hours.

img_3_1720469231268

2. Total insulin since start of day now displayed in pump history data table, together with the previous Total insulin 24 hours (or the hours existing with pump data).

image

**New features**
1. Read the current active profile (override) preset name in middleware.
2. Added a post Ore0 layer and integrated it into the middleware function, making it possible to enact a basal rate from middleware. 1 and 2 can of course be combined in middleware, enacting a basal rate when using a certain preset.

To enable basal rate in middleware: profile.set_basal = true
To enact the basal rate (only if set to true) to 2U/h: profile.set_basal = 2

This will override the Oref0 suggestion and enact a new Basal rate. Use cases are numerous, but requested for use when doing prolonged exercises.

image

3. Add carbs, fat and protein using the iAPS meal presets with iOS shortcuts. For instance: When waking up enable a morning profile override and add two coffees and a breakfast to iAPS.

**Resolved issues**
1. Out of bonds issue (found with iOS 18 simulator with Xcode beta2).

**Miscellaneous**
1. Add methods for using some iOS 17 - required functions in Swift.

**Translations**
New translations from the Crowdin translators:
Micheline Tasseron, Hung Nguyen Phuteleco and David de Tommasi
  • Loading branch information
Jon-b-m authored Jul 8, 2024
1 parent 2384902 commit d069246
Show file tree
Hide file tree
Showing 57 changed files with 856 additions and 187 deletions.
2 changes: 1 addition & 1 deletion Config.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
APP_DISPLAY_NAME = iAPS
APP_VERSION = 4.4.1
APP_VERSION = 4.6.0
APP_BUILD_NUMBER = 1
COPYRIGHT_NOTICE =
DEVELOPER_TEAM = ##TEAM_ID##
Expand Down
132 changes: 75 additions & 57 deletions FreeAPS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions FreeAPS/Resources/javascript/prepare/determine-basal.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ function generate(iob, currenttemp, glucose, profile, autosens = null, meal = nu
}
var glucose_status = freeaps_glucoseGetLast(glucose);

// In case Basal Rate been set in midleware
if (profile.set_basal && profile.basal_rate) {
console.log("Basal Rate set by middleware to " + profile.basal_rate + " U/h.");
}

return freeaps_determineBasal(glucose_status, currenttemp, iob, profile, autosens_data, meal_data, freeaps_basalSetTemp, microbolusAllowed, reservoir_data, clock);
}

Expand Down
4 changes: 4 additions & 0 deletions FreeAPS/Resources/javascript/prepare/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ function generate(pumpsettings_data, bgtargets_data, isf_data, basalprofile_data
}

var tdd_factor = { };
var set_basal = false;
var basal_rate = { };

var inputs = { };
//add all preferences to the inputs
Expand All @@ -108,6 +110,8 @@ function generate(pumpsettings_data, bgtargets_data, isf_data, basalprofile_data
inputs.model = model_data;
inputs.autotune = autotune_data;
inputs.tddFactor = tdd_factor;
inputs.set_basal = set_basal;
inputs.basal_rate = basal_rate;

if (autotune_data) {
if (autotune_data.basalprofile) { inputs.basals = autotune_data.basalprofile; }
Expand Down
36 changes: 32 additions & 4 deletions FreeAPS/Sources/APS/OpenAPS/OpenAPS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ final class OpenAPS {

// Update Suggestion
if var suggestion = Suggestion(from: suggested) {
// Add some reasons
// Process any eventual middleware basal rate
if let newSuggestion = self.overrideBasal(alteredProfile: alteredProfile, oref0Suggestion: suggestion) {
suggestion = newSuggestion
}
// Add some reasons, when needed
suggestion.reason = self.reasons(
reason: suggestion.reason,
suggestion: suggestion,
Expand Down Expand Up @@ -304,7 +308,7 @@ final class OpenAPS {
}
}

// Dsiplay either Target or Override (where target is included).
// Display either Target or Override (where target is included).
let targetGlucose = suggestion.targetBG
if targetGlucose != nil, let or = OverrideStorage().fetchLatestOverride().first, or.enabled {
var orString = ", Override:"
Expand Down Expand Up @@ -372,6 +376,23 @@ final class OpenAPS {
return reasonString
}

private func overrideBasal(alteredProfile: RawJSON, oref0Suggestion: Suggestion) -> Suggestion? {
guard let changeRate = readJSON(json: alteredProfile, variable: "set_basal"), Bool(changeRate) ?? false,
let basal_rate_is = readJSON(json: alteredProfile, variable: "basal_rate") else { return nil }

var returnSuggestion = oref0Suggestion
let basal_rate = Decimal(string: basal_rate_is) ?? 0
returnSuggestion.rate = basal_rate
returnSuggestion.duration = 30
var reasonString = oref0Suggestion.reason
let endIndex = reasonString.endIndex
let insertedResons: String = reasonString + "\n\nBasal Rate overridden in middleware to: \(basal_rate) U/h"
reasonString.insert(contentsOf: insertedResons, at: endIndex)
returnSuggestion.reason = reasonString

return returnSuggestion
}

private func readJSON(json: RawJSON, variable: String) -> String? {
if let string = json.debugDescription.components(separatedBy: ",").filter({ $0.contains(variable) }).first {
let targetComponents = string.components(separatedBy: ":")
Expand Down Expand Up @@ -432,12 +453,13 @@ final class OpenAPS {
let disableCGMError = settingsData?.disableCGMError ?? true

let cd = CoreDataStorage()
let os = OverrideStorage()
// TDD
let uniqueEvents = cd.fetchTDD(interval: DateFilter().tenDays)
// Temp Targets using slider
let sliderArray = cd.fetchTempTargetsSlider()
// Overrides
let overrideArray = OverrideStorage().fetchNumberOfOverrides(numbers: 2)
let overrideArray = os.fetchNumberOfOverrides(numbers: 2)
// Temp Target
let tempTargetsArray = cd.fetchTempTargets()

Expand Down Expand Up @@ -474,6 +496,11 @@ final class OpenAPS {
let overrideMaxIOB = overrideArray.first?.overrideMaxIOB ?? false
let maxIOB = overrideArray.first?.maxIOB ?? (preferences?.maxIOB ?? 0) as NSDecimalNumber

var name = ""
if useOverride, overrideArray.first?.isPreset ?? false, let overridePreset = os.isPresetName() {
name = overridePreset
}

if nrOfIndeces == 0 {
nrOfIndeces = 1
}
Expand Down Expand Up @@ -553,7 +580,8 @@ final class OpenAPS {
uamMinutes: (overrideArray.first?.uamMinutes ?? uamMinutes) as Decimal,
maxIOB: maxIOB as Decimal,
overrideMaxIOB: overrideMaxIOB,
disableCGMError: disableCGMError
disableCGMError: disableCGMError,
preset: name
)
storage.save(averages, as: OpenAPS.Monitor.dynamicVariables)
return self.loadFileFromStorage(name: Monitor.dynamicVariables)
Expand Down
6 changes: 6 additions & 0 deletions FreeAPS/Sources/APS/OpenAPS/TotalDailyDose.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ final class TotalDailyDose {
} else { return 0 }
}

func insulinToday(_ data: [PumpHistoryEvent], increment: Double) -> (bolus: Decimal, basal: Decimal, hours: Double) {
let filtered = data.filter({ $0.timestamp > Calendar.current.startOfDay(for: Date()) })

return totalDailyDose(filtered, increment: increment)
}

// All delivered boli (manual, external and SMBs)
private func bolus(_ data: [PumpHistoryEvent]) -> Decimal {
data.compactMap(\.amount).reduce(0, +)
Expand Down
30 changes: 30 additions & 0 deletions FreeAPS/Sources/APS/Storage/CoreDataStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,34 @@ final class CoreDataStorage {
}
return nr.first
}

func fetchMealPreset(_ name: String) -> Presets? {
var presetsArray = [Presets]()
var preset: Presets?
coredataContext.performAndWait {
let requestPresets = Presets.fetchRequest() as NSFetchRequest<Presets>
requestPresets.predicate = NSPredicate(
format: "dish == %@", name
)
try? presetsArray = self.coredataContext.fetch(requestPresets)

guard let mealPreset = presetsArray.first else {
return
}
preset = mealPreset
}
return preset
}

func fetchMealPresets() -> [Presets] {
var presetsArray = [Presets]()
coredataContext.performAndWait {
let requestPresets = Presets.fetchRequest() as NSFetchRequest<Presets>
requestPresets.predicate = NSPredicate(
format: "dish != %@", "" as String
)
try? presetsArray = self.coredataContext.fetch(requestPresets)
}
return presetsArray
}
}
8 changes: 8 additions & 0 deletions FreeAPS/Sources/Helpers/ScrollOffset.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import SwiftUI

struct ScrollViewOffsetPreferenceKey: PreferenceKey {
static var defaultValue = CGFloat.zero
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
value += nextValue()
}
}
15 changes: 15 additions & 0 deletions FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,18 @@ Enact a temp Basal or a temp target */
/* Override Shortcut */
"Activates an %@ Override Preset" = "Activates an %@ Override Preset";

/* Meal Prestes Shortcut */
"Which meal preset would you like to use?" = "Which meal preset would you like to use?";

/* Meal Prestes Shortcut */
"Are you sure you want to use the meal preset %@?" = "Are you sure you want to use the meal preset %@?";

/* Meal Prestes Shortcut */
"The Meal" = "The Meal";

/* Meal Prestes Shortcut */
"has been added to iAPS" = "has been added to iAPS";

/* */
"Schedule " = "Schedule ";

Expand Down Expand Up @@ -2494,6 +2506,9 @@ Enact a temp Basal or a temp target */
/* UI/UX option */
"Display Time Interval Setting Button" = "Display Time Interval Setting Button";

/* UI/UX option */
"Never display the small glucose chart when scrolling" = "Never display the small glucose chart when scrolling";

/* Setting title */
"Bolus Calculator" = "Bolus Calculator";

Expand Down
12 changes: 12 additions & 0 deletions FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,18 @@ Enact a temp Basal or a temp target */
/* Override Shortcut */
"Activates an %@ Override Preset" = "Aktiverar en %@ - profil";

/* Meal Prestes Shortcut */
"Which meal preset would you like to use?" = "Vilken måltid vill du lägga till?";

/* Meal Prestes Shortcut */
"Are you sure you want to use the meal preset %@?" = "Är du säker att du vill lägga till måltiden %@?";

/* Meal Prestes Shortcut */
"The Meal" = "Måltiden";

/* Meal Prestes Shortcut */
"has been added to iAPS" = "har lagt till i iAPS";

/* */
"Schedule " = "Schema ";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@

/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@

/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@
/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@
/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@
/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@

/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@
/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@

/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@
/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@
/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@
/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@
/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@
/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@
/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@

/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,15 @@

/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@

/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@
/* iAPS Bolus shortcut description */
"${applicationName} Enacts a bolus" = "${applicationName} Enacts a bolus";

/* iAPS Override shortcut */
"${applicationName} Meal Presets" = "${applicationName} Meal Presets";

/* iAPS Meal presets shortcut description */
"Uses an ${applicationName} Meal Preset" = "Uses an ${applicationName} Meal Preset";
Loading

0 comments on commit d069246

Please sign in to comment.