 uint16_t _old_max_index = 0;
 float _phase_avg = 0;
 float _phaseRateAverage = 1;
-void updatePhase(float mag[], float phase[], uint16_t startIndex, uint16_t endIndex) {
+
+float updatePhase(float mag[], float phases[], uint16_t startIndex, uint16_t endIndex) {
     float maxValue = -FLT_MAX;
     int maxIndex = startIndex;
     for (int i = startIndex; i < endIndex; i++) {

        _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;

#include <Adafruit_Sensor.h>
#include <PDM.h>
#include <KickFFT.h>
#include <float.h>

#define ACC_SIZE 64
#define FFT_SIZE 512
