Added check for not enough value's

This commit is contained in:
jbr7rr 2022-12-13 09:46:59 +01:00
parent cd02fa6c0f
commit 49d2eb9f49

View file

@ -34,6 +34,11 @@ class AvgSmoothingPlugin @Inject constructor(
@Suppress("LocalVariableName")
override fun smooth(data: MutableList<InMemoryGlucoseValue>): MutableList<InMemoryGlucoseValue> {
if (data.lastIndex < 4)
{
aapsLogger.debug(LTag.GLUCOSE, "Not enough value's to smooth!")
return data
}
for (i in data.lastIndex -1 downTo 1) {
// Check if value's are in a valid range