mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-20 00:55:58 -04:00
2.1 KiB
2.1 KiB
TOPMIN
Arduino library to track the top N minima.
Description
This experimental library tracks the top N minima of a series of values. It can be used e.g. to track the top 5 lowest temperatures over a given period of time.
Links
- https://github.com/RobTillaart/TOPMIN
- https://github.com/RobTillaart/TOPMIN
- https://github.com/RobTillaart/runningAverage
- https://github.com/RobTillaart/MINMAX
Interface
#include "TOPMIN.h"
- TOPMIN(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 TOPMIN object to check it needs to be in the top N of minima.
- 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
- 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.