FastLED 3.10.8
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#include "fl/stl/stdint.h"
7
8namespace fl {
9
10class IChannel;
11class IChannelDriver; // IWYU pragma: keep
12class ChannelData;
13struct ChannelConfig;
14enum class ColorProfileStatus : u8;
33
63#if defined(FASTLED_DISABLE_CHANNEL_EVENTS) && FASTLED_DISABLE_CHANNEL_EVENTS
64
65namespace detail {
71struct NoOpChannelEvent {
72 template <typename... Args>
73 void operator()(Args&&...) const FL_NO_EXCEPT {}
74
75 template <typename F>
76 int add(F&& /*f*/, int /*priority*/ = 0) const FL_NO_EXCEPT { return -1; }
77
78 void remove(int /*id*/) const FL_NO_EXCEPT {}
79};
80} // namespace detail
81
82struct ChannelEvents {
83 static ChannelEvents& instance() FL_NO_EXCEPT {
84 static ChannelEvents s;
85 return s;
86 }
87
88 detail::NoOpChannelEvent onChannelCreated;
89 detail::NoOpChannelEvent onChannelBeginDestroy;
90 detail::NoOpChannelEvent onChannelAdded;
91 detail::NoOpChannelEvent onChannelRemoved;
92 detail::NoOpChannelEvent onChannelConfigured;
93 detail::NoOpChannelEvent onColorProfileFallback;
94 detail::NoOpChannelEvent onColorProfileWarning;
95 detail::NoOpChannelEvent onChannelDataEncoded;
96 detail::NoOpChannelEvent onChannelEnqueued;
97};
98
99#else
100
103
104 // -- Lifecycle events --
105
107 fl::function_list<void(const IChannel&)> onChannelCreated;
108
110 fl::function_list<void(const IChannel&)> onChannelBeginDestroy;
111
112 // -- FastLED list events --
113
115 fl::function_list<void(const IChannel&)> onChannelAdded;
116
118 fl::function_list<void(const IChannel&)> onChannelRemoved;
119
120 // -- Configuration events --
121
123 fl::function_list<void(const IChannel&, const ChannelConfig&)> onChannelConfigured;
124 fl::function_list<void(const ColorProfileEvent&)> onColorProfileFallback;
125 fl::function_list<void(const ColorProfileEvent&)> onColorProfileWarning;
126
127 // -- Rendering events --
128
132 fl::function_list<void(const IChannel&, const ChannelData&)> onChannelDataEncoded;
133
136 fl::function_list<void(const IChannel&, const fl::string& driverName)> onChannelEnqueued;
137};
138
139#endif // FASTLED_DISABLE_CHANNEL_EVENTS
140
141} // namespace fl
Transmission data for a single LED channel.
Definition data.h:55
Minimal interface for LED channel transmission drivers.
Definition driver.h:52
Polymorphic identification base for any channel in the system.
Definition ichannel.h:23
Iterator remove(Iterator first, Iterator last, const T &value) FL_NO_EXCEPT
Definition algorithm.h:268
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_info.h:57
unsigned char u8
Definition stdint.h:131
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
ColorProfileWarning
float add(float &a, float &b) FL_NO_EXCEPT
ColorProfileStatus
Definition channel.h:42
Base definition for an LED controller.
Definition crgb.hpp:179
ColorProfileWarning warning
ColorProfileStatus status
Payload shared by every color-profile notification.
Configuration for a single LED channel.
Definition config.h:167
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...
static ChannelEvents & instance() FL_NO_EXCEPT
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 ColorProfileEvent &)> onColorProfileFallback
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.
fl::function_list< void(const ColorProfileEvent &)> onColorProfileWarning
Singleton event router for Channel lifecycle events.