From 9995e7448b596e79e9f71f4139152b96d3b499f8 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Tue, 28 Apr 2020 21:31:25 +0200 Subject: [PATCH] RandomBGPlugin - stay between min and max The sinus is in interval [-1,1]. If we shift it by one interval it would map it to 0 to 2 times the interval -> divide by two. --- .../info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt index 27f3fd4b4c..bb008b383b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt @@ -79,7 +79,7 @@ class RandomBgPlugin @Inject constructor( val cal = GregorianCalendar() val currentMinute = cal.get(Calendar.MINUTE) + (cal.get(Calendar.HOUR_OF_DAY) % 2) * 60 - val bgMgdl = min + (max - min) + (max - min) * sin(currentMinute / 120.0 * 2 * PI) + val bgMgdl = min + ((max - min) + (max - min) * sin(currentMinute / 120.0 * 2 * PI))/2 val bgReading = BgReading() bgReading.value = bgMgdl