Plaquette
 
Loading...
Searching...
No Matches
Smoother.h
1/*
2 * Smoother.h
3 *
4 * (c) 2015 Sofian Audry :: info(@)sofianaudry(.)com
5 * (c) 2015 Thomas O Fredericks :: tof(@)t-o-f(.)info
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef SMOOTHER_H_
22#define SMOOTHER_H_
23
24#include "PqCore.h"
25
26namespace pq {
27
29class Smoother : public Unit, public MovingAverage {
30public:
36
42 Smoother(float smoothingWindow, Engine& engine = Engine::primary());
43 virtual ~Smoother() {}
44
50 virtual float put(float value);
51
53 virtual float get() { return MovingAverage::get(); }
54
55protected:
56 virtual void step();
57
58 // Variables used to compute current value average during a step (in case of multiple calls to put()).
59 float _currentValueStep;
60 uint8_t _nValuesStep;
61};
62
63}
64
65#endif
The main Plaquette static class containing all the units.
Definition PqCore.h:60
static Engine & primary()
Returns the main instance of Plaquette.
Definition PqCore.cpp:31
An exponential moving average class.
Definition MovingAverage.h:35
float get()
Returns the value of the moving average. This is undefined if isValid() == false.
Definition MovingAverage.h:73
Simple moving average transform filter.
Definition Smoother.h:29
virtual float get()
Returns smoothed value.
Definition Smoother.h:53
virtual float put(float value)
Pushes value into the unit.
Definition Smoother.cpp:36
A generic class representing a unit in the system.
Definition PqCore.h:335
Engine * engine() const
Returns the engine that owns this unit.
Definition PqCore.h:382