| 171 | } |
| 172 | |
| 173 | void loop() { |
| 174 | // The main program loop that runs continuously |
| 175 | |
| 176 | // Set the overall brightness from the UI slider |
| 177 | FastLED.setBrightness(brightness); |
| 178 | |
| 179 | // Get the selected color palette |
| 180 | fl::CRGBPalette16 myPal = getPalette(); |
| 181 | |
| 182 | // Get the current time in milliseconds |
| 183 | uint32_t now = fl::millis(); |
| 184 | |
| 185 | // Update the animation speed from the UI slider |
| 186 | timeScale.setSpeed(speedY); |
| 187 | |
| 188 | // Calculate the current y-offset for animation (makes the fire move) |
| 189 | uint32_t y_speed = timeScale.update(now); |
| 190 | |
| 191 | // Loop through every LED in our cylindrical matrix |
| 192 | for (int width = 0; width < WIDTH; width++) { |
| 193 | for (int height = 0; height < HEIGHT; height++) { |
| 194 | // Calculate which color to use from our palette for this LED |
| 195 | // This function handles the cylindrical mapping using sine/cosine |
| 196 | uint8_t palette_index = |
| 197 | getPaletteIndex(now, width, WIDTH, height, HEIGHT, y_speed); |
| 198 | |
| 199 | // Get the actual RGB color from the palette |
| 200 | // BRIGHTNESS ensures we use the full brightness range |
| 201 | fl::CRGB c = ColorFromPalette(myPal, palette_index, BRIGHTNESS); |
| 202 | |
| 203 | // Convert our 2D coordinates to the 1D fl::array index |
| 204 | // We use (WIDTH-1)-width and (HEIGHT-1)-height to flip the coordinates |
| 205 | // This makes the fire appear to rise from the bottom |
| 206 | int index = xyMap((WIDTH - 1) - width, (HEIGHT - 1) - height); |
| 207 | |
| 208 | // Set the LED color in our fl::array |
| 209 | leds[index] = c; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | // Send the color data to the actual LEDs |
| 214 | FastLED.show(); |
| 215 | } |
nothing calls this directly
no test coverage detected