| 289 | |
| 290 | |
| 291 | float RunningAverage::getMaxInBufferLast(uint16_t count) |
| 292 | { |
| 293 | uint16_t cnt = count; |
| 294 | if (cnt > _count) cnt = _count; |
| 295 | if (cnt == 0) return NAN; |
| 296 | |
| 297 | uint16_t idx = _index; |
| 298 | if (idx == 0) idx = _size; |
| 299 | idx--; |
| 300 | float _max = _array[idx]; |
| 301 | for (uint16_t i = 0; i < cnt; i++) |
| 302 | { |
| 303 | if (_array[idx] > _max) _max = _array[idx]; |
| 304 | if (idx == 0) idx = _size; |
| 305 | idx--; |
| 306 | } |
| 307 | return _max; |
| 308 | } |
| 309 | |
| 310 | |
| 311 |