@@ -138,7 +138,51 @@ final class NightscoutDataManager {
138138 let loopName = Bundle . main. bundleDisplayName
139139 let loopVersion = Bundle . main. shortVersionString
140140
141- let loopStatus = LoopStatus ( name: loopName, version: loopVersion, timestamp: statusTime, iob: iob, cob: cob, predicted: predicted, recommendedTempBasal: recommended, recommendedBolus: recommendedBolus, enacted: loopEnacted, failureReason: loopError)
141+ //add new loop parameters
142+ var loopParams : String = " "
143+ var loopBGTlow : String = " "
144+ var loopBGThigh : String = " "
145+ var loopEventualBG : String = " "
146+ if let loopBGRange = deviceDataManager. loopManager. settings. glucoseTargetRangeSchedule? . value ( at: Date ( ) ) , let userUnit = deviceDataManager. loopManager. settings. glucoseTargetRangeSchedule? . unit {
147+ if userUnit == HKUnit . milligramsPerDeciliter ( ) {
148+ loopBGTlow = String ( Int ( ( loopBGRange. minValue) ) )
149+ loopBGThigh = String ( Int ( ( loopBGRange. maxValue) ) )
150+ }
151+ else
152+ {
153+ loopBGTlow = String ( format: " %.1f " , ( loopBGRange. minValue) )
154+ loopBGThigh = String ( format: " %.1f " , ( loopBGRange. maxValue) )
155+ }
156+ }
157+
158+ else {
159+ loopBGTlow = " N/A "
160+ loopBGThigh = " N/A "
161+ }
162+
163+ if let loopEventualBGquantity = predictedGlucose? . last? . quantity, let userUnit = deviceDataManager. loopManager. settings. glucoseTargetRangeSchedule? . unit {
164+ if userUnit == HKUnit . milligramsPerDeciliter ( ) {
165+ loopEventualBG = String ( Int ( loopEventualBGquantity. doubleValue ( for: userUnit) ) )
166+ }
167+ else
168+ {
169+ loopEventualBG = String ( format: " %.1f " , loopEventualBGquantity. doubleValue ( for: userUnit) )
170+ }
171+ }
172+ else
173+ {
174+ loopEventualBG = " N/A "
175+ }
176+
177+ loopParams = " BGTargets ( " + loopBGTlow + " : " + loopBGThigh + " ) | EvBG " + loopEventualBG + " | " + loopName
178+
179+ //upload loopParams instead of just loopName
180+ //that is the only pill that has the option to modify the text
181+ let loopStatus = LoopStatus ( name: loopParams, version: loopVersion, timestamp: statusTime, iob: iob, cob: cob, predicted: predicted, recommendedTempBasal: recommended, recommendedBolus: recommendedBolus, enacted: loopEnacted, failureReason: loopError)
182+
183+ //if you wish to have the Loop pill clean, without the added BGtargets and EventualBG showing, remove the slashes on code line below, and add slashes to code line above
184+
185+ //let loopStatus = LoopStatus(name: loopName, version: loopVersion, timestamp: statusTime, iob: iob, cob: cob, predicted: predicted, recommendedTempBasal: recommended, recommendedBolus: recommendedBolus, enacted: loopEnacted, failureReason: loopError)
142186
143187 uploadDeviceStatus ( nil , loopStatus: loopStatus, includeUploaderStatus: false )
144188
0 commit comments