GY-63_MS5611/libraries/MINMAX/MINMAX.h

68 lines
1.3 KiB
C
Raw Normal View History

2021-10-14 08:54:11 -04:00
#pragma once
//
// FILE: MINMAX.h
// AUTHOR: Rob Tillaart
2022-12-07 08:58:50 -05:00
// VERSION: 0.2.0
2021-10-14 08:54:11 -04:00
// DATE: 2021-10-14
// PURPOSE: MINMAX library - simple peak finder
2022-12-07 08:58:50 -05:00
// URL: https://github.com/RobTillaart/MINMAX
2021-10-14 08:54:11 -04:00
#include "Arduino.h"
2022-12-07 08:58:50 -05:00
#define MINMAX_LIB_VERSION (F("0.2.0"))
2021-12-21 13:57:20 -05:00
#define MINMAX_NO_CHANGE 0X00
#define MINMAX_MIN_CHANGED 0X01
#define MINMAX_MAX_CHANGED 0X02
#define MINMAX_RESET_DONE 0X80
2021-10-14 08:54:11 -04:00
class MINMAX
{
2021-11-08 15:19:42 -05:00
public:
2021-10-14 08:54:11 -04:00
2022-12-07 08:58:50 -05:00
MINMAX();
uint8_t add(const float value);
void reset();
// call back function when there is a change
void addCallBack( void (* func)(void) );
// set the auto reset at certain count
// count == 0 implies no auto reset.
void setAutoResetCount(uint32_t count);
uint32_t getAutoResetCount();
// last value added
float lastValue();
// number of elements added.
uint32_t count();
// peak values so far.
float minimum();
float maximum();
// timestamp of the last minimum and maximum change in milliseconds since start.
uint32_t lastMin();
uint32_t lastMax();
2021-11-08 15:19:42 -05:00
private:
2022-11-17 11:36:35 -05:00
float _lastValue;
2021-11-08 15:19:42 -05:00
float _minimum;
float _maximum;
uint32_t _count;
uint32_t _resetCount;
2022-11-17 11:36:35 -05:00
void (* _callback)(void);
uint32_t _lastMin;
uint32_t _lastMax;
2021-10-14 08:54:11 -04:00
};
2021-11-08 15:19:42 -05:00
2022-12-07 08:58:50 -05:00
// -- END OF FILE --
2021-11-08 15:19:42 -05:00