@brief UART-based channel driver for single-lane LED control Implements IChannelDriver interface using ESP32 UART peripheral for LED data transmission. Uses wave10 encoding with dynamic LUT generation.
| 47 | /// Implements IChannelDriver interface using ESP32 UART peripheral for |
| 48 | /// LED data transmission. Uses wave10 encoding with dynamic LUT generation. |
| 49 | class ChannelEngineUART : public IChannelDriver { |
| 50 | public: |
| 51 | explicit ChannelEngineUART(fl::shared_ptr<IUartPeripheral> peripheral) FL_NOEXCEPT; |
| 52 | ~ChannelEngineUART() override; |
| 53 | |
| 54 | bool canHandle(const ChannelDataPtr& data) const FL_NOEXCEPT override; |
| 55 | |
| 56 | void enqueue(ChannelDataPtr channelData) FL_NOEXCEPT override; |
| 57 | void show() FL_NOEXCEPT override; |
| 58 | DriverState poll() FL_NOEXCEPT override; |
| 59 | |
| 60 | fl::string getName() const FL_NOEXCEPT override { return fl::string::from_literal("UART"); } |
| 61 | |
| 62 | Capabilities getCapabilities() const FL_NOEXCEPT override { |
| 63 | return Capabilities(true, false); // Clockless only |
| 64 | } |
| 65 | |
| 66 | private: |
| 67 | void beginTransmission(fl::span<const ChannelDataPtr> channelData) FL_NOEXCEPT; |
| 68 | |
| 69 | void prepareScratchBuffer(fl::span<const ChannelDataPtr> channelData, |
| 70 | size_t maxChannelSize) FL_NOEXCEPT; |
| 71 | |
| 72 | /// @brief Get or create a Wave10Lut for the given timing |
| 73 | /// @param timing Chipset timing configuration |
| 74 | /// @return Reference to cached Wave10Lut |
| 75 | const Wave10Lut& getOrBuildLut(const ChipsetTimingConfig& timing) FL_NOEXCEPT; |
| 76 | |
| 77 | private: |
| 78 | struct ChipsetGroup { |
| 79 | ChipsetTimingConfig mTiming; |
| 80 | fl::vector<ChannelDataPtr> mChannels; |
| 81 | }; |
| 82 | |
| 83 | /// @brief Cached LUT entry (timing → LUT mapping) |
| 84 | struct LutCacheEntry { |
| 85 | ChipsetTimingConfig mTiming; |
| 86 | Wave10Lut mLut; |
| 87 | u32 mBaudRate; |
| 88 | }; |
| 89 | |
| 90 | fl::shared_ptr<IUartPeripheral> mPeripheral; |
| 91 | bool mInitialized; |
| 92 | u32 mCurrentBaudRate; ///< Currently configured baud rate |
| 93 | |
| 94 | fl::vector<u8> mScratchBuffer; |
| 95 | fl::vector<u8> mEncodedBuffer; |
| 96 | |
| 97 | fl::vector<ChannelDataPtr> mEnqueuedChannels; |
| 98 | fl::vector<ChannelDataPtr> mTransmittingChannels; |
| 99 | |
| 100 | fl::vector<ChipsetGroup> mChipsetGroups; |
| 101 | size_t mCurrentGroupIndex; |
| 102 | |
| 103 | /// @brief LUT cache for multi-timing support |
| 104 | fl::vector<LutCacheEntry> mLutCache; |
| 105 | }; |
| 106 |
no test coverage detected