mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
.. | ||
.github | ||
examples/TOPMAX_demo | ||
test | ||
.arduino-ci.yml | ||
CHANGELOG.md | ||
keywords.txt | ||
library.json | ||
library.properties | ||
LICENSE | ||
README.md | ||
TOPMAX.cpp | ||
TOPMAX.h |
TOPMAX
Arduino library to track the top N maxima.
Description
This experimental library tracks the top N maxima of a series of values. It can be used e.g. to track the top 5 peak temperatures over a given period of time.
Links
- https://github.com/RobTillaart/TOPMAX
- https://github.com/RobTillaart/TOPMIN
- https://github.com/RobTillaart/runningAverage
- https://github.com/RobTillaart/MINMAX
Interface
#include "TOPMAX.h"
- TOPMAX(uint8_t size = 5) Constructor, defines the number of elements it can hold. Default number of elements is 5. If size < 3 it becomes 3.
- uint8_t count() returns the number of elements in the internal array.
- uint8_t size() returns the maximum number of elements in the internal array.
- void reset() reset the internal counter to 0, clearing the system.
- bool add(float value) add a value to the TOPMAX object to check it needs to be in the top N of maxima.
- float get(uint8_t index) get an element of the internal array. index == count().
- bool fill(float value) convenience function to fill the internal array with a single value e.g. 0.
Future
Must
- keep functional in sync with TOPMIN
- improve documentation.
Should
- add unit tests.
- add more examples.
Could
- create template class
- create derived class that holds an index or timestamp
- uint32_t extra per element.