FastLED 3.9.15
Loading...
Searching...
No Matches
leaky_integrator_impl.h
Go to the documentation of this file.
1#pragma once
2
4#include "fl/stl/noexcept.h"
5
6namespace fl {
7namespace detail {
8
9template <typename T, int K = 2>
11 public:
13 explicit LeakyIntegratorImpl(T initial) : mY(initial) {}
14
15 T update(T input) {
16 mY = mY + shift_right(input - mY);
17 return mY;
18 }
19
20 T value() const { return mY; }
21 void reset(T initial = T(0)) { mY = initial; }
22
23 private:
24 template <typename U = T>
26 shift_right(U val) { return val / static_cast<U>(1 << K); }
27
28 template <typename U = T>
30 shift_right(U val) { return val >> K; }
31
32 T mY;
33};
34
35} // namespace detail
36} // namespace fl
static fl::enable_if< fl::is_floating_point< U >::value, U >::type shift_right(U val)
static fl::enable_if<!fl::is_floating_point< U >::value, U >::type shift_right(U val)
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_traits.h:48
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT