11// / @file channel.cpp
22// / @brief LED channel implementation
33
4- #include " channel.h"
5- #include " channel_config.h"
6- #include " channel_data.h"
7- #include " channel_engine.h"
4+ #include " fl/channels/channel.h"
5+ #include " fl/channels/config.h"
6+ #include " fl/channels/data.h"
7+ #include " fl/channels/engine.h"
8+ #include " fl/channels/bus_manager.h"
89#include " ftl/atomic.h"
910#include " fl/dbg.h"
10- #include " fl/led_settings.h"
11+ #include " fl/warn.h"
12+ #include " fl/channels/options.h"
1113#include " fl/pixel_iterator_any.h"
1214#include " pixel_controller.h"
1315
@@ -25,13 +27,31 @@ int32_t Channel::nextId() {
2527 return gNextChannelId .fetch_add (1 );
2628}
2729
28- ChannelPtr Channel::create (const ChannelConfig &config, IChannelEngine* engine) {
30+ ChannelPtr Channel::create (const ChannelConfig &config) {
31+ IChannelEngine* selectedEngine = nullptr ;
32+
33+ // Handle affinity binding: if affinity is specified, look up engine by name
34+ if (config.options .affinity && config.options .affinity [0 ]) {
35+ selectedEngine = ChannelBusManager::instance ().getEngineByName (config.options .affinity );
36+ if (selectedEngine) {
37+ FL_DBG (" Channel: Bound to engine '" << config.options .affinity << " ' via affinity" );
38+ } else {
39+ FL_WARN (" Channel: Affinity engine '" << config.options .affinity << " ' not found or not enabled - using ChannelBusManager" );
40+ }
41+ }
42+
43+ // If no affinity or affinity engine not found, use ChannelBusManager
44+ if (!selectedEngine) {
45+ selectedEngine = &ChannelBusManager::instance ();
46+ FL_DBG (" Channel: Using ChannelBusManager for engine selection" );
47+ }
48+
2949 return fl::make_shared<Channel>(config.pin , config.timing , config.mLeds ,
30- config.rgb_order , engine , config.settings );
50+ config.rgb_order , selectedEngine , config.options );
3151}
3252
3353Channel::Channel (int pin, const ChipsetTimingConfig& timing, fl::span<CRGB > leds,
34- EOrder rgbOrder, IChannelEngine* engine, const LEDSettings& settings )
54+ EOrder rgbOrder, IChannelEngine* engine, const ChannelOptions& options )
3555 : CPixelLEDController<RGB >()
3656 , mPin (pin)
3757 , mTiming (timing)
@@ -48,11 +68,11 @@ Channel::Channel(int pin, const ChipsetTimingConfig& timing, fl::span<CRGB> leds
4868 // Set the LED data array
4969 setLeds (leds);
5070
51- // Set color correction/temperature/dither/rgbw from LEDSettings
52- setCorrection (settings .correction );
53- setTemperature (settings .temperature );
54- setDither (settings .ditherMode );
55- setRgbw (settings .rgbw );
71+ // Set color correction/temperature/dither/rgbw from ChannelOptions
72+ setCorrection (options .correction );
73+ setTemperature (options .temperature );
74+ setDither (options .ditherMode );
75+ setRgbw (options .rgbw );
5676
5777 // Create ChannelData during construction
5878 mChannelData = ChannelData::create (mPin , mTiming );
0 commit comments