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.
This commit is contained in:
AdrianLxM 2020-04-28 21:31:25 +02:00 committed by Milos Kozak
parent 9ed1a9ba69
commit 9995e7448b

View file

@ -79,7 +79,7 @@ class RandomBgPlugin @Inject constructor(
val cal = GregorianCalendar() val cal = GregorianCalendar()
val currentMinute = cal.get(Calendar.MINUTE) + (cal.get(Calendar.HOUR_OF_DAY) % 2) * 60 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() val bgReading = BgReading()
bgReading.value = bgMgdl bgReading.value = bgMgdl