59 lines
913 B
C
Raw Normal View History

2023-05-18 21:22:02 +02:00
#pragma once
//
// FILE: TOPMIN.h
// AUTHOR: Rob Tillaart
2023-06-18 10:25:40 +02:00
// VERSION: 0.2.0
2023-05-18 21:22:02 +02:00
// DATE: 2023-05-18
// PURPOSE: Arduino library to track top n minima.
// URL: https://github.com/RobTillaart/TOPMIN
2023-06-18 10:25:40 +02:00
#include "Arduino.h"
2023-05-18 21:22:02 +02:00
2023-06-18 10:25:40 +02:00
#define TOPMIN_LIB_VERSION (F("0.2.0"))
2023-05-18 21:22:02 +02:00
class TOPMIN
{
public:
TOPMIN(uint8_t size = 5);
~TOPMIN();
uint8_t count();
uint8_t size();
void reset();
2023-06-16 09:46:29 +02:00
virtual bool add(float value);
2023-06-18 10:25:40 +02:00
virtual bool fill(float value);
2023-06-16 09:46:29 +02:00
float getValue(uint8_t index);
2023-05-18 21:22:02 +02:00
2023-06-16 09:46:29 +02:00
protected:
2023-05-18 21:22:02 +02:00
uint8_t _size;
uint8_t _count;
float * _arr;
};
2023-06-16 09:46:29 +02:00
////////////////////////////////////////////////////
//
// DERIVED
//
class TOPMINext : public TOPMIN
{
public:
TOPMINext(uint8_t size = 5);
TOPMINext();
bool add(float value, uint32_t tag);
2023-06-18 10:25:40 +02:00
bool fill(float value, uint32_t tag);
2023-06-16 09:46:29 +02:00
uint32_t getTag(uint8_t index);
private:
uint32_t * _tag;
};
2023-05-18 21:22:02 +02:00
// -- END OF FILE --