libNeon
Loading...
Searching...
No Matches
any_fx.hpp
Go to the documentation of this file.
1//
2// Created by spak on 10/6/21.
3//
4
5#ifndef NEO_ANY_FX_HPP
6#define NEO_ANY_FX_HPP
7
8#include <cstdint>
9#include <mlab/any_of.hpp>
10#include <mlab/bin_data.hpp>
11#include <neo/gradient_fx.hpp>
12#include <neo/matrix_fx.hpp>
13#include <neo/solid_fx.hpp>
14
15namespace neo {
16
17 enum struct fx_type : std::uint8_t {
18 solid = 0,
19 gradient = 1,
20 matrix = 2
21 };
22
23
24 template <fx_type>
26
27 class any_fx : public mlab::uniquely_tracked {
28 std::atomic<fx_type> _type = fx_type::solid;
32
33 friend class any_fx_config;
34
35 public:
36 any_fx() = default;
37
38 any_fx(any_fx &&other) noexcept;
39 any_fx &operator=(any_fx &&other) noexcept;
40
41 [[nodiscard]] inline fx_type type() const;
42 inline void set_type(fx_type t);
43
44 [[nodiscard]] inline solid_fx const &s_fx() const;
45 [[nodiscard]] inline gradient_fx const &g_fx() const;
46 [[nodiscard]] inline matrix_fx const &m_fx() const;
47
48 [[nodiscard]] std::function<void(std::chrono::milliseconds)> make_steady_timer_callback(
49 transmittable_rgb_strip &strip, rmt_channel_t channel, blending_method method = blend_linear) const;
50
51 std::vector<rgb> render_frame(transmittable_rgb_strip &strip, rmt_channel_t channel,
52 std::chrono::milliseconds elapsed, std::vector<rgb> recycle_buffer = {},
53 blending_method method = blend_linear) const;
54 };
55
56
57 class any_fx_config : public mlab::any_of<fx_type, any_fx_config_data> {
58 public:
59 using mlab::any_of<fx_type, any_fx_config_data>::any_of;
60 inline any_fx_config();
61
62 void apply(any_fx &fx) const;
63
64 [[nodiscard]] std::string to_string() const;
65 };
66
67
68 template <>
71 };
72
73
74 template <>
77 };
78
79
80 template <>
83 };
84
85 solid_fx const &any_fx::s_fx() const {
86 return _s_fx;
87 }
88 gradient_fx const &any_fx::g_fx() const {
89 return _g_fx;
90 }
91 matrix_fx const &any_fx::m_fx() const {
92 return _m_fx;
93 }
94
96 return _type;
97 }
99 _type = t;
100 }
103}// namespace neo
104
105namespace mlab {
106 mlab::bin_stream &operator>>(mlab::bin_stream &s, neo::any_fx_config &fx_cfg);
107}
108
109#endif//NEO_ANY_FX_HPP
Definition: any_fx.hpp:57
std::string to_string() const
Definition: any_fx.cpp:53
void apply(any_fx &fx) const
Definition: any_fx.cpp:65
any_fx_config()
Definition: any_fx.hpp:101
Definition: any_fx.hpp:27
solid_fx const & s_fx() const
Definition: any_fx.hpp:85
gradient_fx _g_fx
Definition: any_fx.hpp:30
matrix_fx _m_fx
Definition: any_fx.hpp:31
gradient_fx const & g_fx() const
Definition: any_fx.hpp:88
void set_type(fx_type t)
Definition: any_fx.hpp:98
any_fx & operator=(any_fx &&other) noexcept
Definition: any_fx.cpp:13
solid_fx _s_fx
Definition: any_fx.hpp:29
std::atomic< fx_type > _type
Definition: any_fx.hpp:28
matrix_fx const & m_fx() const
Definition: any_fx.hpp:91
std::vector< rgb > render_frame(transmittable_rgb_strip &strip, rmt_channel_t channel, std::chrono::milliseconds elapsed, std::vector< rgb > recycle_buffer={}, blending_method method=blend_linear) const
Definition: any_fx.cpp:36
std::function< void(std::chrono::milliseconds)> make_steady_timer_callback(transmittable_rgb_strip &strip, rmt_channel_t channel, blending_method method=blend_linear) const
Definition: any_fx.cpp:24
any_fx()=default
fx_type type() const
Definition: any_fx.hpp:95
Definition: gradient_fx.hpp:20
Definition: gradient.hpp:86
Definition: matrix_fx.hpp:21
Definition: solid_fx.hpp:15
Definition: strip.hpp:39
Definition: strip.hpp:29
Definition: any_fx.cpp:81
mlab::bin_stream & operator>>(mlab::bin_stream &s, neo::any_fx_config &fx_cfg)
Definition: any_fx.cpp:83
Definition: any_fx.cpp:7
rgb(&)(rgb l, rgb r, float t) blending_method
Definition: gradient.hpp:13
fx_type
Definition: any_fx.hpp:17
rgb blend_linear(rgb l, rgb r, float t)
Definition: gradient.cpp:96
any_fx_config_data(gradient_fx_config cfg)
Definition: any_fx.hpp:76
any_fx_config_data(matrix_fx_config cfg)
Definition: any_fx.hpp:82
any_fx_config_data(solid_fx_config cfg)
Definition: any_fx.hpp:70
Definition: any_fx.hpp:25
Definition: gradient_fx.hpp:53
Definition: matrix_fx.hpp:79
Definition: solid_fx.hpp:37