diff --git a/src/modules/ekf2/EKF/RingBuffer.h b/src/modules/ekf2/EKF/RingBuffer.h index e11a1f95c2..aeb4471ad5 100644 --- a/src/modules/ekf2/EKF/RingBuffer.h +++ b/src/modules/ekf2/EKF/RingBuffer.h @@ -81,10 +81,7 @@ public: _size = size; - _head = 0; - _tail = 0; - - _first_write = true; + reset(); return true; } @@ -171,6 +168,19 @@ public: return count; } + void reset() + { + if (_buffer) { + for (uint8_t i = 0; i < _size; i++) { + _buffer[i] = {}; + } + + _head = 0; + _tail = 0; + _first_write = true; + } + } + private: data_type *_buffer{nullptr};