How can I write a script to get value of max gradient into activity?
This will do it. Gradient data is noisy so I added 10 point (usually second) moving average:
{
let gradient = icu.streams.grade_smooth
let window = 10
gradient = icu.stats.calcMovingAvg(gradient, window)
let max = 0
for (let i = window; i < gradient.length; i++) {
let g = gradient[i]
if (g > max) max = g
}
max
}
Thanks!