|
| 1 | + |
| 2 | +[](https://github.com/marketplace/actions/arduino_ci) |
| 3 | +[](https://github.com/RobTillaart/RunningMinMax/actions/workflows/arduino-lint.yml) |
| 4 | +[](https://github.com/RobTillaart/RunningMinMax/actions/workflows/jsoncheck.yml) |
| 5 | +[](https://github.com/RobTillaart/RunningMinMax/issues) |
| 6 | + |
| 7 | +[](https://github.com/RobTillaart/RunningMinMax/blob/master/LICENSE) |
| 8 | +[](https://github.com/RobTillaart/RunningMinMax/releases) |
| 9 | +[](https://registry.platformio.org/libraries/robtillaart/RunningMinMax) |
| 10 | + |
| 11 | + |
| 12 | +# RunningMinMax |
| 13 | + |
| 14 | +Arduino library for a running Minimum and Maximum. |
| 15 | + |
| 16 | + |
| 17 | +## Description |
| 18 | + |
| 19 | +**Experimental** |
| 20 | + |
| 21 | +RunningMinMax stores values in a ring buffer and can return the minimum, |
| 22 | +maximum and the average of the buffer. |
| 23 | +The first implementation is not optimized. |
| 24 | + |
| 25 | +The library can be used e.g. to have an indication for the maximum |
| 26 | +volume for a VU meter. |
| 27 | + |
| 28 | +The library does not store timestamps of the samples (yet), that might |
| 29 | +be a function in the future. |
| 30 | + |
| 31 | +Feedback as always welcome. |
| 32 | + |
| 33 | + |
| 34 | +### Related |
| 35 | + |
| 36 | +- https://github.com/RobTillaart/Correlation |
| 37 | +- https://github.com/RobTillaart/GST - Golden standard test metrics |
| 38 | +- https://github.com/RobTillaart/Histogram |
| 39 | +- https://github.com/RobTillaart/infiniteAverage |
| 40 | +- https://github.com/RobTillaart/RunningAngle |
| 41 | +- https://github.com/RobTillaart/RunningAverage |
| 42 | +- https://github.com/RobTillaart/RunningMedian |
| 43 | +- https://github.com/RobTillaart/RunningMinMax |
| 44 | +- https://github.com/RobTillaart/statHelpers - combinations & permutations |
| 45 | +- https://github.com/RobTillaart/Statistic |
| 46 | +- https://github.com/RobTillaart/Student |
| 47 | + |
| 48 | +For printing floats in scientific or engineering format |
| 49 | + |
| 50 | +https://github.com/RobTillaart/printHelpers |
| 51 | + |
| 52 | + |
| 53 | +## Interface |
| 54 | + |
| 55 | +```cpp |
| 56 | +#include "RunningMinMax.h" |
| 57 | +``` |
| 58 | + |
| 59 | + |
| 60 | +### Constructor |
| 61 | + |
| 62 | +- **RunningMinMax(const uint8_t size)** Constructor, dynamically allocates memory. |
| 63 | +- **~RunningMinMax()** Destructor. |
| 64 | +- **uint8_t getSize()** returns size of internal array. |
| 65 | +- **uint8_t getCount()** returns current used elements, getCount() <= getSize(). |
| 66 | +- **bool isFull()** returns true if the internal buffer is 100% filled. |
| 67 | + |
| 68 | + |
| 69 | +### Base functions |
| 70 | + |
| 71 | +- **clear()** resets internal buffer and variables, effectively empty the buffer. |
| 72 | +- **add(const float value)** adds a new value to internal buffer, |
| 73 | +optionally replacing the oldest element if the buffer is full. |
| 74 | +- **float getAverage()** returns average of the values in the internal buffer. |
| 75 | +- **float getMaximum()** get the largest values in the buffer. |
| 76 | +- **float getMinimum()** get the smallest value in the buffer. |
| 77 | + |
| 78 | + |
| 79 | +## Future |
| 80 | + |
| 81 | +#### Must |
| 82 | + |
| 83 | +- improve documentation. |
| 84 | +- test |
| 85 | +- keep it a simple class. |
| 86 | + |
| 87 | +#### Should |
| 88 | + |
| 89 | +- check for optimizations. |
| 90 | + |
| 91 | +#### Could |
| 92 | + |
| 93 | +- check for optimizations. |
| 94 | +- add examples |
| 95 | +- extend unit tests |
| 96 | + |
| 97 | +#### Wont |
| 98 | + |
| 99 | + |
| 100 | +## Support |
| 101 | + |
| 102 | +If you appreciate my libraries, you can support the development and maintenance. |
| 103 | +Improve the quality of the libraries by providing issues and Pull Requests, or |
| 104 | +donate through PayPal or GitHub sponsors. |
| 105 | + |
| 106 | +Thank you, |
| 107 | + |
| 108 | + |
0 commit comments