Added check for not enough value's
This commit is contained in:
parent
cd02fa6c0f
commit
49d2eb9f49
|
@ -34,6 +34,11 @@ class AvgSmoothingPlugin @Inject constructor(
|
||||||
|
|
||||||
@Suppress("LocalVariableName")
|
@Suppress("LocalVariableName")
|
||||||
override fun smooth(data: MutableList<InMemoryGlucoseValue>): MutableList<InMemoryGlucoseValue> {
|
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) {
|
for (i in data.lastIndex -1 downTo 1) {
|
||||||
// Check if value's are in a valid range
|
// Check if value's are in a valid range
|
||||||
|
|
Loading…
Reference in a new issue