| 209 | } |
| 210 | |
| 211 | void displayFrameOnLEDs(const fl::Frame& frame) { |
| 212 | for (int y = 0; y < ledHeight; y++) { |
| 213 | for (int x = 0; x < ledWidth; x++) { |
| 214 | // Calculate source pixel coordinates (with scaling) |
| 215 | int srcX = (x * (int)frame.getWidth()) / ledWidth; |
| 216 | int srcY = (y * (int)frame.getHeight()) / ledHeight; |
| 217 | |
| 218 | // Get pixel from frame |
| 219 | CRGB color = getPixelFromFrame(frame, srcX, srcY); |
| 220 | |
| 221 | // Set LED color |
| 222 | int ledIndex = y * ledWidth + x; |
| 223 | if (ledIndex < numLeds) { |
| 224 | leds[ledIndex] = color; |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | CRGB getPixelFromFrame(const fl::Frame& frame, int x, int y) { |
| 231 | if (x >= (int)frame.getWidth() || y >= (int)frame.getHeight() || !frame.isValid()) { |
no test coverage detected