MCPcopy Create free account
hub / github.com/Blueforcer/awtrix3 / EffectOverlay

Function EffectOverlay

src/effects.cpp:1234–1361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1232}
1233
1234void EffectOverlay(FastLED_NeoMatrix *matrix, int16_t x, int16_t y, OverlayEffect effect)
1235{
1236 static CRGB leds[32][8] = {CRGB::Black}; // Initialize all LEDs to black
1237 static int colorChanges[32][8] = {0};
1238 static bool lightning = false; // Track whether lightning is happening
1239 static unsigned long lastLightningMillis = 0; // Store last time lightning happened
1240 static unsigned long lastUpdate[32][8] = {0}; // Store the last update time for each LED
1241 static int lightningDuration = 50; // Duration of lightning flash in milliseconds
1242 static int updateFrame = 0; // Counter to control the update rate of the display
1243 static int windFrame = 0; // Additional variable for wind logic during storms
1244 static unsigned long lastIceUpdateMillis = 0; // Store the last time ice pixels were updated
1245 static int fadeInterval = 10; // Interval in milliseconds for each fade step
1246
1247 // Handle lightning logic
1248 if (effect == THUNDER)
1249 {
1250 if (random8() < 1)
1251 { // Chance of lightning
1252 lightning = true;
1253 lastLightningMillis = millis();
1254 }
1255 else if (lightning && (millis() - lastLightningMillis > lightningDuration))
1256 {
1257 lightning = false;
1258 }
1259 }
1260
1261 // Generate weather effects based on the specified effect
1262 int rainChance = (effect == STORM || effect == THUNDER ? 60 : (effect == DRIZZLE ? 15 : 50));
1263 CRGB color = (effect == DRIZZLE ? CHSV(160, 255, 230) : CHSV(160, 255, 200)); // Lighter blue for drizzle
1264 if (effect == RAIN || effect == STORM || effect == THUNDER || effect == DRIZZLE)
1265 {
1266 if (random8() < rainChance)
1267 {
1268 int randomColumn = random8(32);
1269 leds[randomColumn][0] = color;
1270 }
1271 }
1272 else if (effect == SNOW && random8() < 20)
1273 {
1274 int randomColumn = random8(32);
1275 leds[randomColumn][0] = CHSV(0, 0, 255); // White for snow
1276 }
1277
1278 // ICE effect logic
1279 if (effect == FROST)
1280 {
1281 // Go through each LED and update its status
1282 for (int i = 0; i < 32; i++)
1283 {
1284 for (int j = 0; j < 8; j++)
1285 {
1286 // If a pixel is currently active, update its color
1287 if (colorChanges[i][j] > 0)
1288 {
1289 leds[i][j] = ColorFromPalette(OceanColors_p, random8(), 255, LINEARBLEND);
1290 colorChanges[i][j]++;
1291 // Turn off the pixel after MAX_COLOR_CHANGES changes

Callers 3

NotifyOverlayFunction · 0.85
ShowCustomAppFunction · 0.85
tickMethod · 0.85

Calls 1

drawPixelMethod · 0.80

Tested by

no test coverage detected