FastLED 3.9.15
Loading...
Searching...
No Matches
channel_events.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/function.h"
4#include "fl/stl/noexcept.h"
5#include "fl/stl/string.h" // IWYU pragma: keep
6
7namespace fl {
8
9class IChannel;
10class IChannelDriver; // IWYU pragma: keep
11class ChannelData;
12struct ChannelConfig;
13
43#if defined(FASTLED_DISABLE_CHANNEL_EVENTS) && FASTLED_DISABLE_CHANNEL_EVENTS
44
45namespace detail {
51struct NoOpChannelEvent {
52 template <typename... Args>
53 void operator()(Args&&...) const FL_NOEXCEPT {}
54
55 template <typename F>
56 int add(F&& /*f*/, int /*priority*/ = 0) const FL_NOEXCEPT { return -1; }
57
58 void remove(int /*id*/) const FL_NOEXCEPT {}
59};
60} // namespace detail
61
62struct ChannelEvents {
63 static ChannelEvents& instance() FL_NOEXCEPT {
64 static ChannelEvents s;
65 return s;
66 }
67
68 detail::NoOpChannelEvent onChannelCreated;
69 detail::NoOpChannelEvent onChannelBeginDestroy;
70 detail::NoOpChannelEvent onChannelAdded;
71 detail::NoOpChannelEvent onChannelRemoved;
72 detail::NoOpChannelEvent onChannelConfigured;
73 detail::NoOpChannelEvent onChannelDataEncoded;
74 detail::NoOpChannelEvent onChannelEnqueued;
75};
76
77#else
78
80 static ChannelEvents& instance();
81
82 // -- Lifecycle events --
83
85 fl::function_list<void(const IChannel&)> onChannelCreated;
86
88 fl::function_list<void(const IChannel&)> onChannelBeginDestroy;
89
90 // -- FastLED list events --
91
93 fl::function_list<void(const IChannel&)> onChannelAdded;
94
96 fl::function_list<void(const IChannel&)> onChannelRemoved;
97
98 // -- Configuration events --
99
101 fl::function_list<void(const IChannel&, const ChannelConfig&)> onChannelConfigured;
102
103 // -- Rendering events --
104
108 fl::function_list<void(const IChannel&, const ChannelData&)> onChannelDataEncoded;
109
112 fl::function_list<void(const IChannel&, const fl::string& driverName)> onChannelEnqueued;
113};
114
115#endif // FASTLED_DISABLE_CHANNEL_EVENTS
116
117} // namespace fl
Transmission data for a single LED channel.
Definition data.h:39
Minimal interface for LED channel transmission drivers.
Definition driver.h:49
Polymorphic identification base for any channel in the system.
Definition ichannel.h:23
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_traits.h:48
float add(float &a, float &b)
Iterator remove(Iterator first, Iterator last, const T &value) FL_NOEXCEPT
Definition algorithm.h:265
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT
Configuration for a single LED channel.
Definition config.h:163
fl::function_list< void(const IChannel &, const fl::string &driverName)> onChannelEnqueued
Fired after channel data is enqueued to a driver Second parameter is the driver name (empty string fo...
fl::function_list< void(const IChannel &)> onChannelCreated
Fired after a Channel is constructed via Channel::create()
fl::function_list< void(const IChannel &)> onChannelBeginDestroy
Fired at the start of ~Channel(), before members are torn down.
fl::function_list< void(const IChannel &, const ChannelData &)> onChannelDataEncoded
Fired after pixel data is encoded into byte stream (before enqueuing) Second parameter is the encoded...
fl::function_list< void(const IChannel &)> onChannelAdded
Fired after a Channel is added to FastLED's controller list.
fl::function_list< void(const IChannel &, const ChannelConfig &)> onChannelConfigured
Fired after applyConfig() reconfigures a Channel.
fl::function_list< void(const IChannel &)> onChannelRemoved
Fired after a Channel is removed from FastLED's controller list.
static ChannelEvents & instance()
Singleton event router for Channel lifecycle events.