From dbba304af88ffc710c6bd1bd49a36c7355a8f416 Mon Sep 17 00:00:00 2001 From: uncrustify Date: Thu, 16 Aug 2012 23:22:11 -0700 Subject: [PATCH] uncrustify libraries/Filter/AverageFilter.h --- libraries/Filter/AverageFilter.h | 55 ++++++++++++++++---------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/libraries/Filter/AverageFilter.h b/libraries/Filter/AverageFilter.h index 2384233d28..89cc6ffd8c 100644 --- a/libraries/Filter/AverageFilter.h +++ b/libraries/Filter/AverageFilter.h @@ -16,24 +16,25 @@ #include #include -// 1st parameter is the type of data being filtered. +// 1st parameter is the type of data being filtered. // 2nd parameter is a larger data type used during summation to prevent overflows // 3rd parameter is the number of elements in the filter template class AverageFilter : public FilterWithBuffer { - public: - // constructor - AverageFilter() : FilterWithBuffer(), _num_samples(0) {}; +public: + // constructor + AverageFilter() : FilterWithBuffer(), _num_samples(0) { + }; - // 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(); - private: - uint8_t _num_samples; // the number of samples in the filter, maxes out at size of the filter +private: + uint8_t _num_samples; // the number of samples in the filter, maxes out at size of the filter }; // Typedef for convenience (1st argument is the data type, 2nd is a larger datatype to handle overflows, 3rd is buffer size) @@ -69,34 +70,34 @@ typedef AverageFilter AverageFilterFloat_Size5; // Public Methods ////////////////////////////////////////////////////////////// template -T AverageFilter::apply(T sample) +T AverageFilter:: apply(T sample) { - U result = 0; + U result = 0; - // call parent's apply function to get the sample into the array - FilterWithBuffer::apply(sample); + // call parent's apply function to get the sample into the array + FilterWithBuffer::apply(sample); - // increment the number of samples so far - _num_samples++; - if( _num_samples > FILTER_SIZE || _num_samples == 0 ) - _num_samples = FILTER_SIZE; + // increment the number of samples so far + _num_samples++; + if( _num_samples > FILTER_SIZE || _num_samples == 0 ) + _num_samples = FILTER_SIZE; - // get sum of all values - there is a risk of overflow here that we ignore - for(uint8_t i=0; i::samples[i]; + // get sum of all values - there is a risk of overflow here that we ignore + for(uint8_t i=0; i::samples[i]; - return (T)(result / _num_samples); + return (T)(result / _num_samples); } // reset - clear all samples template -void AverageFilter::reset() +void AverageFilter:: reset() { - // call parent's apply function to get the sample into the array - FilterWithBuffer::reset(); + // call parent's apply function to get the sample into the array + FilterWithBuffer::reset(); - // clear our variable - _num_samples = 0; + // clear our variable + _num_samples = 0; } #endif