diff --git a/libraries/Filter/FilterWithBuffer.h b/libraries/Filter/FilterWithBuffer.h index df2fcdd8a0..6a8a2955ee 100644 --- a/libraries/Filter/FilterWithBuffer.h +++ b/libraries/Filter/FilterWithBuffer.h @@ -22,22 +22,24 @@ template class FilterWithBuffer : public Filter { - public: - // constructor - FilterWithBuffer(); +public: + // constructor + FilterWithBuffer(); - // apply - Add a new raw value to the filter, retrieve the filtered result - virtual T apply(T sample); + // apply - Add a new raw value to the filter, retrieve the filtered result + virtual T apply(T sample); - // reset - clear the filter - virtual void reset(); + // reset - clear the filter + virtual void reset(); - // get filter size - virtual uint8_t get_filter_size() { return FILTER_SIZE; }; + // get filter size + virtual uint8_t get_filter_size() { + return FILTER_SIZE; + }; - protected: - T samples[FILTER_SIZE]; // buffer of samples - uint8_t sample_index; // pointer to the next empty slot in the buffer +protected: + T samples[FILTER_SIZE]; // buffer of samples + uint8_t sample_index; // pointer to the next empty slot in the buffer }; // Typedef for convenience @@ -70,42 +72,42 @@ typedef FilterWithBuffer FilterWithBufferUInt32_Size7; // Constructor template FilterWithBuffer::FilterWithBuffer() : - Filter(), - sample_index(0) + Filter(), + sample_index(0) { - // clear sample buffer - reset(); + // clear sample buffer + reset(); } // reset - clear all samples from the buffer template -void FilterWithBuffer::reset() +void FilterWithBuffer:: reset() { - // call base class reset - Filter::reset(); + // call base class reset + Filter::reset(); - // clear samples buffer - for( int8_t i=0; i -T FilterWithBuffer::apply(T sample) +T FilterWithBuffer:: apply(T sample) { - // add sample to array - samples[sample_index++] = sample; + // add sample to array + samples[sample_index++] = sample; - // wrap index if necessary - if( sample_index >= FILTER_SIZE ) - sample_index = 0; + // wrap index if necessary + if( sample_index >= FILTER_SIZE ) + sample_index = 0; - // base class doesn't know what filtering to do so we just return the raw sample - return sample; + // base class doesn't know what filtering to do so we just return the raw sample + return sample; } #endif