File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11//
22// FILE: RunningMedian.cpp
33// AUTHOR: Rob dot Tillaart at gmail dot com
4- // VERSION: 0.1.10
4+ // VERSION: 0.1.11
55// PURPOSE: RunningMedian library for Arduino
66//
77// HISTORY:
1616// 0.1.08 - 2013-10-20 add getElement(), add getSottedElement() add predict()
1717// 0.1.09 - 2014-11-25 float to double (support ARM)
1818// 0.1.10 - 2015-03-07 fix clear
19+ // 0.1.11 - 2015-03-29 undo 0.1.10 fix clear
1920//
2021// Released to the public domain
2122//
@@ -48,8 +49,7 @@ void RunningMedian::clear()
4849 _cnt = 0 ;
4950 _idx = 0 ;
5051 _sorted = false ;
51-
52- for (uint8_t i=0 ; i< _size; i++) _p[i] = 0 ;
52+ for (uint8_t i = 0 ; i< _size; i++) _p[i] = i;
5353}
5454
5555// adds a new value to the data-set
@@ -148,10 +148,10 @@ double RunningMedian::predict(uint8_t n)
148148void RunningMedian::sort ()
149149{
150150 // bubble sort with flag
151- for (uint8_t i= 0 ; i< _cnt-1 ; i++)
151+ for (uint8_t i = 0 ; i < _cnt-1 ; i++)
152152 {
153153 bool flag = true ;
154- for (uint8_t j= 1 ; j< _cnt-i; j++)
154+ for (uint8_t j = 1 ; j < _cnt-i; j++)
155155 {
156156 if (_ar[_p[j-1 ]] > _ar[_p[j]])
157157 {
@@ -163,7 +163,6 @@ void RunningMedian::sort()
163163 }
164164 if (flag) break ;
165165 }
166-
167166 _sorted = true ;
168167}
169168
Original file line number Diff line number Diff line change 22// FILE: RunningMedian.h
33// AUTHOR: Rob dot Tillaart at gmail dot com
44// PURPOSE: RunningMedian library for Arduino
5- // VERSION: 0.1.10
5+ // VERSION: 0.1.11
66// URL: http://arduino.cc/playground/Main/RunningMedian
77// HISTORY: See RunningMedian.cpp
88//
2020
2121#include < inttypes.h>
2222
23- #define RUNNING_MEDIAN_VERSION " 0.1.10 "
23+ #define RUNNING_MEDIAN_VERSION " 0.1.11 "
2424
2525// prepare for dynamic version
2626// not tested use at own risk :)
You can’t perform that action at this time.
0 commit comments