| 30 | namespace fl { |
| 31 | |
| 32 | class CLEDController { |
| 33 | protected: |
| 34 | friend class CFastLED; |
| 35 | fl::span<CRGB> mLeds; ///< span of LED data used by this controller |
| 36 | CLEDController *mPNext = nullptr; ///< pointer to the next LED controller in the linked list |
| 37 | ChannelOptions mSettings; ///< Optional channel settings (correction, temperature, dither, rgbw, affinity) |
| 38 | bool mEnabled = true; |
| 39 | static CLEDController *mPHead; ///< pointer to the first LED controller in the linked list |
| 40 | static CLEDController *mPTail; ///< pointer to the last LED controller in the linked list |
| 41 | |
| 42 | /// @brief Registration mode for constructor |
| 43 | enum class RegistrationMode { |
| 44 | AutoRegister, ///< Automatically add to linked list (default, backward compatible) |
| 45 | DeferRegister ///< Defer registration until addToList() is called |
| 46 | }; |
| 47 | |
| 48 | /// @brief Protected constructor with registration mode |
| 49 | /// @param mode Registration mode (AutoRegister or DeferRegister) |
| 50 | /// @note Subclasses can use DeferRegister to control when they join the linked list |
| 51 | CLEDController(RegistrationMode mode) FL_NOEXCEPT; |
| 52 | |
| 53 | public: |
| 54 | /// @brief Add this controller to the linked list |
| 55 | /// @note Used with DeferRegister mode to explicitly add controller to list |
| 56 | /// @note Safe to call multiple times - won't add if already in list |
| 57 | void addToList() FL_NOEXCEPT; |
| 58 | |
| 59 | /// @brief Check if this controller is in the linked list |
| 60 | /// @return true if controller is in the list, false otherwise |
| 61 | bool isInList() const FL_NOEXCEPT; |
| 62 | |
| 63 | /// Set all the LEDs to a given color. |
| 64 | /// @param data the CRGB color to set the LEDs to |
| 65 | /// @param nLeds the number of LEDs to set to this color |
| 66 | /// @param scale the rgb scaling value for outputting color |
| 67 | virtual void showColor(const CRGB & data, int nLeds, fl::u8 brightness) FL_NOEXCEPT = 0; |
| 68 | |
| 69 | /// Write the passed in RGB data out to the LEDs managed by this controller. |
| 70 | /// @param data the rgb data to write out to the strip |
| 71 | /// @param nLeds the number of LEDs being written out |
| 72 | /// @param scale the rgb scaling to apply to each led before writing it out |
| 73 | virtual void show(const CRGB *data, int nLeds, fl::u8 brightness) FL_NOEXCEPT = 0; |
| 74 | |
| 75 | CLEDController& setRgbw(const Rgbw& arg = RgbwDefault::value()) FL_NOEXCEPT { |
| 76 | // Note that at this time (Sept 13th, 2024) this is only implemented in the ESP32 driver |
| 77 | // directly. For an emulated version please see RGBWEmulatedController in chipsets.h |
| 78 | // |
| 79 | // (#2558) mSettings.mWhiteCfg is now a fl::variant<Empty, Rgbw, Rgbww>; |
| 80 | // assigning Rgbw selects the 4-channel alternative. The legacy |
| 81 | // "setRgbw(RgbwInvalid::value()) → disable" semantics are preserved |
| 82 | // by translating an inactive Rgbw into Empty so observers see the |
| 83 | // same "no white channel" state they did before the variant migration. |
| 84 | if (!arg.active()) { |
| 85 | mSettings.mWhiteCfg.reset(); |
| 86 | } else { |
| 87 | mSettings.mWhiteCfg = arg; |
| 88 | } |
| 89 | return *this; // builder pattern. |
nothing calls this directly
no test coverage detected