You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libraries/MINMAX/README.md
+35-4Lines changed: 35 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,7 @@ Finally the library keeps track when the last peaks occurred.
44
44
-**MINMAX()** Constructor,
45
45
-**uint8_t add(float value)** add next value. Returns status (bit flags), see table below.
46
46
-**void reset()** resets the minimum and maximum to 0.
47
+
-**void setResetDefaults(float minimum, float maximum)** sets the default values for minimum and maximum defining an initial range / window.
47
48
-**float minimum()** returns last minimum. Can be higher than previous call due to **reset()** or **autoReset()**.
48
49
If no call to **add()** is made yet it will return 0.
49
50
-**float maximum()** returns last maximum. Can be lower than previous call due to **reset()** or **autoReset()**.
@@ -88,6 +89,30 @@ when the minimum or the maximum has changed.
88
89
See examples.
89
90
90
91
92
+
#### setResetDefaults()
93
+
94
+
-**void setResetDefaults(minimum, maximum)** sets the default values for minimum and maximum defining an initial range / window when **reset()** is called.
95
+
This will reduce an abundance of new min/max values in the first part of a stream, possibly causing unneeded call back calls.
96
+
97
+
The constructor sets both to zero (0) by default. The user can now override these values.
98
+
There are no default values for the parameters in the function.
99
+
The user is responsible and even allowed to set minimum to be larger than maximum.
100
+
The new values become active after the call to **reset()**.
101
+
102
+
The function does not change or reset the **lastMin()** and **lastMax()** timestamps.
103
+
Only after **reset()** these are set to 0 again.
104
+
105
+
Note that with an initial range set, the **lastMin()** and **lastMax()** timestamps
106
+
may be zero for quite a while.
107
+
108
+
Typical code snippet
109
+
110
+
```cpp
111
+
mm.setResetDefaults(-10, 20); // arbitrary values
112
+
mm.reset(); // activate them
113
+
```
114
+
115
+
91
116
## Obsolete
92
117
93
118
-**void autoReset(uint32_t count)** obsolete since 0.2.0
@@ -107,8 +132,9 @@ The examples show the basic working of the functions.
107
132
108
133
#### Should
109
134
110
-
- separate call back for MINMAX_MIN_CHANGED and MINMAX_MAX_CHANGED
111
-
- add getLastEvent()?
135
+
- consider an (featured) extended class and a (simple) base class.
136
+
- separate call back for **MINMAX_MIN_CHANGED** and **MINMAX_MAX_CHANGED**
137
+
- add **getLastEvent()**
112
138
- add AVG **average()****sum()**
113
139
- like a digital multimeter (DMM)
114
140
-**sum()** would be sufficient as average can be derived.
@@ -117,11 +143,16 @@ The examples show the basic working of the functions.
117
143
118
144
- Template class to allow other types
119
145
- int32_t uint64_t double etc.
120
-
- now you loose precision
146
+
- now you loose precision.
147
+
- a related class might be **WINDOW(min, max)** that counts and call backs if
148
+
a value is out of a predefined range.
149
+
-**void setResetDefaults(minimum, maximum, bool adjust = true)** add an adjust flag
150
+
that allows / reject adaption of min / max. (extended class).
151
+
- define MINMAX_MIN_CHANGED => MINMAX_MIN_EXCEEDED (new or reuse?)
0 commit comments