 #include <Adafruit_Sensor.h>
 #include <PDM.h>
 #include <KickFFT.h>
+#include <float.h>
 
 #define ACC_SIZE 64
 #define FFT_SIZE 512

            maxIndex = i;
        }
    }

    float phase = phase[maxIndex];

    // Add the rate to our phase even in the case where we don't update the rate.
    _phase_avg += _phaseRateAverage;

    if (maxIndex == _old_max_index && maxIndex > 1) {
        float phaseDiff = normalize_rads(phase - _old_phase);
        //Serial.print("PhaseDiff: "); Serial.println(phaseDiff);


        _phase_avg = (_phase_avg * 9 + phase) / 10;
        _phase_avg = normalize_rads(_phase_avg);
        //Serial.print("Phase    : "); Serial.println(phase);
        Serial.print("Phase Avg: "); Serial.println(_phase_avg);
    }
    _old_phase = phase;
    _old_max_index = maxIndex;
