ESPHome
2024.11.2
|
Simple median filter. More...
#include <filter.h>
Public Member Functions | |
MedianFilter (size_t window_size, size_t send_every, size_t send_first_at) | |
Construct a MedianFilter. More... | |
optional< float > | new_value (float value) override |
void | set_send_every (size_t send_every) |
void | set_window_size (size_t window_size) |
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. More... | |
void | input (float value) |
void | output (float value) |
Protected Attributes | |
std::deque< float > | queue_ |
size_t | send_every_ |
size_t | send_at_ |
size_t | window_size_ |
Protected Attributes inherited from esphome::sensor::Filter | |
friend | Sensor |
Filter * | next_ {nullptr} |
Sensor * | parent_ {nullptr} |
Simple median filter.
Takes the median of the last <send_every> values and pushes it out every <send_every>.
|
explicit |
Construct a MedianFilter.
window_size | The number of values that should be used in median calculation. |
send_every | After how many sensor values should a new one be pushed out. |
send_first_at | After how many values to forward the very first value. Defaults to the first value on startup being published on the first raw value, so with no filter applied. Must be less than or equal to send_every. |
Definition at line 35 of file filter.cpp.
|
overridevirtual |
Implements esphome::sensor::Filter.
Definition at line 39 of file filter.cpp.
void esphome::sensor::MedianFilter::set_send_every | ( | size_t | send_every | ) |
Definition at line 37 of file filter.cpp.
void esphome::sensor::MedianFilter::set_window_size | ( | size_t | window_size | ) |
Definition at line 38 of file filter.cpp.
|
protected |
|
protected |
|
protected |