|
|
@@ -848,13 +848,24 @@ extension MainViewController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- func speakBG(sgv: Int) {
|
|
|
- var speechSynthesizer = AVSpeechSynthesizer()
|
|
|
- var speechUtterance: AVSpeechUtterance = AVSpeechUtterance(string: "Current BG is " + bgUnits.toDisplayUnits(String(sgv)))
|
|
|
- speechUtterance.rate = AVSpeechUtteranceMaximumSpeechRate / 2
|
|
|
- speechUtterance.voice = AVSpeechSynthesisVoice(language: "en-US")
|
|
|
- speechSynthesizer.speak(speechUtterance)
|
|
|
- }
|
|
|
+ func speakBG(currentValue: Int, previousValue: Int) {
|
|
|
+ let bloodGlucoseDifference = currentValue - previousValue
|
|
|
+ let negligibleThreshold = 3
|
|
|
+ let differenceText: String
|
|
|
+
|
|
|
+ if abs(bloodGlucoseDifference) <= negligibleThreshold {
|
|
|
+ differenceText = "stable"
|
|
|
+ } else {
|
|
|
+ let direction = bloodGlucoseDifference < 0 ? "down" : "up"
|
|
|
+ let absoluteDifference = bgUnits.toDisplayUnits(String(abs(bloodGlucoseDifference)))
|
|
|
+ differenceText = "\(direction) \(absoluteDifference)"
|
|
|
+ }
|
|
|
+
|
|
|
+ let announcementText = "Current BG is \(bgUnits.toDisplayUnits(String(currentValue))), and it is \(differenceText)"
|
|
|
+ let speechUtterance = AVSpeechUtterance(string: announcementText)
|
|
|
+ speechUtterance.voice = AVSpeechSynthesisVoice(language: "en-US")
|
|
|
+ speechSynthesizer.speak(speechUtterance)
|
|
|
+ }
|
|
|
|
|
|
func isOnPhoneCall() -> Bool {
|
|
|
/*
|