| 163 | /// @brief Driver state with optional error message |
| 164 | /// @note Backward compatible: DriverState::READY, BUSY, DRAINING, ERROR still work |
| 165 | struct DriverState { |
| 166 | enum Value { |
| 167 | READY, ///< Hardware idle; ready to accept new transmissions |
| 168 | BUSY, ///< Active: channels transmitting or queued |
| 169 | DRAINING, ///< All channels submitted; still transmitting |
| 170 | ERROR, ///< Driver encountered an error |
| 171 | }; |
| 172 | |
| 173 | Value state; ///< Current driver state |
| 174 | fl::string error; ///< Error message (only populated when state == ERROR) |
| 175 | |
| 176 | /// @brief Construct from state only (no error) |
| 177 | DriverState(Value v) FL_NOEXCEPT : state(v), error() {} |
| 178 | |
| 179 | /// @brief Construct from state and error message |
| 180 | DriverState(Value v, const fl::string& e) FL_NOEXCEPT : state(v), error(e) {} |
| 181 | |
| 182 | /// @brief Implicit conversion to Value for backward compatibility |
| 183 | operator Value() const FL_NOEXCEPT { return state; } |
| 184 | |
| 185 | /// @brief Comparison operators for backward compatibility |
| 186 | bool operator==(Value v) const FL_NOEXCEPT { return state == v; } |
| 187 | bool operator!=(Value v) const FL_NOEXCEPT { return state != v; } |
| 188 | }; |
| 189 | |
| 190 | /// @brief Enqueue channel data for transmission |
| 191 | /// @param channelData Channel data to transmit |