|
ESPHome 2026.3.2
|
Base class for filters that use a sliding window of values. More...
#include <filter.h>
Public Member Functions | |
| SlidingWindowFilter (size_t window_size, size_t send_every, size_t send_first_at) | |
| optional< float > | new_value (float value) final |
Public Member Functions inherited from esphome::sensor::Filter | |
| virtual void | initialize (Sensor *parent, Filter *next) |
| Initialize this filter, please note this can be called more than once. | |
| void | input (float value) |
| void | output (float value) |
Protected Member Functions | |
| virtual float | compute_result ()=0 |
| Called by new_value() to compute the filtered result from the current window. | |
Protected Attributes | |
| FixedVector< float > | window_ |
| Access the sliding window values (ring buffer implementation) Use: for (size_t i = 0; i < window_count_; i++) { float val = window_[i]; }. | |
| size_t | window_head_ {0} |
| Index where next value will be written. | |
| size_t | window_count_ {0} |
| Number of valid values in window (0 to window_size_) | |
| size_t | window_size_ |
| Maximum window size. | |
| size_t | send_every_ |
| Send result every N values. | |
| size_t | send_at_ |
| Counter for send_every. | |
Protected Attributes inherited from esphome::sensor::Filter | |
| friend | Sensor |
| Filter * | next_ {nullptr} |
| Sensor * | parent_ {nullptr} |
Base class for filters that use a sliding window of values.
Uses a ring buffer to efficiently maintain a fixed-size sliding window without reallocations or pop_front() overhead. Eliminates deque fragmentation issues.
| esphome::sensor::SlidingWindowFilter::SlidingWindowFilter | ( | size_t | window_size, |
| size_t | send_every, | ||
| size_t | send_first_at ) |
Definition at line 44 of file filter.cpp.
|
protectedpure virtual |
Called by new_value() to compute the filtered result from the current window.
Implemented in esphome::sensor::MaxFilter, esphome::sensor::MedianFilter, esphome::sensor::MinFilter, esphome::sensor::QuantileFilter, and esphome::sensor::SlidingWindowMovingAverageFilter.
|
finalvirtual |
Implements esphome::sensor::Filter.
Definition at line 50 of file filter.cpp.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |