libNeon
Loading...
Searching...
No Matches
solid_fx.hpp
Go to the documentation of this file.
1//
2// Created by spak on 10/6/21.
3//
4
5#ifndef NEO_SOLID_FX_HPP
6#define NEO_SOLID_FX_HPP
7
8#include <mlab/bin_data.hpp>
9#include <mlab/unique_tracker.hpp>
10#include <mutex>
11#include <neo/strip.hpp>
12
13namespace neo {
14
15 class solid_fx : public mlab::uniquely_tracked {
17 mutable std::recursive_mutex _color_mutex;
18
19 public:
20 inline explicit solid_fx(neo::rgb color = neo::rgb{0, 0, 0});
21
22 solid_fx(solid_fx &&other) noexcept;
23
24 solid_fx &operator=(solid_fx &&other) noexcept;
25
26 [[nodiscard]] inline rgb color() const;
27
28 inline void set_color(rgb c);
29
30 [[nodiscard]] std::function<void(std::chrono::milliseconds)>
31 make_steady_timer_callback(transmittable_rgb_strip &strip, rmt_channel_t channel) const;
32
33 void render_frame(transmittable_rgb_strip &strip, rmt_channel_t channel) const;
34 };
35
36
39
40 solid_fx_config() = default;
41
42 inline void apply(solid_fx &s_fx) const;
43
44 [[nodiscard]] std::string to_string() const;
45 };
46}// namespace neo
47
48
49namespace mlab {
50 mlab::bin_stream &operator>>(mlab::bin_stream &s, neo::solid_fx_config &m_fx_cfg);
51}
52
53
54namespace neo {
55
56 solid_fx::solid_fx(neo::rgb color) : _color{color} {}
57
59 std::scoped_lock lock{_color_mutex};
60 return _color;
61 }
62
64 std::scoped_lock lock{_color_mutex};
65 _color = c;
66 }
67
68 void solid_fx_config::apply(solid_fx &s_fx) const {
69 s_fx.set_color(color);
70 }
71}// namespace neo
72
73#endif//NEO_SOLID_FX_HPP
Definition: solid_fx.hpp:15
std::recursive_mutex _color_mutex
Definition: solid_fx.hpp:17
rgb color() const
Definition: solid_fx.hpp:58
solid_fx(neo::rgb color=neo::rgb{0, 0, 0})
Definition: solid_fx.hpp:56
std::function< void(std::chrono::milliseconds)> make_steady_timer_callback(transmittable_rgb_strip &strip, rmt_channel_t channel) const
Definition: solid_fx.cpp:32
solid_fx & operator=(solid_fx &&other) noexcept
Definition: solid_fx.cpp:15
neo::rgb _color
Definition: solid_fx.hpp:16
void render_frame(transmittable_rgb_strip &strip, rmt_channel_t channel) const
Definition: solid_fx.cpp:22
void set_color(rgb c)
Definition: solid_fx.hpp:63
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
Definition: color.hpp:47
Definition: solid_fx.hpp:37
std::string to_string() const
Definition: solid_fx.cpp:44
solid_fx_config()=default
void apply(solid_fx &s_fx) const
Definition: solid_fx.hpp:68
neo::rgb color
Definition: solid_fx.hpp:38