| 298 | // ---------------------------------------------------------------------------- |
| 299 | |
| 300 | u8 SPITransposer::getLaneByte(const LaneData& lane, size_t byte_idx, size_t max_size) { |
| 301 | // Calculate padding needed for this lane |
| 302 | const size_t lane_size = lane.payload.size(); |
| 303 | const size_t padding_bytes = max_size - lane_size; |
| 304 | |
| 305 | // If we're in the padding region (prepended to beginning) |
| 306 | if (byte_idx < padding_bytes) { |
| 307 | // Return padding frame byte (repeating pattern) |
| 308 | if (!lane.padding_frame.empty()) { |
| 309 | return lane.padding_frame[byte_idx % lane.padding_frame.size()]; |
| 310 | } |
| 311 | return 0x00; // Fallback to zero |
| 312 | } |
| 313 | |
| 314 | // We're in the data region |
| 315 | const size_t data_idx = byte_idx - padding_bytes; |
| 316 | if (data_idx < lane_size) { |
| 317 | return lane.payload[data_idx]; |
| 318 | } |
| 319 | |
| 320 | // Should never reach here if max_size is correct |
| 321 | return 0x00; |
| 322 | } |
| 323 | |
| 324 | } // namespace fl |
| 325 | |