PeakDetector was not triggering correctly when in apex mode (PEAK_MAX, PEAK_MIN).
It would trigger at the moment of crossing the triggerThreshold (behaving like crossing mode) rather than triggering when falling back beyond the fallbackTolerance.
The issue was due to _peakValue being reset to -FLT_MIN when fallingBack was true, but then immediately taking on the value of the next value at the next step :
if (isMax)
_peakValue = value;
(because value is always higher than -FLT_MIN, so isMax is true!)
Issue was fixed by adding if (_crossing) conditional to ensure that _peakValue will only be updated again after the next crossing.
PeakDetector was not triggering correctly when in apex mode (PEAK_MAX, PEAK_MIN). It would trigger at the moment of crossing the triggerThreshold (behaving like crossing mode) rather than triggering when falling back beyond the fallbackTolerance.
The issue was due to _peakValue being reset to -FLT_MIN when fallingBack was true, but then immediately taking on the value of the next value at the next step :
(because value is always higher than -FLT_MIN, so isMax is true!)
Issue was fixed by adding if (_crossing) conditional to ensure that _peakValue will only be updated again after the next crossing.